1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
\set VERBOSITY terse
-- predictability
SET synchronous_commit = on;
DROP TABLE IF EXISTS xpto;
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json');
?column?
----------
init
(1 row)
CREATE TABLE xpto (a SERIAL PRIMARY KEY, b bool, c varchar(60), d real);
COMMIT;
WARNING: there is no transaction in progress
BEGIN;
INSERT INTO xpto (b, c, d) VALUES('t', 'test1', '+inf');
INSERT INTO xpto (b, c, d) VALUES('f', 'test2', 'nan');
INSERT INTO xpto (b, c, d) VALUES(NULL, 'null', '-inf');
INSERT INTO xpto (b, c, d) VALUES(TRUE, E'valid: '' " \\ / \b \f \n \r \t \u207F \u967F invalid: \\g \\k end', 123.456);
COMMIT;
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0');
data
-------------------------------------------------------------------------------------------------------------------------
{ +
"change": [ +
] +
}
{ +
"change": [ +
{ +
"kind": "insert", +
"schema": "public", +
"table": "xpto", +
"columnnames": ["a", "b", "c", "d"], +
"columntypes": ["int4", "bool", "varchar", "float4"], +
"columnvalues": [1, true, "test1", null] +
} +
,{ +
"kind": "insert", +
"schema": "public", +
"table": "xpto", +
"columnnames": ["a", "b", "c", "d"], +
"columntypes": ["int4", "bool", "varchar", "float4"], +
"columnvalues": [2, false, "test2", null] +
} +
,{ +
"kind": "insert", +
"schema": "public", +
"table": "xpto", +
"columnnames": ["a", "b", "c", "d"], +
"columntypes": ["int4", "bool", "varchar", "float4"], +
"columnvalues": [3, null, "null", null] +
} +
,{ +
"kind": "insert", +
"schema": "public", +
"table": "xpto", +
"columnnames": ["a", "b", "c", "d"], +
"columntypes": ["int4", "bool", "varchar", "float4"], +
"columnvalues": [4, true, "valid: ' \" \\ / \b \f \n \r \t ⁿ 陿 invalid: \\g \\k end", 123.456]+
} +
] +
}
(2 rows)
SELECT 'stop' FROM pg_drop_replication_slot('regression_slot');
?column?
----------
stop
(1 row)
|