Thread: pgsql: Reorder subskiplsn in pg_subscription to avoid alignment issues.

pgsql: Reorder subskiplsn in pg_subscription to avoid alignment issues.

From
Amit Kapila
Date:
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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/79b716cfb7a1be2a61ebb4418099db1258f35e30

Modified Files
--------------
doc/src/sgml/catalogs.sgml                 | 20 ++++++-------
src/backend/catalog/pg_subscription.c      |  2 +-
src/backend/catalog/system_views.sql       |  4 +--
src/backend/commands/subscriptioncmds.c    |  2 +-
src/include/catalog/catversion.h           |  2 +-
src/include/catalog/pg_subscription.h      | 11 ++++----
src/test/regress/expected/sanity_check.out | 29 +++++++++++++++++++
src/test/regress/expected/test_setup.out   |  4 +++
src/test/regress/regress.c                 | 45 ++++++++++++++++++++++++++++++
src/test/regress/sql/sanity_check.sql      | 26 +++++++++++++++++
src/test/regress/sql/test_setup.sql        |  5 ++++
11 files changed, 130 insertions(+), 20 deletions(-)