diff options
Diffstat (limited to 'contrib/test_decoding')
-rw-r--r-- | contrib/test_decoding/Makefile | 2 | ||||
-rw-r--r-- | contrib/test_decoding/expected/ddl.out | 4 | ||||
-rw-r--r-- | contrib/test_decoding/expected/slot.out | 58 | ||||
-rw-r--r-- | contrib/test_decoding/sql/slot.sql | 20 |
4 files changed, 81 insertions, 3 deletions
diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index a6641f5040d..d2bc8b8350a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -39,7 +39,7 @@ submake-test_decoding: REGRESSCHECKS=ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill + spill slot regresscheck: | submake-regress submake-test_decoding temp-install $(MKDIR_P) regression_output diff --git a/contrib/test_decoding/expected/ddl.out b/contrib/test_decoding/expected/ddl.out index a9ba615b5bb..c104c4802d1 100644 --- a/contrib/test_decoding/expected/ddl.out +++ b/contrib/test_decoding/expected/ddl.out @@ -702,7 +702,7 @@ SELECT pg_drop_replication_slot('regression_slot'); /* check that the slot is gone */ SELECT * FROM pg_replication_slots; - slot_name | plugin | slot_type | datoid | database | active | active_pid | xmin | catalog_xmin | restart_lsn | confirmed_flush_lsn ------------+--------+-----------+--------+----------+--------+------------+------+--------------+-------------+--------------------- + slot_name | plugin | slot_type | datoid | database | temporary | active | active_pid | xmin | catalog_xmin | restart_lsn | confirmed_flush_lsn +-----------+--------+-----------+--------+----------+-----------+--------+------------+------+--------------+-------------+--------------------- (0 rows) diff --git a/contrib/test_decoding/expected/slot.out b/contrib/test_decoding/expected/slot.out new file mode 100644 index 00000000000..5e6b70ba38a --- /dev/null +++ b/contrib/test_decoding/expected/slot.out @@ -0,0 +1,58 @@ +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot_p', 'test_decoding'); + ?column? +---------- + init +(1 row) + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot_t', 'test_decoding', true); + ?column? +---------- + init +(1 row) + +SELECT pg_drop_replication_slot('regression_slot_p'); + pg_drop_replication_slot +-------------------------- + +(1 row) + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot_p', 'test_decoding', false); + ?column? +---------- + init +(1 row) + +-- reconnect to clean temp slots +\c +SELECT pg_drop_replication_slot('regression_slot_p'); + pg_drop_replication_slot +-------------------------- + +(1 row) + +-- should fail because the temporary slot was dropped automatically +SELECT pg_drop_replication_slot('regression_slot_t'); +ERROR: replication slot "regression_slot_t" does not exist +-- test switching between slots in a session +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot1', 'test_decoding', true); + ?column? +---------- + init +(1 row) + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot2', 'test_decoding', true); + ?column? +---------- + init +(1 row) + +SELECT * FROM pg_logical_slot_get_changes('regression_slot1', NULL, NULL); + location | xid | data +----------+-----+------ +(0 rows) + +SELECT * FROM pg_logical_slot_get_changes('regression_slot2', NULL, NULL); + location | xid | data +----------+-----+------ +(0 rows) + diff --git a/contrib/test_decoding/sql/slot.sql b/contrib/test_decoding/sql/slot.sql new file mode 100644 index 00000000000..3b0aecd6a88 --- /dev/null +++ b/contrib/test_decoding/sql/slot.sql @@ -0,0 +1,20 @@ +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot_p', 'test_decoding'); +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot_t', 'test_decoding', true); + +SELECT pg_drop_replication_slot('regression_slot_p'); +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot_p', 'test_decoding', false); + +-- reconnect to clean temp slots +\c + +SELECT pg_drop_replication_slot('regression_slot_p'); + +-- should fail because the temporary slot was dropped automatically +SELECT pg_drop_replication_slot('regression_slot_t'); + + +-- test switching between slots in a session +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot1', 'test_decoding', true); +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot2', 'test_decoding', true); +SELECT * FROM pg_logical_slot_get_changes('regression_slot1', NULL, NULL); +SELECT * FROM pg_logical_slot_get_changes('regression_slot2', NULL, NULL); |