postgresql/src/backend/commands
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
..
aggregatecmds.c Improve spelling of new FINALFUNC_MODIFY aggregate attribute. 2018-05-21 11:41:42 -04:00
alter.c Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
amcmds.c Update copyright for 2018 2018-01-02 23:30:12 -05:00
analyze.c Improve VACUUM and ANALYZE by avoiding early lock queue 2018-08-27 09:11:12 +09:00
async.c Update copyright for 2018 2018-01-02 23:30:12 -05:00
cluster.c Refactor cluster_rel() to handle more options 2018-07-24 11:37:32 +09:00
collationcmds.c Merge catalog/pg_foo_fn.h headers back into pg_foo.h headers. 2018-04-08 14:35:29 -04:00
comment.c Update copyright for 2018 2018-01-02 23:30:12 -05:00
constraint.c Update copyright for 2018 2018-01-02 23:30:12 -05:00
conversioncmds.c Merge catalog/pg_foo_fn.h headers back into pg_foo.h headers. 2018-04-08 14:35:29 -04:00
copy.c Allow multi-inserts during COPY into a partitioned table 2018-08-01 10:23:09 +02:00
createas.c Update copyright for 2018 2018-01-02 23:30:12 -05:00
dbcommands.c Rename TransactionChain functions 2018-03-16 13:18:06 -04:00
define.c Update copyright for 2018 2018-01-02 23:30:12 -05:00
discard.c Rename TransactionChain functions 2018-03-16 13:18:06 -04:00
dropcmds.c Fix more wrong paths in header comments 2018-07-11 17:57:04 +03:00
event_trigger.c Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
explain.c Fix misc typos, mostly in comments. 2018-07-18 16:17:32 +03:00
extension.c Replace AclObjectKind with ObjectType 2018-01-19 14:01:15 -05:00
foreigncmds.c Don't record FDW user mappings as members of extensions. 2018-08-07 16:32:50 -04:00
functioncmds.c Prohibit transaction commands in security definer procedures 2018-07-13 10:41:32 +02:00
indexcmds.c Restrict access to reindex of shared catalogs for non-privileged users 2018-08-09 09:40:15 +02:00
lockcmds.c Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
Makefile Implement multivariate n-distinct coefficients 2017-03-24 14:06:10 -03:00
matview.c Indexes with INCLUDE columns and their support in B-tree 2018-04-07 23:00:39 +03:00
opclasscmds.c doc: Update uses of the word "procedure" 2018-08-22 14:44:49 +02:00
operatorcmds.c Change PROCEDURE to FUNCTION in CREATE OPERATOR syntax 2018-08-22 14:44:49 +02:00
policy.c Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
portalcmds.c Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
prepare.c Revert MERGE patch 2018-04-12 11:22:56 +01:00
proclang.c Merge catalog/pg_foo_fn.h headers back into pg_foo.h headers. 2018-04-08 14:35:29 -04:00
publicationcmds.c Merge catalog/pg_foo_fn.h headers back into pg_foo.h headers. 2018-04-08 14:35:29 -04:00
schemacmds.c Replace AclObjectKind with ObjectType 2018-01-19 14:01:15 -05:00
seclabel.c Update copyright for 2018 2018-01-02 23:30:12 -05:00
sequence.c Combine options for RangeVarGetRelidExtended() into a flags argument. 2018-03-30 17:05:16 -07:00
statscmds.c Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
subscriptioncmds.c Split the SetSubscriptionRelState function into two 2018-04-06 10:00:26 -04:00
tablecmds.c Avoid using potentially-under-aligned page buffers. 2018-09-01 15:27:17 -04:00
tablespace.c Refactor dir/file permissions 2018-04-07 17:45:39 -04:00
trigger.c Allow using the updated tuple while moving it to a different partition. 2018-07-12 12:51:39 +05:30
tsearchcmds.c Avoid unnecessary use of pg_strcasecmp for already-downcased identifiers. 2018-01-26 18:25:14 -05:00
typecmds.c Fix a couple minor typos 2018-04-20 19:04:54 -04:00
user.c Replace AclObjectKind with ObjectType 2018-01-19 14:01:15 -05:00
vacuum.c Improve VACUUM and ANALYZE by avoiding early lock queue 2018-08-27 09:11:12 +09:00
vacuumlazy.c Further cleanup of client dependencies on src/include/catalog headers. 2018-04-09 14:39:58 -04:00
variable.c Update copyright for 2018 2018-01-02 23:30:12 -05:00
view.c Fix set of NLS translation issues 2018-08-21 15:17:13 +09:00