| 1 |
-- predictability |
| 2 |
SET synchronous_commit = on; |
| 3 |
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding'); |
| 4 |
?column? |
| 5 |
---------- |
| 6 |
init |
| 7 |
(1 row) |
| 8 |
|
| 9 |
-- These two cover the path for the flush variant. |
| 10 |
SELECT 'msg1' FROM pg_logical_emit_message(true, 'test', 'msg1', true); |
| 11 |
?column? |
| 12 |
---------- |
| 13 |
msg1 |
| 14 |
(1 row) |
| 15 |
|
| 16 |
SELECT 'msg2' FROM pg_logical_emit_message(false, 'test', 'msg2', true); |
| 17 |
?column? |
| 18 |
---------- |
| 19 |
msg2 |
| 20 |
(1 row) |
| 21 |
|
| 22 |
BEGIN; |
| 23 |
SELECT 'msg3' FROM pg_logical_emit_message(true, 'test', 'msg3'); |
| 24 |
?column? |
| 25 |
---------- |
| 26 |
msg3 |
| 27 |
(1 row) |
| 28 |
|
| 29 |
SELECT 'msg4' FROM pg_logical_emit_message(false, 'test', 'msg4'); |
| 30 |
?column? |
| 31 |
---------- |
| 32 |
msg4 |
| 33 |
(1 row) |
| 34 |
|
| 35 |
ROLLBACK; |
| 36 |
BEGIN; |
| 37 |
SELECT 'msg5' FROM pg_logical_emit_message(true, 'test', 'msg5'); |
| 38 |
?column? |
| 39 |
---------- |
| 40 |
msg5 |
| 41 |
(1 row) |
| 42 |
|
| 43 |
SELECT 'msg6' FROM pg_logical_emit_message(false, 'test', 'msg6'); |
| 44 |
?column? |
| 45 |
---------- |
| 46 |
msg6 |
| 47 |
(1 row) |
| 48 |
|
| 49 |
SELECT 'msg7' FROM pg_logical_emit_message(true, 'test', 'msg7'); |
| 50 |
?column? |
| 51 |
---------- |
| 52 |
msg7 |
| 53 |
(1 row) |
| 54 |
|
| 55 |
COMMIT; |
| 56 |
SELECT 'ignorethis' FROM pg_logical_emit_message(true, 'test', 'czechtastic'); |
| 57 |
?column? |
| 58 |
------------ |
| 59 |
ignorethis |
| 60 |
(1 row) |
| 61 |
|
| 62 |
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'force-binary', '0', 'skip-empty-xacts', '1', 'include-xids', '0'); |
| 63 |
data |
| 64 |
-------------------------------------------------------------------- |
| 65 |
BEGIN |
| 66 |
message: transactional: 1 prefix: test, sz: 4 content:msg1 |
| 67 |
COMMIT |
| 68 |
message: transactional: 0 prefix: test, sz: 4 content:msg2 |
| 69 |
message: transactional: 0 prefix: test, sz: 4 content:msg4 |
| 70 |
message: transactional: 0 prefix: test, sz: 4 content:msg6 |
| 71 |
BEGIN |
| 72 |
message: transactional: 1 prefix: test, sz: 4 content:msg5 |
| 73 |
message: transactional: 1 prefix: test, sz: 4 content:msg7 |
| 74 |
COMMIT |
| 75 |
BEGIN |
| 76 |
message: transactional: 1 prefix: test, sz: 11 content:czechtastic |
| 77 |
COMMIT |
| 78 |
(13 rows) |
| 79 |
|
| 80 |
-- test db filtering |
| 81 |
\set prevdb :DBNAME |
| 82 |
\c template1 |
| 83 |
SELECT 'otherdb1' FROM pg_logical_emit_message(false, 'test', 'otherdb1'); |
| 84 |
?column? |
| 85 |
---------- |
| 86 |
otherdb1 |
| 87 |
(1 row) |
| 88 |
|
| 89 |
SELECT 'otherdb2' FROM pg_logical_emit_message(true, 'test', 'otherdb2'); |
| 90 |
?column? |
| 91 |
---------- |
| 92 |
otherdb2 |
| 93 |
(1 row) |
| 94 |
|
| 95 |
\c :prevdb |
| 96 |
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'force-binary', '0', 'skip-empty-xacts', '1'); |
| 97 |
data |
| 98 |
------ |
| 99 |
(0 rows) |
| 100 |
|
| 101 |
SELECT 'cleanup' FROM pg_drop_replication_slot('regression_slot'); |
| 102 |
?column? |
| 103 |
---------- |
| 104 |
cleanup |
| 105 |
(1 row) |
| 106 |
|