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

Hüseyin Demir <huseyin.d3r@gmail.com>

From: Hüseyin Demir <huseyin.d3r@gmail.com>
To: pgsql-hackers@lists.postgresql.org
Cc: Laurenz Albe <laurenz.albe@cybertec.at>
Date: 2026-02-20T06:52:33Z
Lists: pgsql-bugs, pgsql-hackers
The following review has been posted through the commitfest application:
make installcheck-world:  tested, failed
Implements feature:       tested, failed
Spec compliant:           tested, failed
Documentation:            tested, failed

Hi,

I reviewed and tested v2 of this patch.

Builds with zero errors and zero warnings and all tests passed.

Verified the fix against Bug #19393. The original crash (unique key violation on pg_constraint_conrelid_contypid_conname_index) no longer occurs.
Also tested edge cases: cascading collisions (name, name1, name2 all taken), multiple NOT NULL columns with mixed collisions, and the normal no-collision case. All work
correctly. No doc changes needed.

The new status of this patch is: Ready for Committer

Commits

  1. Update .abi-compliance-history for AddRelationNotNullConstraints().

  2. Avoid name collision with NOT NULL constraints