Fix corrupt GIN_SEGMENT_ADDITEMS WAL records on big-endian hardware.
Fix corrupt GIN_SEGMENT_ADDITEMS WAL records on big-endian hardware.

computeLeafRecompressWALData() tried to produce a uint16 WAL log field by
memcpy'ing the first two bytes of an int-sized variable.  That accidentally
works on little-endian hardware, but not at all on big-endian.  Replay then
thinks it's looking at an ADDITEMS action with zero entries, and reads the
first two bytes of the first TID therein as the next segno/action,
typically leading to "unexpected GIN leaf action" errors during replay.
Even if replay failed to crash, the resulting GIN index page would surely
be incorrect.  To fix, just declare the variable as uint16 instead.

Per bug #14295 from Spencer Thomason (much thanks to Spencer for turning
his problem into a self-contained test case).  This likely also explains
a previous report of the same symptom from Bernd Helmle.

Back-patch to 9.4 where the problem was introduced (by commit 14d02f0bb).

Discussion: <0d140cf0c6e573211ec913354a6e48cf41f172fb@wrigleys.postgresql.org>
Possible-Report: <35a7d54e4d54a9c3f309d80babb2a45b4925a996@eje.land.credativ.lan>

greenplum-db/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,xinzweb/gpdb,adam8157/gpdb,jmcatamney/gpdb,xinzweb/gpdb,xinzweb/gpdb,jmcatamney/gpdb,lisakowen/gpdb,50wu/gpdb,50wu/gpdb,lisakowen/gpdb,xinzweb/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,xinzweb/gpdb,50wu/gpdb,50wu/gpdb,jmcatamney/gpdb,50wu/gpdb,adam8157/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,adam8157/gpdb,greenplum-db/gpdb,xinzweb/gpdb,greenplum-db/gpdb,adam8157/gpdb,ashwinstar/gpdb,lisakowen/gpdb,ashwinstar/gpdb,lisakowen/gpdb,lisakowen/gpdb,greenplum-db/gpdb,lisakowen/gpdb,ashwinstar/gpdb,50wu/gpdb,50wu/gpdb,lisakowen/gpdb,xinzweb/gpdb,xinzweb/gpdb,ashwinstar/gpdb,adam8157/gpdb,adam8157/gpdb,ashwinstar/gpdb,ashwinstar/gpdb,adam8157/gpdb,adam8157/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,lisakowen/gpdb,jmcatamney/gpdb,50wu/gpdb,ashwinstar/gpdb