aboutsummaryrefslogtreecommitdiff
path: root/contrib/test_decoding/sql
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2016-12-08 12:00:00 -0500
committerPeter Eisentraut <peter_e@gmx.net>2016-12-12 08:38:17 -0500
commita924c327e2793d2025b19e18de7917110dc8afd8 (patch)
tree2a81b0fd87cf4efb98a9a05aa3c27e8c8767bba3 /contrib/test_decoding/sql
parente7f051b8f9a6341f6d3bf80b29c1dbc1837be9ab (diff)
downloadpostgresql-a924c327e2793d2025b19e18de7917110dc8afd8.tar.gz
postgresql-a924c327e2793d2025b19e18de7917110dc8afd8.zip
Add support for temporary replication slots
This allows creating temporary replication slots that are removed automatically at the end of the session or on error. From: Petr Jelinek <petr.jelinek@2ndquadrant.com>
Diffstat (limited to 'contrib/test_decoding/sql')
-rw-r--r--contrib/test_decoding/sql/slot.sql20
1 files changed, 20 insertions, 0 deletions
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);