mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
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
This commit is contained in:
@@ -63,6 +63,7 @@ GetSubscription(Oid subid, bool missing_ok)
|
||||
sub = (Subscription *) palloc(sizeof(Subscription));
|
||||
sub->oid = subid;
|
||||
sub->dbid = subform->subdbid;
|
||||
sub->skiplsn = subform->subskiplsn;
|
||||
sub->name = pstrdup(NameStr(subform->subname));
|
||||
sub->owner = subform->subowner;
|
||||
sub->enabled = subform->subenabled;
|
||||
@@ -70,7 +71,6 @@ GetSubscription(Oid subid, bool missing_ok)
|
||||
sub->stream = subform->substream;
|
||||
sub->twophasestate = subform->subtwophasestate;
|
||||
sub->disableonerr = subform->subdisableonerr;
|
||||
sub->skiplsn = subform->subskiplsn;
|
||||
|
||||
/* Get conninfo */
|
||||
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
|
||||
|
@@ -1285,8 +1285,8 @@ REVOKE ALL ON pg_replication_origin_status FROM public;
|
||||
|
||||
-- All columns of pg_subscription except subconninfo are publicly readable.
|
||||
REVOKE ALL ON pg_subscription FROM public;
|
||||
GRANT SELECT (oid, subdbid, subname, subowner, subenabled, subbinary,
|
||||
substream, subtwophasestate, subdisableonerr, subskiplsn, subslotname,
|
||||
GRANT SELECT (oid, subdbid, subskiplsn, subname, subowner, subenabled,
|
||||
subbinary, substream, subtwophasestate, subdisableonerr, subslotname,
|
||||
subsynccommit, subpublications)
|
||||
ON pg_subscription TO public;
|
||||
|
||||
|
@@ -596,6 +596,7 @@ CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt,
|
||||
Anum_pg_subscription_oid);
|
||||
values[Anum_pg_subscription_oid - 1] = ObjectIdGetDatum(subid);
|
||||
values[Anum_pg_subscription_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
|
||||
values[Anum_pg_subscription_subskiplsn - 1] = LSNGetDatum(InvalidXLogRecPtr);
|
||||
values[Anum_pg_subscription_subname - 1] =
|
||||
DirectFunctionCall1(namein, CStringGetDatum(stmt->subname));
|
||||
values[Anum_pg_subscription_subowner - 1] = ObjectIdGetDatum(owner);
|
||||
@@ -607,7 +608,6 @@ CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt,
|
||||
LOGICALREP_TWOPHASE_STATE_PENDING :
|
||||
LOGICALREP_TWOPHASE_STATE_DISABLED);
|
||||
values[Anum_pg_subscription_subdisableonerr - 1] = BoolGetDatum(opts.disableonerr);
|
||||
values[Anum_pg_subscription_subskiplsn - 1] = LSNGetDatum(InvalidXLogRecPtr);
|
||||
values[Anum_pg_subscription_subconninfo - 1] =
|
||||
CStringGetTextDatum(conninfo);
|
||||
if (opts.slot_name)
|
||||
|
Reference in New Issue
Block a user