pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: André Hänsel <andre@webkr.de>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Two constraints with the same name not always allowed
Date: Sun, 02 Sep 2018 14:22:56 +0100
Message-ID: <87in3ovy0r.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <0c1001d4428f$0942b430$1bc81c90$@webkr.de>
References: <0c1001d4428f$0942b430$1bc81c90$@webkr.de>

>>>>> "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)




view thread (9+ messages)  latest in thread

Message-ID: <87in3ovy0r.fsf@news-spur.riddles.org.uk>
Permalink:  ../87in3ovy0r.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87in3ovy0r.fsf@news-spur.riddles.org.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, andre@webkr.de
  Subject: Re: Two constraints with the same name not always allowed
  In-Reply-To: <87in3ovy0r.fsf@news-spur.riddles.org.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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