Introduce logical decoding.
This feature, building on previous commits, allows the write-ahead log
stream to be decoded into a series of logical changes; that is,
inserts, updates, and deletes and the transactions which contain them.
It is capable of handling decoding even across changes to the schema
of the effected tables. The output format is controlled by a
so-called "output plugin"; an example is included. To make use of
this in a real replication system, the output plugin will need to be
modified to produce output in the format appropriate to that system,
and to perform filtering.
Currently, information can be extracted from the logical decoding
system only via SQL; future commits will add the ability to stream
changes via walsender.
Andres Freund, with review and other contributions from many other
people, including Álvaro Herrera, Abhijit Menon-Sen, Peter Gheogegan,
Kevin Grittner, Robert Haas, Heikki Linnakangas, Fujii Masao, Abhijit
Menon-Sen, Michael Paquier, Simon Riggs, Craig Ringer, and Steve
Singer.
2014-03-03 22:32:18 +01:00
|
|
|
-- predictability
|
|
|
|
SET synchronous_commit = on;
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS xpto;
|
|
|
|
|
|
|
|
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
|
|
|
|
|
|
|
|
CREATE SEQUENCE xpto_rand_seq START 79 INCREMENT 1499; -- portable "random"
|
|
|
|
CREATE TABLE xpto (
|
|
|
|
id serial primary key,
|
|
|
|
toasted_col1 text,
|
|
|
|
rand1 float8 DEFAULT nextval('xpto_rand_seq'),
|
|
|
|
toasted_col2 text,
|
|
|
|
rand2 float8 DEFAULT nextval('xpto_rand_seq')
|
|
|
|
);
|
|
|
|
|
|
|
|
-- uncompressed external toast data
|
|
|
|
INSERT INTO xpto (toasted_col1, toasted_col2) SELECT string_agg(g.i::text, ''), string_agg((g.i*2)::text, '') FROM generate_series(1, 2000) g(i);
|
|
|
|
|
|
|
|
-- compressed external toast data
|
|
|
|
INSERT INTO xpto (toasted_col2) SELECT repeat(string_agg(to_char(g.i, 'FM0000'), ''), 50) FROM generate_series(1, 500) g(i);
|
|
|
|
|
|
|
|
-- update of existing column
|
|
|
|
UPDATE xpto SET toasted_col1 = (SELECT string_agg(g.i::text, '') FROM generate_series(1, 2000) g(i)) WHERE id = 1;
|
|
|
|
|
|
|
|
UPDATE xpto SET rand1 = 123.456 WHERE id = 1;
|
|
|
|
|
Add support for INSERT ... ON CONFLICT DO NOTHING/UPDATE.
The newly added ON CONFLICT clause allows to specify an alternative to
raising a unique or exclusion constraint violation error when inserting.
ON CONFLICT refers to constraints that can either be specified using a
inference clause (by specifying the columns of a unique constraint) or
by naming a unique or exclusion constraint. DO NOTHING avoids the
constraint violation, without touching the pre-existing row. DO UPDATE
SET ... [WHERE ...] updates the pre-existing tuple, and has access to
both the tuple proposed for insertion and the existing tuple; the
optional WHERE clause can be used to prevent an update from being
executed. The UPDATE SET and WHERE clauses have access to the tuple
proposed for insertion using the "magic" EXCLUDED alias, and to the
pre-existing tuple using the table name or its alias.
This feature is often referred to as upsert.
This is implemented using a new infrastructure called "speculative
insertion". It is an optimistic variant of regular insertion that first
does a pre-check for existing tuples and then attempts an insert. If a
violating tuple was inserted concurrently, the speculatively inserted
tuple is deleted and a new attempt is made. If the pre-check finds a
matching tuple the alternative DO NOTHING or DO UPDATE action is taken.
If the insertion succeeds without detecting a conflict, the tuple is
deemed inserted.
To handle the possible ambiguity between the excluded alias and a table
named excluded, and for convenience with long relation names, INSERT
INTO now can alias its target table.
Bumps catversion as stored rules change.
Author: Peter Geoghegan, with significant contributions from Heikki
Linnakangas and Andres Freund. Testing infrastructure by Jeff Janes.
Reviewed-By: Heikki Linnakangas, Andres Freund, Robert Haas, Simon Riggs,
Dean Rasheed, Stephen Frost and many others.
2015-05-08 05:31:36 +02:00
|
|
|
-- updating external via INSERT ... ON CONFLICT DO UPDATE
|
|
|
|
INSERT INTO xpto(id, toasted_col2) VALUES (2, 'toasted2-upsert')
|
|
|
|
ON CONFLICT (id)
|
|
|
|
DO UPDATE SET toasted_col2 = EXCLUDED.toasted_col2 || xpto.toasted_col2;
|
|
|
|
|
Introduce logical decoding.
This feature, building on previous commits, allows the write-ahead log
stream to be decoded into a series of logical changes; that is,
inserts, updates, and deletes and the transactions which contain them.
It is capable of handling decoding even across changes to the schema
of the effected tables. The output format is controlled by a
so-called "output plugin"; an example is included. To make use of
this in a real replication system, the output plugin will need to be
modified to produce output in the format appropriate to that system,
and to perform filtering.
Currently, information can be extracted from the logical decoding
system only via SQL; future commits will add the ability to stream
changes via walsender.
Andres Freund, with review and other contributions from many other
people, including Álvaro Herrera, Abhijit Menon-Sen, Peter Gheogegan,
Kevin Grittner, Robert Haas, Heikki Linnakangas, Fujii Masao, Abhijit
Menon-Sen, Michael Paquier, Simon Riggs, Craig Ringer, and Steve
Singer.
2014-03-03 22:32:18 +01:00
|
|
|
DELETE FROM xpto WHERE id = 1;
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS toasted_key;
|
|
|
|
CREATE TABLE toasted_key (
|
|
|
|
id serial,
|
|
|
|
toasted_key text PRIMARY KEY,
|
|
|
|
toasted_col1 text,
|
|
|
|
toasted_col2 text
|
|
|
|
);
|
|
|
|
|
|
|
|
ALTER TABLE toasted_key ALTER COLUMN toasted_key SET STORAGE EXTERNAL;
|
|
|
|
ALTER TABLE toasted_key ALTER COLUMN toasted_col1 SET STORAGE EXTERNAL;
|
|
|
|
|
|
|
|
INSERT INTO toasted_key(toasted_key, toasted_col1) VALUES(repeat('1234567890', 200), repeat('9876543210', 200));
|
|
|
|
|
|
|
|
-- test update of a toasted key without changing it
|
|
|
|
UPDATE toasted_key SET toasted_col2 = toasted_col1;
|
|
|
|
-- test update of a toasted key, changing it
|
|
|
|
UPDATE toasted_key SET toasted_key = toasted_key || '1';
|
|
|
|
|
|
|
|
DELETE FROM toasted_key;
|
|
|
|
|
2014-07-06 15:58:01 +02:00
|
|
|
-- Test that HEAP2_MULTI_INSERT insertions with and without toasted
|
|
|
|
-- columns are handled correctly
|
|
|
|
CREATE TABLE toasted_copy (
|
|
|
|
id int primary key, -- no default, copy didn't use to handle that with multi inserts
|
|
|
|
data text
|
|
|
|
);
|
|
|
|
ALTER TABLE toasted_copy ALTER COLUMN data SET STORAGE EXTERNAL;
|
|
|
|
\copy toasted_copy FROM STDIN
|
|
|
|
1 untoasted1
|
|
|
|
2 toasted1-12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
|
|
|
|
3 untoasted2
|
|
|
|
4 toasted2-12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
|
2014-07-12 14:28:19 +02:00
|
|
|
5 untoasted3
|
|
|
|
6 untoasted4
|
|
|
|
7 untoasted5
|
|
|
|
8 untoasted6
|
|
|
|
9 untoasted7
|
|
|
|
10 untoasted8
|
|
|
|
11 untoasted9
|
|
|
|
12 untoasted10
|
|
|
|
13 untoasted11
|
|
|
|
14 untoasted12
|
|
|
|
15 untoasted13
|
|
|
|
16 untoasted14
|
|
|
|
17 untoasted15
|
|
|
|
18 untoasted16
|
|
|
|
19 untoasted17
|
|
|
|
20 untoasted18
|
|
|
|
21 untoasted19
|
|
|
|
22 untoasted20
|
|
|
|
23 untoasted21
|
|
|
|
24 untoasted22
|
|
|
|
25 untoasted23
|
|
|
|
26 untoasted24
|
|
|
|
27 untoasted25
|
|
|
|
28 untoasted26
|
|
|
|
29 untoasted27
|
|
|
|
30 untoasted28
|
|
|
|
31 untoasted29
|
|
|
|
32 untoasted30
|
|
|
|
33 untoasted31
|
|
|
|
34 untoasted32
|
|
|
|
35 untoasted33
|
|
|
|
36 untoasted34
|
|
|
|
37 untoasted35
|
|
|
|
38 untoasted36
|
|
|
|
39 untoasted37
|
|
|
|
40 untoasted38
|
|
|
|
41 untoasted39
|
|
|
|
42 untoasted40
|
|
|
|
43 untoasted41
|
|
|
|
44 untoasted42
|
|
|
|
45 untoasted43
|
|
|
|
46 untoasted44
|
|
|
|
47 untoasted45
|
|
|
|
48 untoasted46
|
|
|
|
49 untoasted47
|
|
|
|
50 untoasted48
|
|
|
|
51 untoasted49
|
|
|
|
52 untoasted50
|
|
|
|
53 untoasted51
|
|
|
|
54 untoasted52
|
|
|
|
55 untoasted53
|
|
|
|
56 untoasted54
|
|
|
|
57 untoasted55
|
|
|
|
58 untoasted56
|
|
|
|
59 untoasted57
|
|
|
|
60 untoasted58
|
|
|
|
61 untoasted59
|
|
|
|
62 untoasted60
|
|
|
|
63 untoasted61
|
|
|
|
64 untoasted62
|
|
|
|
65 untoasted63
|
|
|
|
66 untoasted64
|
|
|
|
67 untoasted65
|
|
|
|
68 untoasted66
|
|
|
|
69 untoasted67
|
|
|
|
70 untoasted68
|
|
|
|
71 untoasted69
|
|
|
|
72 untoasted70
|
|
|
|
73 untoasted71
|
|
|
|
74 untoasted72
|
|
|
|
75 untoasted73
|
|
|
|
76 untoasted74
|
|
|
|
77 untoasted75
|
|
|
|
78 untoasted76
|
|
|
|
79 untoasted77
|
|
|
|
80 untoasted78
|
|
|
|
81 untoasted79
|
|
|
|
82 untoasted80
|
|
|
|
83 untoasted81
|
|
|
|
84 untoasted82
|
|
|
|
85 untoasted83
|
|
|
|
86 untoasted84
|
|
|
|
87 untoasted85
|
|
|
|
88 untoasted86
|
|
|
|
89 untoasted87
|
|
|
|
90 untoasted88
|
|
|
|
91 untoasted89
|
|
|
|
92 untoasted90
|
|
|
|
93 untoasted91
|
|
|
|
94 untoasted92
|
|
|
|
95 untoasted93
|
|
|
|
96 untoasted94
|
|
|
|
97 untoasted95
|
|
|
|
98 untoasted96
|
|
|
|
99 untoasted97
|
|
|
|
100 untoasted98
|
|
|
|
101 untoasted99
|
|
|
|
102 untoasted100
|
|
|
|
103 untoasted101
|
|
|
|
104 untoasted102
|
|
|
|
105 untoasted103
|
|
|
|
106 untoasted104
|
|
|
|
107 untoasted105
|
|
|
|
108 untoasted106
|
|
|
|
109 untoasted107
|
|
|
|
110 untoasted108
|
|
|
|
111 untoasted109
|
|
|
|
112 untoasted110
|
|
|
|
113 untoasted111
|
|
|
|
114 untoasted112
|
|
|
|
115 untoasted113
|
|
|
|
116 untoasted114
|
|
|
|
117 untoasted115
|
|
|
|
118 untoasted116
|
|
|
|
119 untoasted117
|
|
|
|
120 untoasted118
|
|
|
|
121 untoasted119
|
|
|
|
122 untoasted120
|
|
|
|
123 untoasted121
|
|
|
|
124 untoasted122
|
|
|
|
125 untoasted123
|
|
|
|
126 untoasted124
|
|
|
|
127 untoasted125
|
|
|
|
128 untoasted126
|
|
|
|
129 untoasted127
|
|
|
|
130 untoasted128
|
|
|
|
131 untoasted129
|
|
|
|
132 untoasted130
|
|
|
|
133 untoasted131
|
|
|
|
134 untoasted132
|
|
|
|
135 untoasted133
|
|
|
|
136 untoasted134
|
|
|
|
137 untoasted135
|
|
|
|
138 untoasted136
|
|
|
|
139 untoasted137
|
|
|
|
140 untoasted138
|
|
|
|
141 untoasted139
|
|
|
|
142 untoasted140
|
|
|
|
143 untoasted141
|
|
|
|
144 untoasted142
|
|
|
|
145 untoasted143
|
|
|
|
146 untoasted144
|
|
|
|
147 untoasted145
|
|
|
|
148 untoasted146
|
|
|
|
149 untoasted147
|
|
|
|
150 untoasted148
|
|
|
|
151 untoasted149
|
|
|
|
152 untoasted150
|
|
|
|
153 untoasted151
|
|
|
|
154 untoasted152
|
|
|
|
155 untoasted153
|
|
|
|
156 untoasted154
|
|
|
|
157 untoasted155
|
|
|
|
158 untoasted156
|
|
|
|
159 untoasted157
|
|
|
|
160 untoasted158
|
|
|
|
161 untoasted159
|
|
|
|
162 untoasted160
|
|
|
|
163 untoasted161
|
|
|
|
164 untoasted162
|
|
|
|
165 untoasted163
|
|
|
|
166 untoasted164
|
|
|
|
167 untoasted165
|
|
|
|
168 untoasted166
|
|
|
|
169 untoasted167
|
|
|
|
170 untoasted168
|
|
|
|
171 untoasted169
|
|
|
|
172 untoasted170
|
|
|
|
173 untoasted171
|
|
|
|
174 untoasted172
|
|
|
|
175 untoasted173
|
|
|
|
176 untoasted174
|
|
|
|
177 untoasted175
|
|
|
|
178 untoasted176
|
|
|
|
179 untoasted177
|
|
|
|
180 untoasted178
|
|
|
|
181 untoasted179
|
|
|
|
182 untoasted180
|
|
|
|
183 untoasted181
|
|
|
|
184 untoasted182
|
|
|
|
185 untoasted183
|
|
|
|
186 untoasted184
|
|
|
|
187 untoasted185
|
|
|
|
188 untoasted186
|
|
|
|
189 untoasted187
|
|
|
|
190 untoasted188
|
|
|
|
191 untoasted189
|
|
|
|
192 untoasted190
|
|
|
|
193 untoasted191
|
|
|
|
194 untoasted192
|
|
|
|
195 untoasted193
|
|
|
|
196 untoasted194
|
|
|
|
197 untoasted195
|
|
|
|
198 untoasted196
|
|
|
|
199 untoasted197
|
|
|
|
200 untoasted198
|
|
|
|
201 toasted3-12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
|
|
|
|
202 untoasted199
|
|
|
|
203 untoasted200
|
2014-07-06 15:58:01 +02:00
|
|
|
\.
|
2014-09-01 13:42:43 +02:00
|
|
|
SELECT substr(data, 1, 200) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
logical decoding: Fix handling of large old tuples with replica identity full.
When decoding the old version of an UPDATE or DELETE change, and if that
tuple was bigger than MaxHeapTupleSize, we either Assert'ed out, or
failed in more subtle ways in non-assert builds. Normally individual
tuples aren't bigger than MaxHeapTupleSize, with big datums toasted.
But that's not the case for the old version of a tuple for logical
decoding; the replica identity is logged as one piece. With the default
replica identity btree limits that to small tuples, but that's not the
case for FULL.
Change the tuple buffer infrastructure to separate allocate over-large
tuples, instead of always going through the slab cache.
This unfortunately requires changing the ReorderBufferTupleBuf
definition, we need to store the allocated size someplace. To avoid
requiring output plugins to recompile, don't store HeapTupleHeaderData
directly after HeapTupleData, but point to it via t_data; that leaves
rooms for the allocated size. As there's no reason for an output plugin
to look at ReorderBufferTupleBuf->t_data.header, remove the field. It
was just a minor convenience having it directly accessible.
Reported-By: Adam Dratwiński
Discussion: CAKg6ypLd7773AOX4DiOGRwQk1TVOQKhNwjYiVjJnpq8Wo+i62Q@mail.gmail.com
2016-03-06 03:02:20 +01:00
|
|
|
|
|
|
|
-- test we can decode "old" tuples bigger than the max heap tuple size correctly
|
|
|
|
DROP TABLE IF EXISTS toasted_several;
|
|
|
|
CREATE TABLE toasted_several (
|
|
|
|
id serial unique not null,
|
|
|
|
toasted_key text primary key,
|
|
|
|
toasted_col1 text,
|
|
|
|
toasted_col2 text
|
|
|
|
);
|
|
|
|
ALTER TABLE toasted_several REPLICA IDENTITY FULL;
|
|
|
|
ALTER TABLE toasted_several ALTER COLUMN toasted_key SET STORAGE EXTERNAL;
|
|
|
|
ALTER TABLE toasted_several ALTER COLUMN toasted_col1 SET STORAGE EXTERNAL;
|
|
|
|
ALTER TABLE toasted_several ALTER COLUMN toasted_col2 SET STORAGE EXTERNAL;
|
|
|
|
|
2020-04-09 14:10:01 +02:00
|
|
|
-- Change the storage of the index back to EXTENDED, separately from
|
|
|
|
-- the table. This is currently not doable via DDL, but it is
|
|
|
|
-- supported internally.
|
|
|
|
UPDATE pg_attribute SET attstorage = 'x' WHERE attrelid = 'toasted_several_pkey'::regclass AND attname = 'toasted_key';
|
|
|
|
|
2017-08-05 23:41:40 +02:00
|
|
|
INSERT INTO toasted_several(toasted_key) VALUES(repeat('9876543210', 10000));
|
|
|
|
SELECT pg_column_size(toasted_key) > 2^16 FROM toasted_several;
|
logical decoding: Fix handling of large old tuples with replica identity full.
When decoding the old version of an UPDATE or DELETE change, and if that
tuple was bigger than MaxHeapTupleSize, we either Assert'ed out, or
failed in more subtle ways in non-assert builds. Normally individual
tuples aren't bigger than MaxHeapTupleSize, with big datums toasted.
But that's not the case for the old version of a tuple for logical
decoding; the replica identity is logged as one piece. With the default
replica identity btree limits that to small tuples, but that's not the
case for FULL.
Change the tuple buffer infrastructure to separate allocate over-large
tuples, instead of always going through the slab cache.
This unfortunately requires changing the ReorderBufferTupleBuf
definition, we need to store the allocated size someplace. To avoid
requiring output plugins to recompile, don't store HeapTupleHeaderData
directly after HeapTupleData, but point to it via t_data; that leaves
rooms for the allocated size. As there's no reason for an output plugin
to look at ReorderBufferTupleBuf->t_data.header, remove the field. It
was just a minor convenience having it directly accessible.
Reported-By: Adam Dratwiński
Discussion: CAKg6ypLd7773AOX4DiOGRwQk1TVOQKhNwjYiVjJnpq8Wo+i62Q@mail.gmail.com
2016-03-06 03:02:20 +01:00
|
|
|
|
|
|
|
SELECT regexp_replace(data, '^(.{100}).*(.{100})$', '\1..\2') FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
|
|
|
|
|
|
|
-- test update of a toasted key without changing it
|
|
|
|
UPDATE toasted_several SET toasted_col1 = toasted_key;
|
|
|
|
UPDATE toasted_several SET toasted_col2 = toasted_col1;
|
|
|
|
|
|
|
|
SELECT regexp_replace(data, '^(.{100}).*(.{100})$', '\1..\2') FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
|
|
|
|
|
|
|
|
/*
|
|
|
|
* update with large tuplebuf, in a transaction large enough to force to spool to disk
|
|
|
|
*/
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO toasted_several(toasted_key) SELECT * FROM generate_series(1, 10234);
|
|
|
|
UPDATE toasted_several SET toasted_col1 = toasted_col2 WHERE id = 1;
|
|
|
|
DELETE FROM toasted_several WHERE id = 1;
|
|
|
|
COMMIT;
|
|
|
|
|
|
|
|
DROP TABLE toasted_several;
|
|
|
|
|
|
|
|
SELECT regexp_replace(data, '^(.{100}).*(.{100})$', '\1..\2') FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1')
|
|
|
|
WHERE data NOT LIKE '%INSERT: %';
|
Introduce logical decoding.
This feature, building on previous commits, allows the write-ahead log
stream to be decoded into a series of logical changes; that is,
inserts, updates, and deletes and the transactions which contain them.
It is capable of handling decoding even across changes to the schema
of the effected tables. The output format is controlled by a
so-called "output plugin"; an example is included. To make use of
this in a real replication system, the output plugin will need to be
modified to produce output in the format appropriate to that system,
and to perform filtering.
Currently, information can be extracted from the logical decoding
system only via SQL; future commits will add the ability to stream
changes via walsender.
Andres Freund, with review and other contributions from many other
people, including Álvaro Herrera, Abhijit Menon-Sen, Peter Gheogegan,
Kevin Grittner, Robert Haas, Heikki Linnakangas, Fujii Masao, Abhijit
Menon-Sen, Michael Paquier, Simon Riggs, Craig Ringer, and Steve
Singer.
2014-03-03 22:32:18 +01:00
|
|
|
SELECT pg_drop_replication_slot('regression_slot');
|