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ć <[email protected]> Reviewed-by: Aleksander Alekseev <[email protected]> Reviewed-by: solai v <[email protected]> Backpatch-through: 18 Discussion: https://postgr.es/m/CABXQ4dJUibZzN91qvWmsfA7MUDn9YRCNyu3CcukdyokbH1=4...@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(+)
