Skip to content

Commit 4fc8467

Browse files
ihalatciCopilot
andcommitted
Fix CDC decoder compilation and tuple lifetime on PG15 and PG16
On PostgreSQL 15 and 16, ReorderBufferChange data.tp.newtuple and oldtuple are ReorderBufferTupleBuf pointers rather than HeapTuples, and their pointers are not replaced during translation. Guard originalNewTuple and originalOldTuple restoration and freeing with PG_VERSION_NUM >= PG_VERSION_17. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d89d1f43-18ea-4405-bd1b-5c3129e391a9
1 parent b03e06d commit 4fc8467

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎src/backend/distributed/cdc/cdc_decoder.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,10 @@ TranslateAndPublishRelationForCDC(LogicalDecodingContext *ctx, ReorderBufferTXN
268268
* they were allocated from its own tuple context. Restoring the original
269269
* pointers after publishing keeps each allocator freeing only what it owns.
270270
*/
271+
#if PG_VERSION_NUM >= PG_VERSION_17
271272
HeapTuple originalNewTuple = change->data.tp.newtuple;
272273
HeapTuple originalOldTuple = change->data.tp.oldtuple;
274+
#endif
273275

274276
PG_TRY();
275277
{
@@ -294,6 +296,7 @@ TranslateAndPublishRelationForCDC(LogicalDecodingContext *ctx, ReorderBufferTXN
294296
* This also has to happen when the callback throws, because the reorder
295297
* buffer cleans the transaction up before the error propagates further.
296298
*/
299+
#if PG_VERSION_NUM >= PG_VERSION_17
297300
if (change->data.tp.newtuple != originalNewTuple &&
298301
change->data.tp.newtuple != NULL)
299302
{
@@ -307,6 +310,7 @@ TranslateAndPublishRelationForCDC(LogicalDecodingContext *ctx, ReorderBufferTXN
307310
heap_freetuple(change->data.tp.oldtuple);
308311
change->data.tp.oldtuple = originalOldTuple;
309312
}
313+
#endif
310314

311315
RelationClose(targetRelation);
312316
}

0 commit comments

Comments
 (0)