v3-0001-Handle-XLOG_HEAP2_NEW_CID-in-fast-forward.patch
application/octet-stream
Filename: v3-0001-Handle-XLOG_HEAP2_NEW_CID-in-fast-forward.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
Series: patch v3-0001
| File | + | − |
|---|---|---|
| src/backend/replication/logical/decode.c | 10 | 2 |
| src/backend/replication/logical/snapbuild.c | 0 | 6 |
diff --git a/src/backend/replication/logical/decode.c b/src/backend/replication/logical/decode.c
index cc03f0706e9..4f5704354a6 100644
--- a/src/backend/replication/logical/decode.c
+++ b/src/backend/replication/logical/decode.c
@@ -429,15 +429,23 @@ heap2_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
DecodeMultiInsert(ctx, buf);
break;
case XLOG_HEAP2_NEW_CID:
+ /*
+ * we only log new_cid's if a catalog tuple was modified, so mark the
+ * transaction as containing catalog modifications.
+ *
+ * Note: we do this even in fast-forward mode, as we need to maintain
+ * the snapshot correctly.
+ */
+ ReorderBufferXidSetCatalogChanges(ctx->reorder, xid, buf->origptr);
+
if (!ctx->fast_forward)
{
xl_heap_new_cid *xlrec;
xlrec = (xl_heap_new_cid *) XLogRecGetData(buf->record);
SnapBuildProcessNewCid(builder, xid, buf->origptr, xlrec);
-
- break;
}
+ break;
case XLOG_HEAP2_REWRITE:
/*
diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c
index 6e18baa33cb..9f78a881444 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -691,12 +691,6 @@ SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid,
{
CommandId cid;
- /*
- * we only log new_cid's if a catalog tuple was modified, so mark the
- * transaction as containing catalog modifications
- */
- ReorderBufferXidSetCatalogChanges(builder->reorder, xid, lsn);
-
ReorderBufferAddNewTupleCids(builder->reorder, xlrec->top_xid, lsn,
xlrec->target_locator, xlrec->target_tid,
xlrec->cmin, xlrec->cmax,