pgsql: Reject REPLICA IDENTITY USING INDEX on column with invalid NOT N - Mailing list pgsql-committers

From Álvaro Herrera
Subject pgsql: Reject REPLICA IDENTITY USING INDEX on column with invalid NOT N
Date
Msg-id E1wuCaG-00000000I9d-10W8@gemulon.postgresql.org
Whole thread
List pgsql-committers
Reject REPLICA IDENTITY USING INDEX on column with invalid NOT NULL

ALTER TABLE ... REPLICA IDENTITY USING INDEX verified key columns by
reading pg_attribute.attnotnull, but commit a379061a22a8 made
attnotnull true also for unvalidated (NOT VALID) not-null constraints,
which do not prove the column null-free.  An index over such a column
could thus be marked as replica identity even though the column might
contain NULLs, causing apply-side divergence for UPDATE/DELETE on the
nullable rows.

Fix by additionally requiring convalidated for the underlying
constraint, mirroring the fix d9ffc27291f applied to ATExecAddIdentity
for the analogous identity-column case.

Author: Ante Krešić <ante@tigerdata.com>
Reviewed-by: Aleksander Alekseev <aleksander@tigerdata.com>
Reviewed-by: solai v <solai.cdac@gmail.com>
Backpatch-through: 18
Discussion: https://postgr.es/m/CABXQ4dJUibZzN91qvWmsfA7MUDn9YRCNyu3CcukdyokbH1=41Q@mail.gmail.com

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/864ef0fb1c91e83dff143d6de3f6f85390b6415b

Modified Files
--------------
src/backend/commands/tablecmds.c               | 22 ++++++++++++++++++++++
src/test/regress/expected/replica_identity.out | 23 +++++++++++++++++++++++
src/test/regress/sql/replica_identity.sql      | 16 ++++++++++++++++
3 files changed, 61 insertions(+)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix float8_regr_accum() for Inf/NaN with constant other input.
Next
From: Amit Kapila
Date:
Subject: pgsql: Doc: Clarify ALTER PUBLICATION's REFRESH PUBLICATION wording.