postgresql/src/bin
Tom Lane 03ffe5553c Avoid using potentially-under-aligned page buffers.
There's a project policy against using plain "char buf[BLCKSZ]" local
or static variables as page buffers; preferred style is to palloc or
malloc each buffer to ensure it is MAXALIGN'd.  However, that policy's
been ignored in an increasing number of places.  We've apparently got
away with it so far, probably because (a) relatively few people use
platforms on which misalignment causes core dumps and/or (b) the
variables chance to be sufficiently aligned anyway.  But this is not
something to rely on.  Moreover, even if we don't get a core dump,
we might be paying a lot of cycles for misaligned accesses.

To fix, invent new union types PGAlignedBlock and PGAlignedXLogBlock
that the compiler must allocate with sufficient alignment, and use
those in place of plain char arrays.

I used these types even for variables where there's no risk of a
misaligned access, since ensuring proper alignment should make
kernel data transfers faster.  I also changed some places where
we had been palloc'ing short-lived buffers, for coding style
uniformity and to save palloc/pfree overhead.

Since this seems to be a live portability hazard (despite the lack
of field reports), back-patch to all supported versions.

Patch by me; thanks to Michael Paquier for review.

Discussion: https://postgr.es/m/1535618100.1286.3.camel@credativ.de
2018-09-01 15:27:13 -04:00
..
initdb Translation updates 2018-08-06 19:35:42 +02:00
pg_archivecleanup Fix new warnings from GCC 7 2017-05-16 08:43:55 -04:00
pg_basebackup Avoid using potentially-under-aligned page buffers. 2018-09-01 15:27:13 -04:00
pg_config Translation updates 2018-08-06 19:35:42 +02:00
pg_controldata Translation updates 2018-08-06 19:35:42 +02:00
pg_ctl Translation updates 2018-08-06 19:35:42 +02:00
pg_dump Make pg_restore's identify_locking_dependencies() more bulletproof. 2018-08-28 19:46:59 -04:00
pg_resetxlog Avoid using potentially-under-aligned page buffers. 2018-09-01 15:27:13 -04:00
pg_rewind Avoid using potentially-under-aligned page buffers. 2018-09-01 15:27:13 -04:00
pg_test_fsync Avoid depending on non-POSIX behavior of fcntl(2). 2017-04-21 15:55:56 -04:00
pg_test_timing Move pg_test_timing from contrib/ to src/bin/ 2015-04-20 21:30:12 -04:00
pg_upgrade pg_upgrade: issue helpful error message for use on standbys 2018-08-17 10:25:48 -04:00
pg_xlogdump Use snprintf not sprintf in pg_waldump's timestamptz_to_str. 2018-06-16 14:45:47 -04:00
pgbench Prevent accidental linking of system-supplied copies of libpq.so etc. 2018-07-09 17:23:31 -04:00
pgevent Update copyright for 2015 2015-01-06 11:43:47 -05:00
psql Fix lexing of standard multi-character operators in edge cases. 2018-08-23 21:35:53 +01:00
scripts Fix set of NLS translation issues 2018-08-21 15:18:14 +09:00
Makefile Move pg_xlogdump from contrib/ to src/bin/ 2015-04-21 19:03:49 -04:00