File: pk.out

package info (click to toggle)
wal2json 2.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,672 kB
  • sloc: ansic: 2,524; sql: 1,136; makefile: 27; sh: 6
file content (209 lines) | stat: -rw-r--r-- 18,847 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
\set VERBOSITY terse
-- predictability
SET synchronous_commit = on;
SET extra_float_digits = 0;
CREATE TABLE w2j_pk_with_pk (
a	int,
b	timestamp,
c	text,
d	boolean,
e	numeric(5,3),
PRIMARY KEY(b, d, e)
);
CREATE TABLE w2j_pk_without_pk (
a	int,
b	timestamp,
c	text,
d	boolean,
e	numeric(5,3)
);
CREATE TABLE w2j_pk_with_ri (
a	int NOT NULL,
b	timestamp,
c	text,
d	boolean,
e	numeric(5,3),
UNIQUE(a)
);
ALTER TABLE w2j_pk_with_ri REPLICA IDENTITY USING INDEX w2j_pk_with_ri_a_key;
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json');
 ?column? 
----------
 init
(1 row)

INSERT INTO w2j_pk_with_pk (a, b, c, d, e) VALUES(123, '2020-04-26 16:23:59', 'Melanosuchus Niger', true, 4.56);
UPDATE w2j_pk_with_pk SET a = 456, c = 'Panthera Onca', d = false;
DELETE FROM w2j_pk_with_pk;
INSERT INTO w2j_pk_without_pk (a, b, c, d, e) VALUES(123, '2020-04-26 16:23:59', 'Melanosuchus Niger', true, 4.56);
UPDATE w2j_pk_without_pk SET a = 456, c = 'Panthera Onca', d = false;
DELETE FROM w2j_pk_without_pk;
INSERT INTO w2j_pk_with_ri (a, b, c, d, e) VALUES(123, '2020-04-26 16:23:59', 'Inia Araguaiaensis', true, 4.56);
UPDATE w2j_pk_with_ri SET a = 456, c = 'Panthera Onca', d = false;
DELETE FROM w2j_pk_with_ri;
SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0', 'include-pk', '1');
WARNING:  table "w2j_pk_without_pk" without primary key or replica identity is nothing
WARNING:  table "w2j_pk_without_pk" without primary key or replica identity is nothing
                                                     data                                                      
---------------------------------------------------------------------------------------------------------------
 {                                                                                                            +
         "change": [                                                                                          +
                 {                                                                                            +
                         "kind": "insert",                                                                    +
                         "schema": "public",                                                                  +
                         "table": "w2j_pk_with_pk",                                                           +
                         "columnnames": ["a", "b", "c", "d", "e"],                                            +
                         "columntypes": ["int4", "timestamp", "text", "bool", "numeric"],                     +
                         "columnvalues": [123, "Sun Apr 26 16:23:59 2020", "Melanosuchus Niger", true, 4.560],+
                         "pk": {                                                                              +
                                 "pknames": ["b", "d", "e"],                                                  +
                                 "pktypes": ["timestamp", "bool", "numeric"]                                  +
                         }                                                                                    +
                 }                                                                                            +
         ]                                                                                                    +
 }
 {                                                                                                            +
         "change": [                                                                                          +
                 {                                                                                            +
                         "kind": "update",                                                                    +
                         "schema": "public",                                                                  +
                         "table": "w2j_pk_with_pk",                                                           +
                         "columnnames": ["a", "b", "c", "d", "e"],                                            +
                         "columntypes": ["int4", "timestamp", "text", "bool", "numeric"],                     +
                         "columnvalues": [456, "Sun Apr 26 16:23:59 2020", "Panthera Onca", false, 4.560],    +
                         "pk": {                                                                              +
                                 "pknames": ["b", "d", "e"],                                                  +
                                 "pktypes": ["timestamp", "bool", "numeric"]                                  +
                         },                                                                                   +
                         "oldkeys": {                                                                         +
                                 "keynames": ["b", "d", "e"],                                                 +
                                 "keytypes": ["timestamp", "bool", "numeric"],                                +
                                 "keyvalues": ["Sun Apr 26 16:23:59 2020", true, 4.560]                       +
                         }                                                                                    +
                 }                                                                                            +
         ]                                                                                                    +
 }
 {                                                                                                            +
         "change": [                                                                                          +
                 {                                                                                            +
                         "kind": "delete",                                                                    +
                         "schema": "public",                                                                  +
                         "table": "w2j_pk_with_pk",                                                           +
                         "pk": {                                                                              +
                                 "pknames": ["b", "d", "e"],                                                  +
                                 "pktypes": ["timestamp", "bool", "numeric"]                                  +
                         },                                                                                   +
                         "oldkeys": {                                                                         +
                                 "keynames": ["b", "d", "e"],                                                 +
                                 "keytypes": ["timestamp", "bool", "numeric"],                                +
                                 "keyvalues": ["Sun Apr 26 16:23:59 2020", false, 4.560]                      +
                         }                                                                                    +
                 }                                                                                            +
         ]                                                                                                    +
 }
 {                                                                                                            +
         "change": [                                                                                          +
                 {                                                                                            +
                         "kind": "insert",                                                                    +
                         "schema": "public",                                                                  +
                         "table": "w2j_pk_without_pk",                                                        +
                         "columnnames": ["a", "b", "c", "d", "e"],                                            +
                         "columntypes": ["int4", "timestamp", "text", "bool", "numeric"],                     +
                         "columnvalues": [123, "Sun Apr 26 16:23:59 2020", "Melanosuchus Niger", true, 4.560] +
                 }                                                                                            +
         ]                                                                                                    +
 }
 {                                                                                                            +
         "change": [                                                                                          +
         ]                                                                                                    +
 }
 {                                                                                                            +
         "change": [                                                                                          +
         ]                                                                                                    +
 }
 {                                                                                                            +
         "change": [                                                                                          +
                 {                                                                                            +
                         "kind": "insert",                                                                    +
                         "schema": "public",                                                                  +
                         "table": "w2j_pk_with_ri",                                                           +
                         "columnnames": ["a", "b", "c", "d", "e"],                                            +
                         "columntypes": ["int4", "timestamp", "text", "bool", "numeric"],                     +
                         "columnvalues": [123, "Sun Apr 26 16:23:59 2020", "Inia Araguaiaensis", true, 4.560] +
                 }                                                                                            +
         ]                                                                                                    +
 }
 {                                                                                                            +
         "change": [                                                                                          +
                 {                                                                                            +
                         "kind": "update",                                                                    +
                         "schema": "public",                                                                  +
                         "table": "w2j_pk_with_ri",                                                           +
                         "columnnames": ["a", "b", "c", "d", "e"],                                            +
                         "columntypes": ["int4", "timestamp", "text", "bool", "numeric"],                     +
                         "columnvalues": [456, "Sun Apr 26 16:23:59 2020", "Panthera Onca", false, 4.560],    +
                         "oldkeys": {                                                                         +
                                 "keynames": ["a"],                                                           +
                                 "keytypes": ["int4"],                                                        +
                                 "keyvalues": [123]                                                           +
                         }                                                                                    +
                 }                                                                                            +
         ]                                                                                                    +
 }
 {                                                                                                            +
         "change": [                                                                                          +
                 {                                                                                            +
                         "kind": "delete",                                                                    +
                         "schema": "public",                                                                  +
                         "table": "w2j_pk_with_ri",                                                           +
                         "oldkeys": {                                                                         +
                                 "keynames": ["a"],                                                           +
                                 "keytypes": ["int4"],                                                        +
                                 "keyvalues": [456]                                                           +
                         }                                                                                    +
                 }                                                                                            +
         ]                                                                                                    +
 }
(9 rows)

SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'include-pk', '1');
WARNING:  no tuple identifier for UPDATE in table "public"."w2j_pk_without_pk"
WARNING:  no tuple identifier for DELETE in table "public"."w2j_pk_without_pk"
                                                                                                                                                                                                                                                                                                                                     data                                                                                                                                                                                                                                                                                                                                     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 {"action":"B"}
 {"action":"I","schema":"public","table":"w2j_pk_with_pk","columns":[{"name":"a","type":"integer","value":123},{"name":"b","type":"timestamp without time zone","value":"Sun Apr 26 16:23:59 2020"},{"name":"c","type":"text","value":"Melanosuchus Niger"},{"name":"d","type":"boolean","value":true},{"name":"e","type":"numeric(5,3)","value":4.560}],"pk":[{"name":"b","type":"timestamp without time zone"},{"name":"d","type":"boolean"},{"name":"e","type":"numeric(5,3)"}]}
 {"action":"C"}
 {"action":"B"}
 {"action":"U","schema":"public","table":"w2j_pk_with_pk","columns":[{"name":"a","type":"integer","value":456},{"name":"b","type":"timestamp without time zone","value":"Sun Apr 26 16:23:59 2020"},{"name":"c","type":"text","value":"Panthera Onca"},{"name":"d","type":"boolean","value":false},{"name":"e","type":"numeric(5,3)","value":4.560}],"identity":[{"name":"b","type":"timestamp without time zone","value":"Sun Apr 26 16:23:59 2020"},{"name":"d","type":"boolean","value":true},{"name":"e","type":"numeric(5,3)","value":4.560}],"pk":[{"name":"b","type":"timestamp without time zone"},{"name":"d","type":"boolean"},{"name":"e","type":"numeric(5,3)"}]}
 {"action":"C"}
 {"action":"B"}
 {"action":"D","schema":"public","table":"w2j_pk_with_pk","identity":[{"name":"b","type":"timestamp without time zone","value":"Sun Apr 26 16:23:59 2020"},{"name":"d","type":"boolean","value":false},{"name":"e","type":"numeric(5,3)","value":4.560}],"pk":[{"name":"b","type":"timestamp without time zone"},{"name":"d","type":"boolean"},{"name":"e","type":"numeric(5,3)"}]}
 {"action":"C"}
 {"action":"B"}
 {"action":"I","schema":"public","table":"w2j_pk_without_pk","columns":[{"name":"a","type":"integer","value":123},{"name":"b","type":"timestamp without time zone","value":"Sun Apr 26 16:23:59 2020"},{"name":"c","type":"text","value":"Melanosuchus Niger"},{"name":"d","type":"boolean","value":true},{"name":"e","type":"numeric(5,3)","value":4.560}],"pk":[]}
 {"action":"C"}
 {"action":"B"}
 {"action":"C"}
 {"action":"B"}
 {"action":"C"}
 {"action":"B"}
 {"action":"I","schema":"public","table":"w2j_pk_with_ri","columns":[{"name":"a","type":"integer","value":123},{"name":"b","type":"timestamp without time zone","value":"Sun Apr 26 16:23:59 2020"},{"name":"c","type":"text","value":"Inia Araguaiaensis"},{"name":"d","type":"boolean","value":true},{"name":"e","type":"numeric(5,3)","value":4.560}],"pk":[]}
 {"action":"C"}
 {"action":"B"}
 {"action":"U","schema":"public","table":"w2j_pk_with_ri","columns":[{"name":"a","type":"integer","value":456},{"name":"b","type":"timestamp without time zone","value":"Sun Apr 26 16:23:59 2020"},{"name":"c","type":"text","value":"Panthera Onca"},{"name":"d","type":"boolean","value":false},{"name":"e","type":"numeric(5,3)","value":4.560}],"identity":[{"name":"a","type":"integer","value":123}],"pk":[]}
 {"action":"C"}
 {"action":"B"}
 {"action":"D","schema":"public","table":"w2j_pk_with_ri","identity":[{"name":"a","type":"integer","value":456}],"pk":[]}
 {"action":"C"}
(25 rows)

SELECT 'stop' FROM pg_drop_replication_slot('regression_slot');
 ?column? 
----------
 stop
(1 row)

DROP TABLE w2j_pk_with_pk;
DROP TABLE w2j_pk_without_pk;
DROP TABLE w2j_pk_with_ri;