Re: BUG #19393: pg_upgrade fails with duplicate key violation when CHECK constraint named *_not_null exists

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Hüseyin Demir <huseyin(dot)d3r(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19393: pg_upgrade fails with duplicate key violation when CHECK constraint named *_not_null exists
Date: 2026-02-09 11:01:27
Message-ID: a0e392410cad51bbe236828e1133ed7e668ca791.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Mon, 2026-02-09 at 07:24 +0100, Hüseyin Demir wrote:
> Thanks for the patch and LGTM for PostgreSQL 18.

Thanks for checking!

> I tried to create following table on PG18
>
> benchmark=# CREATE TABLE two_not_null_constraints (
>      col integer NOT NULL,
>      CONSTRAINT two_not_null_constraints_col_not_null CHECK (col IS NOT NULL)
>   );
> ERROR: duplicate key value violates unique constraint "pg_constraint_conrelid_contypid_conname_index"
> DETAIL: Key (conrelid, contypid, conname)=(16385, 0, two_not_null_constraints_col_not_null) already exists.
>
> In PG17 I was able to create the table.

Yes, because what causes your problemm is a new feature in v18.

> One question during the tests should we confirm the output of pg_constraint table ?
> It would make sense during the tests but the current test is also good to proceed.

I would prefer not to, but I don't have a strong opinion about it.
Which name PostgreSQL chooses for the generated NOT NULL constraint
is not important, as long as it doesn't conflict with the existing name.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2026-02-09 11:33:58 BUG #19398: Non-existent repositories are used
Previous Message PG Bug reporting form 2026-02-09 07:31:13 BUG #19396: Standby and DR site replication broken with PANIC: WAL contains references to invalid pages messge

Browse pgsql-hackers by date

  From Date Subject
Next Message Aleksander Alekseev 2026-02-09 11:19:16 Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments
Previous Message Vitaly Davydov 2026-02-09 10:42:56 Re: Support logical replication of DDLs