agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Álvaro Herrera <alvherre@kurilemu.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Reject REPLICA IDENTITY USING INDEX on column with invalid NOT N
Date: Wed, 12 Aug 2026 17:17:45 +0000
Message-ID: <E1wuCaG-00000000I9Z-0RHD@gemulon.postgresql.org> (raw)

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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/bdaad789c843f57b1fc66c5ede7abaff8a915c3b

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(+)



view thread (3+ messages)

Message-ID: <E1wuCaG-00000000I9Z-0RHD@gemulon.postgresql.org>
Permalink:  ../E1wuCaG-00000000I9Z-0RHD@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wuCaG-00000000I9Z-0RHD@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: alvherre@kurilemu.de, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Reject REPLICA IDENTITY USING INDEX on column with invalid NOT N
  In-Reply-To: <E1wuCaG-00000000I9Z-0RHD@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox