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

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: Ante Krešić <ante(at)tigerdata(dot)com>
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-15 18:44:30
Message-ID: ajBHfzOsyPqbqzii@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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")

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Laurenz Albe 2026-06-15 18:38:55 Re: Adding a stored generated column without long-lived locks