postgresql/src/bin
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
..
initdb Cosmetic cleanups in initdb.c. 2018-08-10 14:14:27 -04:00
pg_archivecleanup Don't fall off the end of perl functions 2018-05-27 09:08:42 -04:00
pg_basebackup Avoid using potentially-under-aligned page buffers. 2018-09-01 15:27:17 -04:00
pg_config Translation updates 2018-05-21 12:29:52 -04:00
pg_controldata Translation updates 2018-06-25 12:37:18 +02:00
pg_ctl Implement "pg_ctl logrotate" command 2018-09-01 19:46:49 +03:00
pg_dump pg_dump: Reorganize getTableAttrs() 2018-08-30 18:09:44 +02:00
pg_resetwal Avoid using potentially-under-aligned page buffers. 2018-09-01 15:27:17 -04:00
pg_rewind Avoid using potentially-under-aligned page buffers. 2018-09-01 15:27:17 -04:00
pg_test_fsync Translation updates 2018-05-21 12:29:52 -04:00
pg_test_timing Translation updates 2018-05-21 12:29:52 -04:00
pg_upgrade Avoid using potentially-under-aligned page buffers. 2018-09-01 15:27:17 -04:00
pg_verify_checksums Avoid using potentially-under-aligned page buffers. 2018-09-01 15:27:17 -04:00
pg_waldump Avoid using potentially-under-aligned page buffers. 2018-09-01 15:27:17 -04:00
pgbench Fix handling of pgbench's hash when no argument is provided 2018-07-27 13:40:24 +09:00
pgevent Update copyright for 2018 2018-01-02 23:30:12 -05:00
psql Fix psql's \dC command to annotate I/O conversion casts as such. 2018-08-31 16:45:33 -04:00
scripts Add semicolons to end of internally run queries 2018-08-30 19:23:22 +02:00
Makefile Allow on-line enabling and disabling of data checksums 2018-04-05 22:04:48 +02:00