summaryrefslogtreecommitdiff
path: root/src/include/access
diff options
context:
space:
mode:
authorTom Lane2015-02-21 20:13:06 +0000
committerTom Lane2015-02-21 20:13:06 +0000
commite1a11d93111ff3fba7a91f3f2ac0b0aca16909a8 (patch)
tree522fdb9a6b2ed8208bdf692579399eac73c69184 /src/include/access
parent3d9b6f31eec150b5a6000e0814e81e36d9eb069a (diff)
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
Diffstat (limited to 'src/include/access')
-rw-r--r--src/include/access/htup_details.h12
-rw-r--r--src/include/access/tuptoaster.h2
2 files changed, 9 insertions, 5 deletions
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index d2ad910a333..0a673cd5267 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -150,13 +150,15 @@ struct HeapTupleHeaderData
/* ^ - 23 bytes - ^ */
- bits8 t_bits[1]; /* bitmap of NULLs -- VARIABLE LENGTH */
+ bits8 t_bits[FLEXIBLE_ARRAY_MEMBER]; /* bitmap of NULLs */
/* MORE DATA FOLLOWS AT END OF STRUCT */
};
/* typedef appears in tupbasics.h */
+#define SizeofHeapTupleHeader offsetof(HeapTupleHeaderData, t_bits)
+
/*
* information stored in t_infomask:
*/
@@ -498,7 +500,7 @@ do { \
* you can, say, fit 2 tuples of size MaxHeapTupleSize/2 on the same page.
*/
#define MaxHeapTupleSize (BLCKSZ - MAXALIGN(SizeOfPageHeaderData + sizeof(ItemIdData)))
-#define MinHeapTupleSize MAXALIGN(offsetof(HeapTupleHeaderData, t_bits))
+#define MinHeapTupleSize MAXALIGN(SizeofHeapTupleHeader)
/*
* MaxHeapTuplesPerPage is an upper bound on the number of tuples that can
@@ -513,7 +515,7 @@ do { \
*/
#define MaxHeapTuplesPerPage \
((int) ((BLCKSZ - SizeOfPageHeaderData) / \
- (MAXALIGN(offsetof(HeapTupleHeaderData, t_bits)) + sizeof(ItemIdData))))
+ (MAXALIGN(SizeofHeapTupleHeader) + sizeof(ItemIdData))))
/*
* MaxAttrSize is a somewhat arbitrary upper limit on the declared size of
@@ -579,13 +581,15 @@ struct MinimalTupleData
/* ^ - 23 bytes - ^ */
- bits8 t_bits[1]; /* bitmap of NULLs -- VARIABLE LENGTH */
+ bits8 t_bits[FLEXIBLE_ARRAY_MEMBER]; /* bitmap of NULLs */
/* MORE DATA FOLLOWS AT END OF STRUCT */
};
/* typedef appears in htup.h */
+#define SizeofMinimalTupleHeader offsetof(MinimalTupleData, t_bits)
+
/*
* GETSTRUCT - given a HeapTuple pointer, return address of the user data
diff --git a/src/include/access/tuptoaster.h b/src/include/access/tuptoaster.h
index 331dd259ccb..7d185357714 100644
--- a/src/include/access/tuptoaster.h
+++ b/src/include/access/tuptoaster.h
@@ -90,7 +90,7 @@
#define TOAST_MAX_CHUNK_SIZE \
(EXTERN_TUPLE_MAX_SIZE - \
- MAXALIGN(offsetof(HeapTupleHeaderData, t_bits)) - \
+ MAXALIGN(SizeofHeapTupleHeader) - \
sizeof(Oid) - \
sizeof(int32) - \
VARHDRSZ)