Reorder subskiplsn in pg_subscription to avoid alignment issues.
authorAmit Kapila <akapila@postgresql.org>
Thu, 7 Apr 2022 04:09:25 +0000 (09:39 +0530)
committerAmit Kapila <akapila@postgresql.org>
Thu, 7 Apr 2022 04:09:25 +0000 (09:39 +0530)
commit79b716cfb7a1be2a61ebb4418099db1258f35e30
tree6d081e1dac75d5aae7f7c3b5af676b1a788bfd01
parente41aed674f35c63380175bb0e2dfa8dccfb2204d
Reorder subskiplsn in pg_subscription to avoid alignment issues.

The column 'subskiplsn' uses TYPALIGN_DOUBLE (which has 4 bytes alignment
on AIX) for storage. But the C Struct (Form_pg_subscription) has 8-byte
alignment for this field, so retrieving it from storage causes an
unaligned read.

To fix this, we rearranged the 'subskiplsn' column in the catalog so that
it naturally comes at an 8-byte boundary.

We have fixed a similar problem in commit f3b421da5f. This patch adds a
test to avoid a similar mistake in the future.

Reported-by: Noah Misch
Diagnosed-by: Noah Misch, Masahiko Sawada, Amit Kapila
Author: Masahiko Sawada
Reviewed-by: Noah Misch, Amit Kapila
Discussion: https://postgr.es/m/20220401074423.GC3682158@rfd.leadboat.com
    https://postgr.es/m/CAD21AoDeScrsHhLyEPYqN3sydg6PxAPVBboK=30xJfUVihNZDA@mail.gmail.com
doc/src/sgml/catalogs.sgml
src/backend/catalog/pg_subscription.c
src/backend/catalog/system_views.sql
src/backend/commands/subscriptioncmds.c
src/include/catalog/catversion.h
src/include/catalog/pg_subscription.h
src/test/regress/expected/sanity_check.out
src/test/regress/expected/test_setup.out
src/test/regress/regress.c
src/test/regress/sql/sanity_check.sql
src/test/regress/sql/test_setup.sql