Re: Two constraints with the same name not always allowed

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: André Hänsel <andre(at)webkr(dot)de>
Cc: <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Two constraints with the same name not always allowed
Date: 2018-09-02 13:22:56
Message-ID: 87in3ovy0r.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

>>>>> "André" == André Hänsel <andre(at)webkr(dot)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)

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2018-09-02 16:38:03 Re: BUG #15361: Add column if not exists create duplicate constraint
Previous Message Stephen Frost 2018-09-02 11:45:15 Re: BUG #15361: Add column if not exists create duplicate constraint