Skip to content

Commit 41af695

Browse files
committed
prepare parser fixes
1 parent c50886f commit 41af695

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/backend/replication/logical/decode.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,9 @@ DecodeCommit(LogicalDecodingContext *ctx, XLogRecordBuffer *buf,
457457
commit_time = parsed->origin_timestamp;
458458
}
459459

460+
/*
461+
* If that is COMMIT PREPARED than send that to callbacks.
462+
*/
460463
if (TransactionIdIsValid(parsed->twophase_xid)) {
461464
strcpy(ctx->reorder->gid, parsed->twophase_gid);
462465
ReorderBufferCommitBareXact(ctx->reorder, xid, buf->origptr, buf->endptr,
@@ -548,13 +551,6 @@ DecodePrepare(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
548551
RelFileNode *abortrels;
549552
SharedInvalidationMessage *invalmsgs;
550553

551-
// probably there are no origin -- origin stored in hdr
552-
// if (parsed->xinfo & XACT_XINFO_HAS_ORIGIN)
553-
// {
554-
// origin_lsn = parsed->origin_lsn;
555-
// commit_time = parsed->origin_timestamp;
556-
// }
557-
558554
xid = XLogRecGetXid(r);
559555
twophase_buf = XLogRecGetData(r);
560556
twophase_len = sizeof(char) * XLogRecGetDataLen(r);
@@ -588,8 +584,8 @@ DecodePrepare(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
588584
SnapBuildCommitTxn(ctx->snapshot_builder, buf->origptr, xid,
589585
hdr->nsubxacts, children);
590586

591-
// Add db check here
592587
if (SnapBuildXactNeedsSkip(ctx->snapshot_builder, buf->origptr) ||
588+
(hdr->database != InvalidOid && hdr->database != ctx->slot->data.database) ||
593589
FilterByOrigin(ctx, origin_id))
594590
{
595591
for (i = 0; i < hdr->nsubxacts; i++)
@@ -626,6 +622,9 @@ DecodeAbort(LogicalDecodingContext *ctx, XLogRecordBuffer *buf,
626622
XLogRecPtr commit_time = InvalidXLogRecPtr;
627623
XLogRecPtr origin_id = XLogRecGetOrigin(buf->record);
628624

625+
/*
626+
* If that is ROLLBACK PREPARED than send that to callbacks.
627+
*/
629628
if (TransactionIdIsValid(parsed->twophase_xid)) {
630629
strcpy(ctx->reorder->gid, parsed->twophase_gid);
631630
ReorderBufferCommitBareXact(ctx->reorder, xid, buf->origptr, buf->endptr,

0 commit comments

Comments
 (0)