postgresql/src/bin/pg_upgrade
Tom Lane 44cac93464 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:17 -04:00
..
po Translation updates 2018-05-21 12:29:52 -04:00
.gitignore Ignore file generated during pg_upgrade testing 2018-04-30 12:39:29 -04:00
IMPLEMENTATION Fix wording in pg_upgrade docs 2017-05-05 12:42:21 +02:00
Makefile Prevent accidental linking of system-supplied copies of libpq.so etc. 2018-04-03 16:26:05 -04:00
TESTING Fix bit-rot in pg_upgrade's test.sh, and improve documentation. 2017-06-08 13:48:39 -04:00
check.c Improve two error messages 2018-07-12 12:35:59 +02:00
controldata.c pg_upgrade: issue helpful error message for use on standbys 2018-08-17 10:25:48 -04:00
dump.c Ensure that all temp files made during pg_upgrade are non-world-readable. 2018-02-05 10:58:27 -05:00
exec.c Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
file.c Avoid using potentially-under-aligned page buffers. 2018-09-01 15:27:17 -04:00
function.c pg_upgrade: report database names with missing extension libs 2018-07-28 12:33:54 -04:00
info.c Switch client-side code to include catalog/pg_foo_d.h not pg_foo.h. 2018-04-08 13:59:52 -04:00
nls.mk Translation updates 2018-05-21 12:29:52 -04:00
option.c Update copyright for 2018 2018-01-02 23:30:12 -05:00
parallel.c pg_upgrade: prevent check on live cluster from generating error 2018-01-08 22:43:51 -05:00
pg_upgrade.c pg_upgrade: check for clean server shutdowns 2018-07-28 15:01:55 -04:00
pg_upgrade.h pg_upgrade: report database names with missing extension libs 2018-07-28 12:33:54 -04:00
relfilenode.c Switch client-side code to include catalog/pg_foo_d.h not pg_foo.h. 2018-04-08 13:59:52 -04:00
server.c Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
tablespace.c Fix misc typos, mostly in comments. 2018-07-18 16:17:32 +03:00
test.sh Further portability hacking in pg_upgrade's test script. 2018-07-21 15:40:51 -04:00
util.c Update copyright for 2018 2018-01-02 23:30:12 -05:00
version.c Switch client-side code to include catalog/pg_foo_d.h not pg_foo.h. 2018-04-08 13:59:52 -04:00