Re: exclude constraints with same name?

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: "A(dot)M(dot)" <agentm(at)themactionfaction(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: exclude constraints with same name?
Date: 2010-09-25 00:03:26
Message-ID: 1285373006.5820.17.camel@jdavis-ux.asterdata.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 2010-09-24 at 19:05 -0400, A.M. wrote:
> I found some surprising behavior with the new EXCLUDE constraint in
> 9.0.0- it seems that EXCLUDE constraint names have to be unique across
> tables:
>

That's consistent with UNIQUE constraints. It has to do with whether the
constraint is enforced by an index -- UNIQUE and EXCLUDE are both
enforced by indexes, and CHECK is not.

postgres=# create table a(i int);
CREATE TABLE
postgres=# create table b(i int);
CREATE TABLE
postgres=# alter table a add constraint c1 unique(i);
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "c1" for
table "a"
ALTER TABLE
postgres=# alter table b add constraint c1 unique(i);
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "c1" for
table "b"
ERROR: relation "c1" already exists

I can see how that would be a little confusing, however.

Regards,
Jeff Davis

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sergey Burladyan 2010-09-25 00:41:28 Re: Libpq memory leak
Previous Message Scott Marlowe 2010-09-24 23:11:50 Re: pg 8.4 crashing.