From 3a21fd817748b8001e91159c3f2a557088b4fa26 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Fri, 2 Oct 2015 12:58:13 +0900 Subject: [PATCH] Fix overestimated size of t_bits in pageinspect In a tuple, an object-id field is added at the end of HeapTupleHeader and the size of he header is updated to include it. However heap_page_items in pageinspect ignored that fact and overestimated the size of bitmap of NULLs by 4 bytes should an OID be defined in this tuple. Per report from Nikolay Sharplov, for a problem found while working on a new feature for pageinspect, and patch by Michael Paquier. --- contrib/pageinspect/heapfuncs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contrib/pageinspect/heapfuncs.c b/contrib/pageinspect/heapfuncs.c index 8d1666c..031d455 100644 --- a/contrib/pageinspect/heapfuncs.c +++ b/contrib/pageinspect/heapfuncs.c @@ -154,7 +154,6 @@ heap_page_items(PG_FUNCTION_ARGS) lp_offset + lp_len <= raw_page_size) { HeapTupleHeader tuphdr; - int bits_len; /* Extract information from the tuple header */ @@ -180,9 +179,15 @@ heap_page_items(PG_FUNCTION_ARGS) { if (tuphdr->t_infomask & HEAP_HASNULL) { + int bits_len; + bits_len = tuphdr->t_hoff - offsetof(HeapTupleHeaderData, t_bits); + /* ignore OID field of tuple if present */ + if (tuphdr->t_infomask & HEAP_HASOID) + bits_len -= sizeof(Oid); + values[11] = CStringGetTextDatum( bits_to_text(tuphdr->t_bits, bits_len * 8)); } -- 2.6.0