public inbox for [email protected]  
help / color / mirror / Atom feed
pgsql: Avoid name collision with NOT NULL constraints
2+ messages / 1 participants
[nested] [flat]

* pgsql: Avoid name collision with NOT NULL constraints
@ 2026-02-21 11:25 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Álvaro Herrera @ 2026-02-21 11:25 UTC (permalink / raw)
  To: [email protected]

Avoid name collision with NOT NULL constraints

If a CREATE TABLE statement defined a constraint whose name is identical
to the name generated for a NOT NULL constraint, we'd throw an
(unnecessary) unique key violation error on
pg_constraint_conrelid_contypid_conname_index: this can easily be
avoided by choosing a different name for the NOT NULL constraint.

Fix by passing the constraint names already created by
AddRelationNewConstraints() to AddRelationNotNullConstraints(), so that
the latter can avoid name collisions with them.

Bug: #19393
Author: Laurenz Albe <[email protected]>
Reported-by: Hüseyin Demir <[email protected]>
Backpatch-through: 18
Discussion: https://postgr.es/m/[email protected]

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0eeffd31bf9bb73446387cd7eebbbf43148aa281

Modified Files
--------------
src/backend/catalog/heap.c                 |  8 +++++---
src/backend/commands/tablecmds.c           | 18 ++++++++++++++----
src/include/catalog/heap.h                 |  3 ++-
src/test/regress/expected/create_table.out |  6 ++++++
src/test/regress/sql/create_table.sql      |  7 +++++++
5 files changed, 34 insertions(+), 8 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Avoid name collision with NOT NULL constraints
@ 2026-02-21 11:25 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Álvaro Herrera @ 2026-02-21 11:25 UTC (permalink / raw)
  To: [email protected]

Avoid name collision with NOT NULL constraints

If a CREATE TABLE statement defined a constraint whose name is identical
to the name generated for a NOT NULL constraint, we'd throw an
(unnecessary) unique key violation error on
pg_constraint_conrelid_contypid_conname_index: this can easily be
avoided by choosing a different name for the NOT NULL constraint.

Fix by passing the constraint names already created by
AddRelationNewConstraints() to AddRelationNotNullConstraints(), so that
the latter can avoid name collisions with them.

Bug: #19393
Author: Laurenz Albe <[email protected]>
Reported-by: Hüseyin Demir <[email protected]>
Backpatch-through: 18
Discussion: https://postgr.es/m/[email protected]

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8d9a97e0bb6d820dac553848f0d5d8cc3f3e219d

Modified Files
--------------
src/backend/catalog/heap.c                 |  8 +++++---
src/backend/commands/tablecmds.c           | 18 ++++++++++++++----
src/include/catalog/heap.h                 |  3 ++-
src/test/regress/expected/create_table.out |  6 ++++++
src/test/regress/sql/create_table.sql      |  7 +++++++
5 files changed, 34 insertions(+), 8 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-02-21 11:25 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-02-21 11:25 pgsql: Avoid name collision with NOT NULL constraints Álvaro Herrera <[email protected]>
2026-02-21 11:25 pgsql: Avoid name collision with NOT NULL constraints Álvaro Herrera <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox