Re: [PATCH] REPLICA IDENTITY USING INDEX accepts column with invalid NOT NULL

From: Ante Krešić <ante(at)tigerdata(dot)com>
To: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] REPLICA IDENTITY USING INDEX accepts column with invalid NOT NULL
Date: 2026-06-16 13:03:02
Message-ID: CABXQ4dLmy-=2yW6x2kGGCZ4W0CsFLSPSG-9XTftxBaiwCc4Exw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

I've rebased and updated my patch based on Álvaro Herrera's wording
suggestion.

I have left the function refactoring for future work as suggested.

Thanks,

On Mon, Jun 15, 2026 at 8:44 PM Álvaro Herrera <alvherre(at)kurilemu(dot)de> wrote:

> On 2026-May-14, Ante Krešić wrote:
>
> > + if (!conForm->convalidated)
> > + ereport(ERROR,
> > +
> errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> > + errmsg("index \"%s\"
> cannot be used as replica identity because column \"%s\" has an invalid
> not-null constraint",
> > +
> RelationGetRelationName(indexRel),
> > +
> NameStr(attr->attname)),
> > + /*- translator: second %s is a constraint
> characteristic such as NOT VALID */
> > + errdetail("The constraint
> \"%s\" is marked %s.",
> > +
> NameStr(conForm->conname), "NOT VALID"),
> > + errhint("You might need to
> validate it using %s.",
> > + "ALTER
> TABLE ... VALIDATE CONSTRAINT"));
>
> I'd rather make this error be
>
> + ereport(ERROR,
> + errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> + errmsg("cannot use index \"%s\" as replica identity",
> + RelationGetRelationName(indexRel),
> + NameStr(attr->attname)),
> + /*- translator: third %s is a constraint
> characteristic such as NOT VALID */
> + errdetail("The constraint \"%s\" on column \"%s\" is
> marked %s.",
> + NameStr(conForm->conname),
> NameStr(attr->attname), "NOT VALID"),
> + errhint("You might need to validate it using %s.",
> + "ALTER TABLE ... VALIDATE CONSTRAINT"));
>
> The other ones which you're mimicking are IMO in poor style.
>
> --
> Álvaro Herrera Breisgau, Deutschland —
> https://www.EnterpriseDB.com/
> Officer Krupke, what are we to do?
> Gee, officer Krupke, Krup you! (West Side Story, "Gee, Officer Krupke")
>

Attachment Content-Type Size
v2-0001-Reject-REPLICA-IDENTITY-USING-INDEX-on-column-wit.patch text/x-patch 6.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2026-06-16 13:21:33 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Pavel Borisov 2026-06-16 13:01:34 Re: Add SPLIT PARTITION/MERGE PARTITIONS commands