In pageinspect/hashfuncs.c, avoid crashes on alignment-picky machines.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 3 Feb 2017 16:34:41 +0000 (11:34 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 3 Feb 2017 16:34:47 +0000 (11:34 -0500)
commit14e9b18fed289e483ed28daec60fdab95da9cc48
tree928ca1c449c1ba884748758d2d52959c3af76881
parent29e312bc1301061ae9f897ff39f3b230c421a5fb
In pageinspect/hashfuncs.c, avoid crashes on alignment-picky machines.

On machines with MAXALIGN = 8, the payload of a bytea is not maxaligned,
since it will start 4 bytes into a palloc'd value.  On alignment-picky
hardware, this will cause failures in accesses to 8-byte-wide values
within the page.  We already encountered this problem when we introduced
GIN index inspection functions, and fixed it in commit 84ad68d64.  Make
use of the same function for hash indexes.

A small difficulty is that up to now contrib/pageinspect has not shared
any functions at all across files.  To support that, introduce a common
header file "pageinspect.h" for the module.

Also, move get_page_from_raw() out of ginfuncs.c, where it didn't
especially belong, and put it in rawpage.c which seems a more natural home.

Per buildfarm.

Discussion: https://postgr.es/m/17311.1486134714@sss.pgh.pa.us
contrib/pageinspect/brinfuncs.c
contrib/pageinspect/btreefuncs.c
contrib/pageinspect/fsmfuncs.c
contrib/pageinspect/ginfuncs.c
contrib/pageinspect/hashfuncs.c
contrib/pageinspect/heapfuncs.c
contrib/pageinspect/pageinspect.h [new file with mode: 0644]
contrib/pageinspect/rawpage.c