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

Use FLEXIBLE_ARRAY_MEMBER for HeapTupleHeaderData.t_bits[].

This requires changing quite a few places that were depending on
sizeof(HeapTupleHeaderData), but it seems for the best.

Michael Paquier, some adjustments by me
This commit is contained in:
Tom Lane
2015-02-21 15:13:06 -05:00
parent 3d9b6f31ee
commit e1a11d9311
19 changed files with 102 additions and 99 deletions

View File

@ -765,21 +765,19 @@ DecodeMultiInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
* transactions.
*/
tuple->tuple.t_tableOid = InvalidOid;
tuple->tuple.t_data = &tuple->header;
tuple->tuple.t_len = datalen
+ offsetof(HeapTupleHeaderData, t_bits);
tuple->tuple.t_data = &tuple->t_data.header;
tuple->tuple.t_len = datalen + SizeofHeapTupleHeader;
memset(&tuple->header, 0, sizeof(HeapTupleHeaderData));
memset(&tuple->t_data.header, 0, SizeofHeapTupleHeader);
memcpy((char *) &tuple->header
+ offsetof(HeapTupleHeaderData, t_bits),
memcpy((char *) &tuple->t_data.header + SizeofHeapTupleHeader,
(char *) data,
datalen);
data += datalen;
tuple->header.t_infomask = xlhdr->t_infomask;
tuple->header.t_infomask2 = xlhdr->t_infomask2;
tuple->header.t_hoff = xlhdr->t_hoff;
tuple->t_data.header.t_infomask = xlhdr->t_infomask;
tuple->t_data.header.t_infomask2 = xlhdr->t_infomask2;
tuple->t_data.header.t_hoff = xlhdr->t_hoff;
}
/*
@ -815,27 +813,27 @@ DecodeXLogTuple(char *data, Size len, ReorderBufferTupleBuf *tuple)
Assert(datalen >= 0);
Assert(datalen <= MaxHeapTupleSize);
tuple->tuple.t_len = datalen + offsetof(HeapTupleHeaderData, t_bits);
tuple->tuple.t_len = datalen + SizeofHeapTupleHeader;
/* not a disk based tuple */
ItemPointerSetInvalid(&tuple->tuple.t_self);
/* we can only figure this out after reassembling the transactions */
tuple->tuple.t_tableOid = InvalidOid;
tuple->tuple.t_data = &tuple->header;
tuple->tuple.t_data = &tuple->t_data.header;
/* data is not stored aligned, copy to aligned storage */
memcpy((char *) &xlhdr,
data,
SizeOfHeapHeader);
memset(&tuple->header, 0, sizeof(HeapTupleHeaderData));
memset(&tuple->t_data.header, 0, SizeofHeapTupleHeader);
memcpy((char *) &tuple->header + offsetof(HeapTupleHeaderData, t_bits),
memcpy((char *) &tuple->t_data.header + SizeofHeapTupleHeader,
data + SizeOfHeapHeader,
datalen);
tuple->header.t_infomask = xlhdr.t_infomask;
tuple->header.t_infomask2 = xlhdr.t_infomask2;
tuple->header.t_hoff = xlhdr.t_hoff;
tuple->t_data.header.t_infomask = xlhdr.t_infomask;
tuple->t_data.header.t_infomask2 = xlhdr.t_infomask2;
tuple->t_data.header.t_hoff = xlhdr.t_hoff;
}