Debian Codegraph @

contrib/test_decoding/expected/twophase_stream.out

raw
1 -- Test streaming of two-phase commits
2 SET synchronous_commit = on;
3 SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding', false, true);
4 ?column?
5 ----------
6 init
7 (1 row)
8
9 CREATE TABLE stream_test(data text);
10 -- consume DDL
11 SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
12 data
13 ------
14 (0 rows)
15
16 -- streaming test with sub-transaction and PREPARE/COMMIT PREPARED
17 BEGIN;
18 SAVEPOINT s1;
19 SELECT 'msg5' FROM pg_logical_emit_message(true, 'test', repeat('a', 50));
20 ?column?
21 ----------
22 msg5
23 (1 row)
24
25 INSERT INTO stream_test SELECT repeat('a', 2000) || g.i FROM generate_series(1, 35) g(i);
26 TRUNCATE table stream_test;
27 ROLLBACK TO s1;
28 INSERT INTO stream_test SELECT repeat('a', 10) || g.i FROM generate_series(1, 20) g(i);
29 PREPARE TRANSACTION 'test1';
30 -- should show the inserts after a ROLLBACK
31 SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL,NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1');
32 data
33 ----------------------------------------------------------
34 opening a streamed block for transaction
35 streaming message: transactional: 1 prefix: test, sz: 50
36 closing a streamed block for transaction
37 aborting streamed (sub)transaction
38 opening a streamed block 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 streaming change for transaction
58 streaming change for transaction
59 closing a streamed block for transaction
60 preparing streamed transaction 'test1'
61 (27 rows)
62
63 COMMIT PREPARED 'test1';
64 --should show the COMMIT PREPARED and the other changes in the transaction
65 SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL,NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1');
66 data
67 -------------------------
68 COMMIT PREPARED 'test1'
69 (1 row)
70
71 -- streaming test with sub-transaction and PREPARE/COMMIT PREPARED but with
72 -- filtered gid. gids with '_nodecode' will not be decoded at prepare time.
73 BEGIN;
74 SAVEPOINT s1;
75 SELECT 'msg5' FROM pg_logical_emit_message(true, 'test', repeat('a', 50));
76 ?column?
77 ----------
78 msg5
79 (1 row)
80
81 INSERT INTO stream_test SELECT repeat('a', 2000) || g.i FROM generate_series(1, 35) g(i);
82 TRUNCATE table stream_test;
83 ROLLBACK to s1;
84 INSERT INTO stream_test SELECT repeat('a', 10) || g.i FROM generate_series(1, 20) g(i);
85 PREPARE TRANSACTION 'test1_nodecode';
86 -- should NOT show inserts after a ROLLBACK
87 SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL,NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1');
88 data
89 ----------------------------------------------------------
90 opening a streamed block for transaction
91 streaming message: transactional: 1 prefix: test, sz: 50
92 closing a streamed block for transaction
93 aborting streamed (sub)transaction
94 (4 rows)
95
96 COMMIT PREPARED 'test1_nodecode';
97 -- should show the inserts but not show a COMMIT PREPARED but a COMMIT
98 SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL,NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1');
99 data
100 -------------------------------------------------------------
101 BEGIN
102 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa1'
103 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa2'
104 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa3'
105 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa4'
106 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa5'
107 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa6'
108 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa7'
109 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa8'
110 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa9'
111 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa10'
112 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa11'
113 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa12'
114 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa13'
115 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa14'
116 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa15'
117 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa16'
118 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa17'
119 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa18'
120 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa19'
121 table public.stream_test: INSERT: data[text]:'aaaaaaaaaa20'
122 COMMIT
123 (22 rows)
124
125 DROP TABLE stream_test;
126 SELECT pg_drop_replication_slot('regression_slot');
127 pg_drop_replication_slot
128 --------------------------
129
130 (1 row)
131