aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-02-21 15:13:06 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2015-02-21 15:13:06 -0500
commite1a11d93111ff3fba7a91f3f2ac0b0aca16909a8 (patch)
tree522fdb9a6b2ed8208bdf692579399eac73c69184 /contrib
parent3d9b6f31eec150b5a6000e0814e81e36d9eb069a (diff)
downloadpostgresql-e1a11d93111ff3fba7a91f3f2ac0b0aca16909a8.tar.gz
postgresql-e1a11d93111ff3fba7a91f3f2ac0b0aca16909a8.zip
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 'contrib')
-rw-r--r--contrib/file_fdw/file_fdw.c2
-rw-r--r--contrib/pageinspect/heapfuncs.c17
-rw-r--r--contrib/postgres_fdw/postgres_fdw.c2
3 files changed, 11 insertions, 10 deletions
diff --git a/contrib/file_fdw/file_fdw.c b/contrib/file_fdw/file_fdw.c
index d5697602117..4368897581a 100644
--- a/contrib/file_fdw/file_fdw.c
+++ b/contrib/file_fdw/file_fdw.c
@@ -932,7 +932,7 @@ estimate_size(PlannerInfo *root, RelOptInfo *baserel,
int tuple_width;
tuple_width = MAXALIGN(baserel->width) +
- MAXALIGN(sizeof(HeapTupleHeaderData));
+ MAXALIGN(SizeofHeapTupleHeader);
ntuples = clamp_row_est((double) stat_buf.st_size /
(double) tuple_width);
}
diff --git a/contrib/pageinspect/heapfuncs.c b/contrib/pageinspect/heapfuncs.c
index c8876f3dbca..8d1666c8bda 100644
--- a/contrib/pageinspect/heapfuncs.c
+++ b/contrib/pageinspect/heapfuncs.c
@@ -149,7 +149,7 @@ heap_page_items(PG_FUNCTION_ARGS)
* many other ways, but at least we won't crash.
*/
if (ItemIdHasStorage(id) &&
- lp_len >= sizeof(HeapTupleHeader) &&
+ lp_len >= MinHeapTupleSize &&
lp_offset == MAXALIGN(lp_offset) &&
lp_offset + lp_len <= raw_page_size)
{
@@ -169,18 +169,19 @@ heap_page_items(PG_FUNCTION_ARGS)
values[10] = UInt8GetDatum(tuphdr->t_hoff);
/*
- * We already checked that the item as is completely within the
- * raw page passed to us, with the length given in the line
- * pointer.. Let's check that t_hoff doesn't point over lp_len,
- * before using it to access t_bits and oid.
+ * We already checked that the item is completely within the raw
+ * page passed to us, with the length given in the line pointer.
+ * Let's check that t_hoff doesn't point over lp_len, before using
+ * it to access t_bits and oid.
*/
- if (tuphdr->t_hoff >= sizeof(HeapTupleHeader) &&
- tuphdr->t_hoff <= lp_len)
+ if (tuphdr->t_hoff >= SizeofHeapTupleHeader &&
+ tuphdr->t_hoff <= lp_len &&
+ tuphdr->t_hoff == MAXALIGN(tuphdr->t_hoff))
{
if (tuphdr->t_infomask & HEAP_HASNULL)
{
bits_len = tuphdr->t_hoff -
- (((char *) tuphdr->t_bits) -((char *) tuphdr));
+ offsetof(HeapTupleHeaderData, t_bits);
values[11] = CStringGetTextDatum(
bits_to_text(tuphdr->t_bits, bits_len * 8));
diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c
index d76e739f080..63f057704e6 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -519,7 +519,7 @@ postgresGetForeignRelSize(PlannerInfo *root,
{
baserel->pages = 10;
baserel->tuples =
- (10 * BLCKSZ) / (baserel->width + sizeof(HeapTupleHeaderData));
+ (10 * BLCKSZ) / (baserel->width + MAXALIGN(SizeofHeapTupleHeader));
}
/* Estimate baserel size as best we can with local statistics. */