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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
|
\set VERBOSITY terse
-- predictability
SET synchronous_commit = on;
SET extra_float_digits = 0;
CREATE DOMAIN "wal2json_DOMAIN_1" AS bigint;
CREATE DOMAIN wal2json_domain_2 AS numeric(5,3);
CREATE DOMAIN wal2json_domain_3 AS varchar(30);
CREATE DOMAIN "wal2json_DOMAIN_4" AS bit varying(20);
CREATE TYPE "wal2json_Type" AS ENUM('a', 'b', 'c');
CREATE TABLE test_wal2json_5 (
a smallserial,
b smallint,
c int,
d "wal2json_DOMAIN_1",
e wal2json_domain_2,
f real not null,
g double precision,
h char(10),
i wal2json_domain_3,
j text,
k "wal2json_DOMAIN_4",
l timestamp,
m date,
n boolean not null,
o json,
p tsvector,
PRIMARY KEY(b, c, d)
);
CREATE TABLE test_wal2json_6 (
a integer,
b "wal2json_Type"[],
PRIMARY KEY(a)
);
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json');
?column?
----------
init
(1 row)
INSERT INTO test_wal2json_5 (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector);
UPDATE test_wal2json_5 SET f = -f WHERE b = 1;
INSERT INTO test_wal2json_6 (a, b) VALUES(1, array['b', 'c']::"wal2json_Type"[]);
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-domain-data-type', '0', 'include-pk', '1');
data
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
{ +
"change": [ +
{ +
"kind": "insert", +
"schema": "public", +
"table": "test_wal2json_5", +
"columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], +
"columntypes": ["smallint", "smallint", "integer", "wal2json_DOMAIN_1", "wal2json_domain_2", "real", "double precision", "character(10)", "wal2json_domain_3", "text", "wal2json_DOMAIN_4", "timestamp without time zone", "date", "boolean", "json", "tsvector"],+
"columnvalues": [1, 1, 2, "3", "3.540", 876.563, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "Sat Nov 02 17:30:52 2013", "02-04-2013", true, "{ \"a\": 123 }", "'Old' 'Parr'"], +
"pk": { +
"pknames": ["b", "c", "d"], +
"pktypes": ["smallint", "integer", "wal2json_DOMAIN_1"] +
} +
} +
] +
}
{ +
"change": [ +
{ +
"kind": "update", +
"schema": "public", +
"table": "test_wal2json_5", +
"columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], +
"columntypes": ["smallint", "smallint", "integer", "wal2json_DOMAIN_1", "wal2json_domain_2", "real", "double precision", "character(10)", "wal2json_domain_3", "text", "wal2json_DOMAIN_4", "timestamp without time zone", "date", "boolean", "json", "tsvector"],+
"columnvalues": [1, 1, 2, "3", "3.540", -876.563, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "Sat Nov 02 17:30:52 2013", "02-04-2013", true, "{ \"a\": 123 }", "'Old' 'Parr'"], +
"pk": { +
"pknames": ["b", "c", "d"], +
"pktypes": ["smallint", "integer", "wal2json_DOMAIN_1"] +
}, +
"oldkeys": { +
"keynames": ["b", "c", "d"], +
"keytypes": ["smallint", "integer", "wal2json_DOMAIN_1"], +
"keyvalues": [1, 2, "3"] +
} +
} +
] +
}
{ +
"change": [ +
{ +
"kind": "insert", +
"schema": "public", +
"table": "test_wal2json_6", +
"columnnames": ["a", "b"], +
"columntypes": ["integer", "\"wal2json_Type\"[]"], +
"columnvalues": [1, "{b,c}"], +
"pk": { +
"pknames": ["a"], +
"pktypes": ["integer"] +
} +
} +
] +
}
(3 rows)
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-domain-data-type', '1', 'include-pk', '1');
data
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
{ +
"change": [ +
{ +
"kind": "insert", +
"schema": "public", +
"table": "test_wal2json_5", +
"columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], +
"columntypes": ["smallint", "smallint", "integer", "bigint", "numeric(5,3)", "real", "double precision", "character(10)", "character varying(30)", "text", "bit varying(20)", "timestamp without time zone", "date", "boolean", "json", "tsvector"],+
"columnvalues": [1, 1, 2, 3, 3.540, 876.563, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "Sat Nov 02 17:30:52 2013", "02-04-2013", true, "{ \"a\": 123 }", "'Old' 'Parr'"], +
"pk": { +
"pknames": ["b", "c", "d"], +
"pktypes": ["smallint", "integer", "bigint"] +
} +
} +
] +
}
{ +
"change": [ +
{ +
"kind": "update", +
"schema": "public", +
"table": "test_wal2json_5", +
"columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], +
"columntypes": ["smallint", "smallint", "integer", "bigint", "numeric(5,3)", "real", "double precision", "character(10)", "character varying(30)", "text", "bit varying(20)", "timestamp without time zone", "date", "boolean", "json", "tsvector"],+
"columnvalues": [1, 1, 2, 3, 3.540, -876.563, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "Sat Nov 02 17:30:52 2013", "02-04-2013", true, "{ \"a\": 123 }", "'Old' 'Parr'"], +
"pk": { +
"pknames": ["b", "c", "d"], +
"pktypes": ["smallint", "integer", "bigint"] +
}, +
"oldkeys": { +
"keynames": ["b", "c", "d"], +
"keytypes": ["smallint", "integer", "bigint"], +
"keyvalues": [1, 2, 3] +
} +
} +
] +
}
{ +
"change": [ +
{ +
"kind": "insert", +
"schema": "public", +
"table": "test_wal2json_6", +
"columnnames": ["a", "b"], +
"columntypes": ["integer", "\"wal2json_Type\"[]"], +
"columnvalues": [1, "{b,c}"], +
"pk": { +
"pknames": ["a"], +
"pktypes": ["integer"] +
} +
} +
] +
}
(3 rows)
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-domain-data-type', '0', 'include-typmod', '0');
data
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
{ +
"change": [ +
{ +
"kind": "insert", +
"schema": "public", +
"table": "test_wal2json_5", +
"columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], +
"columntypes": ["int2", "int2", "int4", "wal2json_DOMAIN_1", "wal2json_domain_2", "float4", "float8", "bpchar", "wal2json_domain_3", "text", "wal2json_DOMAIN_4", "timestamp", "date", "bool", "json", "tsvector"],+
"columnvalues": [1, 1, 2, "3", "3.540", 876.563, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "Sat Nov 02 17:30:52 2013", "02-04-2013", true, "{ \"a\": 123 }", "'Old' 'Parr'"] +
} +
] +
}
{ +
"change": [ +
{ +
"kind": "update", +
"schema": "public", +
"table": "test_wal2json_5", +
"columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], +
"columntypes": ["int2", "int2", "int4", "wal2json_DOMAIN_1", "wal2json_domain_2", "float4", "float8", "bpchar", "wal2json_domain_3", "text", "wal2json_DOMAIN_4", "timestamp", "date", "bool", "json", "tsvector"],+
"columnvalues": [1, 1, 2, "3", "3.540", -876.563, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "Sat Nov 02 17:30:52 2013", "02-04-2013", true, "{ \"a\": 123 }", "'Old' 'Parr'"], +
"oldkeys": { +
"keynames": ["b", "c", "d"], +
"keytypes": ["int2", "int4", "wal2json_DOMAIN_1"], +
"keyvalues": [1, 2, "3"] +
} +
} +
] +
}
{ +
"change": [ +
{ +
"kind": "insert", +
"schema": "public", +
"table": "test_wal2json_6", +
"columnnames": ["a", "b"], +
"columntypes": ["int4", "_wal2json_Type"], +
"columnvalues": [1, "{b,c}"] +
} +
] +
}
(3 rows)
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-domain-data-type', '1', 'include-typmod', '0');
data
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
{ +
"change": [ +
{ +
"kind": "insert", +
"schema": "public", +
"table": "test_wal2json_5", +
"columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], +
"columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "date", "bool", "json", "tsvector"], +
"columnvalues": [1, 1, 2, 3, 3.540, 876.563, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "Sat Nov 02 17:30:52 2013", "02-04-2013", true, "{ \"a\": 123 }", "'Old' 'Parr'"] +
} +
] +
}
{ +
"change": [ +
{ +
"kind": "update", +
"schema": "public", +
"table": "test_wal2json_5", +
"columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], +
"columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "date", "bool", "json", "tsvector"], +
"columnvalues": [1, 1, 2, 3, 3.540, -876.563, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "Sat Nov 02 17:30:52 2013", "02-04-2013", true, "{ \"a\": 123 }", "'Old' 'Parr'"],+
"oldkeys": { +
"keynames": ["b", "c", "d"], +
"keytypes": ["int2", "int4", "int8"], +
"keyvalues": [1, 2, 3] +
} +
} +
] +
}
{ +
"change": [ +
{ +
"kind": "insert", +
"schema": "public", +
"table": "test_wal2json_6", +
"columnnames": ["a", "b"], +
"columntypes": ["int4", "_wal2json_Type"], +
"columnvalues": [1, "{b,c}"] +
} +
] +
}
(3 rows)
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'include-domain-data-type', '0', 'include-pk', '1');
data
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
{"action":"B"}
{"action":"I","schema":"public","table":"test_wal2json_5","columns":[{"name":"a","type":"smallint","value":1},{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"wal2json_DOMAIN_1","value":"3"},{"name":"e","type":"wal2json_domain_2","value":"3.540"},{"name":"f","type":"real","value":876.563},{"name":"g","type":"double precision","value":1.23},{"name":"h","type":"character(10)","value":"teste "},{"name":"i","type":"wal2json_domain_3","value":"testando"},{"name":"j","type":"text","value":"um texto longo"},{"name":"k","type":"wal2json_DOMAIN_4","value":"001110010101010"},{"name":"l","type":"timestamp without time zone","value":"Sat Nov 02 17:30:52 2013"},{"name":"m","type":"date","value":"02-04-2013"},{"name":"n","type":"boolean","value":true},{"name":"o","type":"json","value":"{ \"a\": 123 }"},{"name":"p","type":"tsvector","value":"'Old' 'Parr'"}],"pk":[{"name":"b","type":"smallint"},{"name":"c","type":"integer"},{"name":"d","type":"wal2json_DOMAIN_1"}]}
{"action":"C"}
{"action":"B"}
{"action":"U","schema":"public","table":"test_wal2json_5","columns":[{"name":"a","type":"smallint","value":1},{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"wal2json_DOMAIN_1","value":"3"},{"name":"e","type":"wal2json_domain_2","value":"3.540"},{"name":"f","type":"real","value":-876.563},{"name":"g","type":"double precision","value":1.23},{"name":"h","type":"character(10)","value":"teste "},{"name":"i","type":"wal2json_domain_3","value":"testando"},{"name":"j","type":"text","value":"um texto longo"},{"name":"k","type":"wal2json_DOMAIN_4","value":"001110010101010"},{"name":"l","type":"timestamp without time zone","value":"Sat Nov 02 17:30:52 2013"},{"name":"m","type":"date","value":"02-04-2013"},{"name":"n","type":"boolean","value":true},{"name":"o","type":"json","value":"{ \"a\": 123 }"},{"name":"p","type":"tsvector","value":"'Old' 'Parr'"}],"identity":[{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"wal2json_DOMAIN_1","value":"3"}],"pk":[{"name":"b","type":"smallint"},{"name":"c","type":"integer"},{"name":"d","type":"wal2json_DOMAIN_1"}]}
{"action":"C"}
{"action":"B"}
{"action":"I","schema":"public","table":"test_wal2json_6","columns":[{"name":"a","type":"integer","value":1},{"name":"b","type":"\"wal2json_Type\"[]","value":"{b,c}"}],"pk":[{"name":"a","type":"integer"}]}
{"action":"C"}
(9 rows)
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '2', 'include-domain-data-type', '1', 'include-pk', '1');
data
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
{"action":"B"}
{"action":"I","schema":"public","table":"test_wal2json_5","columns":[{"name":"a","type":"smallint","value":1},{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"bigint","value":"3"},{"name":"e","type":"numeric(5,3)","value":"3.540"},{"name":"f","type":"real","value":876.563},{"name":"g","type":"double precision","value":1.23},{"name":"h","type":"character(10)","value":"teste "},{"name":"i","type":"character varying(30)","value":"testando"},{"name":"j","type":"text","value":"um texto longo"},{"name":"k","type":"bit varying(20)","value":"001110010101010"},{"name":"l","type":"timestamp without time zone","value":"Sat Nov 02 17:30:52 2013"},{"name":"m","type":"date","value":"02-04-2013"},{"name":"n","type":"boolean","value":true},{"name":"o","type":"json","value":"{ \"a\": 123 }"},{"name":"p","type":"tsvector","value":"'Old' 'Parr'"}],"pk":[{"name":"b","type":"smallint"},{"name":"c","type":"integer"},{"name":"d","type":"bigint"}]}
{"action":"C"}
{"action":"B"}
{"action":"U","schema":"public","table":"test_wal2json_5","columns":[{"name":"a","type":"smallint","value":1},{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"bigint","value":"3"},{"name":"e","type":"numeric(5,3)","value":"3.540"},{"name":"f","type":"real","value":-876.563},{"name":"g","type":"double precision","value":1.23},{"name":"h","type":"character(10)","value":"teste "},{"name":"i","type":"character varying(30)","value":"testando"},{"name":"j","type":"text","value":"um texto longo"},{"name":"k","type":"bit varying(20)","value":"001110010101010"},{"name":"l","type":"timestamp without time zone","value":"Sat Nov 02 17:30:52 2013"},{"name":"m","type":"date","value":"02-04-2013"},{"name":"n","type":"boolean","value":true},{"name":"o","type":"json","value":"{ \"a\": 123 }"},{"name":"p","type":"tsvector","value":"'Old' 'Parr'"}],"identity":[{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"bigint","value":"3"}],"pk":[{"name":"b","type":"smallint"},{"name":"c","type":"integer"},{"name":"d","type":"bigint"}]}
{"action":"C"}
{"action":"B"}
{"action":"I","schema":"public","table":"test_wal2json_6","columns":[{"name":"a","type":"integer","value":1},{"name":"b","type":"\"wal2json_Type\"[]","value":"{b,c}"}],"pk":[{"name":"a","type":"integer"}]}
{"action":"C"}
(9 rows)
SELECT 'stop' FROM pg_drop_replication_slot('regression_slot');
?column?
----------
stop
(1 row)
DROP TABLE test_wal2json_5;
DROP TABLE test_wal2json_6;
DROP DOMAIN "wal2json_DOMAIN_1";
DROP DOMAIN wal2json_domain_2;
DROP DOMAIN wal2json_domain_3;
DROP DOMAIN "wal2json_DOMAIN_4";
DROP TYPE "wal2json_Type";
|