Re: BUG #19393: pg_upgrade fails with duplicate key violation when CHECK constraint named *_not_null exists
Dilip Kumar <dilipbalaut@gmail.com>
From: Dilip Kumar <dilipbalaut@gmail.com>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: huseyin.d3r@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2026-02-06T07:23:33Z
Lists: pgsql-bugs, pgsql-hackers
On Thu, Feb 5, 2026 at 10:22 PM Laurenz Albe <laurenz.albe@cybertec.at> wrote: > > On Thu, 2026-02-05 at 15:58 +0100, I wrote: > > The bug is actually not in pg_upgrade, but in CREATE TABLE. The attached patch > > fixes the problem for me by avoiding given constraint names when generating > > the names for NOT NULL constraints. > > ... and here is v2, including a regression test. The fix LGTM. However I have one question, have you considered validating the name selection logic for other constraint types as well? I’m specifically thinking about AddRelationNewConstraints(). While I don't have a specific test case yet, is it possible for the AddRelationNewConstraints to choose a name that is already in use when adding a new column with a constraint? -- Regards, Dilip Kumar Google
Commits
-
Update .abi-compliance-history for AddRelationNotNullConstraints().
- 70eca789eaaa 18.3 landed
-
Avoid name collision with NOT NULL constraints
- 8d9a97e0bb6d 18.3 landed
- 0eeffd31bf9b 19 (unreleased) landed