Re: [postgresSQL] [bug] Two or more different types of constraints with same name creates ambiguity while drooping. - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [postgresSQL] [bug] Two or more different types of constraints with same name creates ambiguity while drooping.
Date
Msg-id 18034.1459354328@sss.pgh.pa.us
Whole thread Raw
In response to Re: [postgresSQL] [bug] Two or more different types of constraints with same name creates ambiguity while drooping.  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
Andrew Dunstan <andrew@dunslane.net> writes:
> On 03/30/2016 10:21 AM, Tom Lane wrote:
>> I think that if we want to ensure uniqueness of constraint names, this
>> is really approaching it the wrong way, as it still fails to provide
>> any guarantees (consider concurrent index creation, for example).
>> What we need is a unique index on pg_constraint.

> +1, but does that mean people will have to change constraint names to be 
> compliant before running pg_upgrade?

Yeah, but I think the situation is pretty uncommon, because we already
reject duplicate constraint names in most cases.  As far as I could see
in testing it earlier, these cases all fail already:

* create index constraint when same-named index constraint exists already
* create FK constraint when same-named index constraint exists already
* create FK constraint when same-named FK constraint exists already
* create check constraint when same-named check constraint exists already
* create FK constraint when same-named check constraint exists already

I think that the case Amit's patch plugged, namely create index constraint
when same-named FK or check constraint exists already, may be about the
only missing check.  I just want a unique index to be sure we are covering
all cases.

Note also that because pg_dump prefers to create indexes before FK
constraints (for obvious reasons), I believe that such a case would
fail to dump/restore or pg_upgrade already.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: snapshot too old, configured by time
Next
From: Robert Haas
Date:
Subject: Re: Password identifiers, protocol aging and SCRAM protocol