-- predictability
|
SET synchronous_commit = on;
|
CREATE TABLE replication_example(id SERIAL PRIMARY KEY, somedata int, text varchar(120));
|
SELECT 'init' FROM pg_create_logical_replication_slot('dbcopies_slot', 'dbcopies_decoding');
|
?column?
|
----------
|
init
|
(1 row)
|
|
BEGIN;
|
INSERT INTO replication_example(somedata, text) VALUES (1, 1);
|
INSERT INTO replication_example(somedata, text) VALUES (1, 2);
|
COMMIT;
|
SELECT data FROM pg_logical_slot_get_changes('dbcopies_slot', NULL, NULL, 'include-xids', '0');
|
data
|
-------------------------------
|
B
|
I replication_example 1 1 '1'
|
I replication_example 2 1 '2'
|
C
|
(4 rows)
|
|
SELECT pg_drop_replication_slot('dbcopies_slot');
|
pg_drop_replication_slot
|
--------------------------
|
|
(1 row)
|