1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-21 15:54:08 +03:00

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 2c03216d8), so we only need to fix 9.4.

Discussion: <11035.1469058247@sss.pgh.pa.us>
This commit is contained in:
Tom Lane 2016-09-01 11:45:16 -04:00
parent f4e40537e1
commit 10ad15f48a

View File

@ -702,16 +702,16 @@ DecodeUpdate(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
memcpy(&xlhdr, data, sizeof(xlhdr)); memcpy(&xlhdr, data, sizeof(xlhdr));
data += offsetof(xl_heap_header_len, header); data += offsetof(xl_heap_header_len, header);
datalen = xlhdr.t_len + SizeOfHeapHeader; /* t_len is inconsistent with other cases, see log_heap_update */
tuplelen = xlhdr.t_len; tuplelen = xlhdr.t_len - offsetof(HeapTupleHeaderData, t_bits);
datalen = tuplelen + SizeOfHeapHeader;
change->data.tp.oldtuple = change->data.tp.oldtuple =
ReorderBufferGetTupleBuf(ctx->reorder, tuplelen); ReorderBufferGetTupleBuf(ctx->reorder, tuplelen);
DecodeXLogTuple(data, datalen, change->data.tp.oldtuple); DecodeXLogTuple(data, datalen, change->data.tp.oldtuple);
#ifdef NOT_USED #ifdef NOT_USED
data += SizeOfHeapHeader; data += datalen;
data += xlhdr.t_len;
#endif #endif
} }