|
| 1 | +SET synchronous_commit = on; |
| 2 | +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding'); |
| 3 | + ?column? |
| 4 | +---------- |
| 5 | + init |
| 6 | +(1 row) |
| 7 | + |
| 8 | +CREATE TABLE stream_test(data text); |
| 9 | +-- consume DDL |
| 10 | +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1'); |
| 11 | + data |
| 12 | +------ |
| 13 | +(0 rows) |
| 14 | + |
| 15 | +-- streaming test with sub-transaction |
| 16 | +BEGIN; |
| 17 | +savepoint s1; |
| 18 | +SELECT 'msg5' FROM pg_logical_emit_message(true, 'test', repeat('a', 50)); |
| 19 | + ?column? |
| 20 | +---------- |
| 21 | + msg5 |
| 22 | +(1 row) |
| 23 | + |
| 24 | +INSERT INTO stream_test SELECT repeat('a', 2000) || g.i FROM generate_series(1, 35) g(i); |
| 25 | +TRUNCATE table stream_test; |
| 26 | +rollback to s1; |
| 27 | +INSERT INTO stream_test SELECT repeat('a', 10) || g.i FROM generate_series(1, 20) g(i); |
| 28 | +COMMIT; |
| 29 | +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL,NULL, 'include-xids', '0', 'stream-changes', '1'); |
| 30 | + data |
| 31 | +---------------------------------------------------------- |
| 32 | + opening a streamed block for transaction |
| 33 | + streaming message: transactional: 1 prefix: test, sz: 50 |
| 34 | + closing a streamed block for transaction |
| 35 | + aborting streamed (sub)transaction |
| 36 | + opening a streamed block for transaction |
| 37 | + streaming change for transaction |
| 38 | + streaming change for transaction |
| 39 | + streaming change for transaction |
| 40 | + streaming change for transaction |
| 41 | + streaming change for transaction |
| 42 | + streaming change for transaction |
| 43 | + streaming change for transaction |
| 44 | + streaming change for transaction |
| 45 | + streaming change for transaction |
| 46 | + streaming change for transaction |
| 47 | + streaming change for transaction |
| 48 | + streaming change for transaction |
| 49 | + streaming change for transaction |
| 50 | + streaming change for transaction |
| 51 | + streaming change for transaction |
| 52 | + streaming change for transaction |
| 53 | + streaming change for transaction |
| 54 | + streaming change for transaction |
| 55 | + streaming change for transaction |
| 56 | + streaming change for transaction |
| 57 | + closing a streamed block for transaction |
| 58 | + committing streamed transaction |
| 59 | +(27 rows) |
| 60 | + |
| 61 | +-- streaming test for toast changes |
| 62 | +ALTER TABLE stream_test ALTER COLUMN data set storage external; |
| 63 | +-- consume DDL |
| 64 | +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1'); |
| 65 | + data |
| 66 | +------ |
| 67 | +(0 rows) |
| 68 | + |
| 69 | +INSERT INTO stream_test SELECT repeat('a', 6000) || g.i FROM generate_series(1, 10) g(i); |
| 70 | +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL,NULL, 'include-xids', '0', 'stream-changes', '1'); |
| 71 | + data |
| 72 | +------------------------------------------ |
| 73 | + opening a streamed block for transaction |
| 74 | + streaming change for transaction |
| 75 | + streaming change for transaction |
| 76 | + streaming change for transaction |
| 77 | + streaming change for transaction |
| 78 | + streaming change for transaction |
| 79 | + streaming change for transaction |
| 80 | + streaming change for transaction |
| 81 | + streaming change for transaction |
| 82 | + streaming change for transaction |
| 83 | + streaming change for transaction |
| 84 | + closing a streamed block for transaction |
| 85 | + committing streamed transaction |
| 86 | +(13 rows) |
| 87 | + |
| 88 | +DROP TABLE stream_test; |
| 89 | +SELECT pg_drop_replication_slot('regression_slot'); |
| 90 | + pg_drop_replication_slot |
| 91 | +-------------------------- |
| 92 | + |
| 93 | +(1 row) |
| 94 | + |
0 commit comments