Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e26b8c2

Browse files
committed
quick attempt to fix broken decoding of compound primary key updates
1 parent c39f288 commit e26b8c2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/backend/access/rmgrdesc/heapdesc.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ heap_desc(StringInfo buf, XLogReaderState *record)
3636
{
3737
char *rec = XLogRecGetData(record);
3838
uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
39+
bool isinit = (XLogRecGetInfo(record) & XLOG_HEAP_INIT_PAGE) != 0;
3940

4041
info &= XLOG_HEAP_OPMASK;
4142
if (info == XLOG_HEAP_INSERT)
@@ -53,7 +54,12 @@ heap_desc(StringInfo buf, XLogReaderState *record)
5354
}
5455
else if (info == XLOG_HEAP_UPDATE)
5556
{
56-
xl_heap_update *xlrec = (xl_heap_update *) rec;
57+
xl_heap_update *xlrec;
58+
59+
if (isinit)
60+
rec += sizeof(TransactionId);
61+
62+
xlrec = (xl_heap_update *) rec;
5763

5864
appendStringInfo(buf, "off %u xmax " XID_FMT " ",
5965
xlrec->old_offnum,

src/backend/replication/logical/decode.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,11 @@ DecodeUpdate(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
876876
/* caution, remaining data in record is not aligned */
877877
data = XLogRecGetData(r) + SizeOfHeapUpdate;
878878
datalen = XLogRecGetDataLen(r) - SizeOfHeapUpdate;
879+
if (isinit)
880+
{
881+
data += sizeof(TransactionId);
882+
datalen -= sizeof(TransactionId);
883+
}
879884
tuplelen = datalen - SizeOfHeapHeader;
880885

881886
change->data.tp.oldtuple =

0 commit comments

Comments
 (0)