aboutsummaryrefslogtreecommitdiff
path: root/contrib/pageinspect/heapfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-01-04 14:59:00 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2018-01-04 14:59:00 -0500
commit5ad1b1728767dbf0209b35072db372d19bc032f7 (patch)
treebc785e68ff8bb20216124490e9c6a565fcb11392 /contrib/pageinspect/heapfuncs.c
parenta6565da8b9ef2b900d298a19cb817a2c9ca90f7e (diff)
downloadpostgresql-5ad1b1728767dbf0209b35072db372d19bc032f7.tar.gz
postgresql-5ad1b1728767dbf0209b35072db372d19bc032f7.zip
Fix incorrect computations of length of null bitmap in pageinspect.
Instead of using our standard macro for this calculation, this code did it itself ... and got it wrong, leading to incorrect display of the null bitmap in some cases. Noted and fixed by Maksim Milyutin. In passing, remove a uselessly duplicative error check. Errors were introduced in commit d6061f83a; back-patch to 9.6 where that came in. Maksim Milyutin, reviewed by Andrey Borodin Discussion: https://postgr.es/m/ec295792-a69f-350f-6287-25a20e8f31d5@gmail.com
Diffstat (limited to 'contrib/pageinspect/heapfuncs.c')
-rw-r--r--contrib/pageinspect/heapfuncs.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/contrib/pageinspect/heapfuncs.c b/contrib/pageinspect/heapfuncs.c
index 72d1776a4a5..1c8a4a8f9a7 100644
--- a/contrib/pageinspect/heapfuncs.c
+++ b/contrib/pageinspect/heapfuncs.c
@@ -234,7 +234,7 @@ heap_page_items(PG_FUNCTION_ARGS)
int bits_len;
bits_len =
- ((tuphdr->t_infomask2 & HEAP_NATTS_MASK) / 8 + 1) * 8;
+ BITMAPLEN(HeapTupleHeaderGetNatts(tuphdr)) * BITS_PER_BYTE;
values[11] = CStringGetTextDatum(
bits_to_text(tuphdr->t_bits, bits_len));
}
@@ -436,24 +436,19 @@ tuple_data_split(PG_FUNCTION_ARGS)
int bits_str_len;
int bits_len;
- bits_len = (t_infomask2 & HEAP_NATTS_MASK) / 8 + 1;
+ bits_len = BITMAPLEN(t_infomask2 & HEAP_NATTS_MASK) * BITS_PER_BYTE;
if (!t_bits_str)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
errmsg("argument of t_bits is null, but it is expected to be null and %d character long",
- bits_len * 8)));
+ bits_len)));
bits_str_len = strlen(t_bits_str);
- if ((bits_str_len % 8) != 0)
- ereport(ERROR,
- (errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("length of t_bits is not a multiple of eight")));
-
- if (bits_len * 8 != bits_str_len)
+ if (bits_len != bits_str_len)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
errmsg("unexpected length of t_bits %u, expected %d",
- bits_str_len, bits_len * 8)));
+ bits_str_len, bits_len)));
/* do the conversion */
t_bits = text_to_bits(t_bits_str, bits_str_len);