Skip to content

Instantly share code, notes, and snippets.

@CHERTS
Created July 25, 2024 13:29
Show Gist options
  • Save CHERTS/f9c7c88d5abaaf85300fd9776fcb3b00 to your computer and use it in GitHub Desktop.
Save CHERTS/f9c7c88d5abaaf85300fd9776fcb3b00 to your computer and use it in GitHub Desktop.
Checking capturing data change use logical slot
-- Create slot
SELECT pg_create_logical_replication_slot('test_slot_v1', 'pgoutput');
-- Show publication name
SELECT pubname FROM pg_publication_tables GROUP BY pubname;
-- Peak changes (does not consume changes)
SELECT pg_logical_slot_peek_binary_changes('test_slot_v1', NULL, NULL, 'publication_names', 'dbz_publication', 'proto_version', '1');
-- Get changes (consumes changes)
SELECT pg_logical_slot_get_binary_changes('test_slot_v1', NULL, NULL, 'publication_names', 'dbz_publication', 'proto_version', '1');
-- Drop slot
SELECT pg_drop_replication_slot ('test_slot_v1');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment