Re: [PATCH] REPLICA IDENTITY USING INDEX accepts column with invalid NOT NULL - Mailing list pgsql-hackers

From Ante Krešić
Subject Re: [PATCH] REPLICA IDENTITY USING INDEX accepts column with invalid NOT NULL
Date
Msg-id CABXQ4dLmy-=2yW6x2kGGCZ4W0CsFLSPSG-9XTftxBaiwCc4Exw@mail.gmail.com
Whole thread
Responses Re: [PATCH] REPLICA IDENTITY USING INDEX accepts column with invalid NOT NULL
List 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@kurilemu.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

pgsql-hackers by date:

Previous
From: Pavel Borisov
Date:
Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Next
From: Dilip Kumar
Date:
Subject: Re: Proposal: Conflict log history table for Logical Replication