8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d357a16 commit 8c67d29Copy full SHA for 8c67d29
contrib/test_decoding/expected/ddl.out
@@ -409,6 +409,24 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'inc
409
COMMIT
410
(6 rows)
411
412
+-- check that DDL in aborted subtransactions handled correctly
413
+CREATE TABLE tr_sub_ddl(data int);
414
+BEGIN;
415
+SAVEPOINT a;
416
+ALTER TABLE tr_sub_ddl ALTER COLUMN data TYPE text;
417
+INSERT INTO tr_sub_ddl VALUES ('blah-blah');
418
+ROLLBACK TO SAVEPOINT a;
419
+ALTER TABLE tr_sub_ddl ALTER COLUMN data TYPE bigint;
420
+INSERT INTO tr_sub_ddl VALUES(43);
421
+COMMIT;
422
+SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
423
+ data
424
+--------------------------------------------------
425
+ BEGIN
426
+ table public.tr_sub_ddl: INSERT: data[bigint]:43
427
+ COMMIT
428
+(3 rows)
429
+
430
/*
431
* Check whether treating a table as a catalog table works somewhat
432
*/
contrib/test_decoding/sql/ddl.sql
@@ -234,6 +234,19 @@ INSERT INTO tr_sub(path) VALUES ('5-top-1-#1');
234
COMMIT;
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
251
252
src/backend/replication/logical/reorderbuffer.c
@@ -1326,15 +1326,19 @@ ReorderBufferBuildTupleCidHash(ReorderBuffer *rb, ReorderBufferTXN *txn)
1326
}
1327
else
1328
{
1329
+ /*
1330
+ * Maybe we already saw this tuple before in this transaction,
1331
+ * but if so it must have the same cmin.
1332
+ */
1333
Assert(ent->cmin == change->data.tuplecid.cmin);
- Assert(ent->cmax == InvalidCommandId ||
- ent->cmax == change->data.tuplecid.cmax);
1334
1335
- * if the tuple got valid in this transaction and now got deleted
- * we already have a valid cmin stored. The cmax will be
1336
- * InvalidCommandId though.
+ * cmax may be initially invalid, but once set it can only grow,
1337
+ * and never become invalid again.
1338
1339
+ Assert((ent->cmax == InvalidCommandId) ||
1340
+ ((change->data.tuplecid.cmax != InvalidCommandId) &&
1341
+ (change->data.tuplecid.cmax > ent->cmax)));
1342
ent->cmax = change->data.tuplecid.cmax;
1343
1344