8000 Fix minor 9.4-only bug in logical decoding. · s-monk/postgres@10ad15f · GitHub
[go: up one dir, main page]

Skip to content

Commit 10ad15f

Browse files
committed
Fix minor 9.4-only bug in logical decoding.
The 9.4 version of log_heap_update() stores the full length of the old_key_tuple in xlhdr.t_len, rather than the length less offsetof(HeapTupleHeaderData, t_bits) as is customary elsewhere. DecodeUpdate() was expecting the usual definition, which caused it to copy 23 bytes too much out of the WAL-file buffer. Most of the time that's harmless, although Valgrind on buildfarm member skink has been complaining about it, and there was one actual SIGSEGV on curculio that might have been caused by this. The reconstructed key tuple would also have an over-length t_len, though offhand I do not see how that could cause any visible problem. The problem seems to have disappeared in the 9.5 WAL format changes (commit 2c03216), so we only need to fix 9.4. Discussion: <11035.1469058247@sss.pgh.pa.us>
1 parent f4e4053 commit 10ad15f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/backend/replication/logical/decode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -702,16 +702,16 @@ DecodeUpdate(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
702702
memcpy(&xlhdr, data, sizeof(xlhdr));
703703
data += offsetof(xl_heap_header_len, header);
704704

705-
datalen = xlhdr.t_len + SizeOfHeapHeader;
706-
tuplelen = xlhdr.t_len;
705+
/* t_len is inconsistent with other cases, see log_heap_update */
706+
tuplelen = xlhdr.t_len - offsetof(HeapTupleHeaderData, t_bits);
707+
datalen = tuplelen + SizeOfHeapHeader;
707708

708709
change->data.tp.oldtuple =
709710
ReorderBufferGetTupleBuf(ctx->reorder, tuplelen);
710711

711712
DecodeXLogTuple(data, datalen, change->data.tp.oldtuple);
712713
#ifdef NOT_USED
713-
data += SizeOfHeapHeader;
714-
data += xlhdr.t_len;
714+
data += datalen;
715715
#endif
716716
}
717717

0 commit comments

Comments
 (0)
0