Re: Two constraints with the same name not always allowed
Andrew Gierth <andrew@tao11.riddles.org.uk>
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: André Hänsel <andre@webkr.de>
Cc: <pgsql-bugs@postgresql.org>
Date: 2018-09-02T13:22:56Z
Lists: pgsql-bugs
>>>>> "André" == André Hänsel <andre@webkr.de> writes: André> Case 2: André> CREATE TABLE t(c integer); André> ALTER TABLE t ADD CONSTRAINT foo CHECK(c > 1); André> ALTER TABLE t ADD CONSTRAINT foo UNIQUE(c); André> -> Creates two constraints, both called "foo". I'd call _that_ a bug, myself - having two constraints on a table with the same name potentially messes up a lot of automated maintenance operations. André> In cases where two constraints with the same name are created, André> an "ALTER TABLE t DROP CONSTRAINT ..." drops the UNIQUE first. André> Issuing the ALTER TABLE a second time then drops the CHECK. I think that's purely an artifact of what order an index scan on pg_constraint_conrelid_index finds the constraints. -- Andrew (irc:RhodiumToad)
Commits
-
Fully enforce uniqueness of constraint names.
- fb466d7b5dbe 11.0 landed
- 17b7c302b5fc 12.0 landed