Re: CHECK constraint names - Mailing list pgsql-hackers

From Stephan Szabo
Subject Re: CHECK constraint names
Date
Msg-id Pine.BSF.4.21.0012200930450.81979-100000@megazone23.bigpanda.com
Whole thread Raw
In response to CHECK constraint names  ("Christopher Kings-Lynne" <chriskl@familyhealth.com.au>)
List pgsql-hackers
The constraint naming isn't really terribly sensible right now.  The
names generated should be unique within I think schema according to
the spec and I think that should be true even if users name a constraint
such that it would cause a collision (so, if i name a constraint what
an automatic constraint would normally be named, it should be picking
a different automatic name rather than erroring:
create table test( a int constraint test_b check (a>3), b int check
(b<3));
)

Until there's a a good way to look at the defined constraints (a catalog
or something) this probably isn't a big deal, since these should   also
be unique against the other constraints too (pk, unique, fk).


Stephan Szabo
sszabo@bigpanda.com

On Wed, 20 Dec 2000, Christopher Kings-Lynne wrote:

> Hi,
> 
> Is it correct behaviour that unnamed table-level check constraints get the
> names '$1', '$2', '$3', etc. in Postgres 7.0.3???
> 
> Eg, using table constraints:
> ----------------------------
> 
> test=# create table test (temp char(1) NOT NULL, CHECK (temp IN ('M',
> 'F')));
> CREATE
> test=# select rcname from pg_relcheck;
> rcname
> $1
> (1 row)
> 
> And, even worse - I think this has got to be a bug:
> ---------------------------------------------------
> 
> test=# create table test (temp char(1) NOT NULL, CHECK (temp IN ('M',
> 'F')));
> CREATE
> test=# create table test2 (temp char(1) NOT NULL, CHECK (temp IN ('M',
> 'F')));
> CREATE
> test=# select rcname from pg_relcheck;
>  rcname
> --------
>  $1
>  $1
> (2 rows)
> 
> Two constraints with the same name!!!!
> 
> And if you use column constraints:
> ----------------------------------
> 
> test=# create table test (temp char(1) NOT NULL CHECK (temp IN ('M', 'F')));
> CREATE
> test=# select rcname from pg_relcheck;
>   rcname
> -----------
>  test_temp
> (1 row)
> 
> --
> Christopher Kings-Lynne
> Family Health Network (ACN 089 639 243)
> 



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: PostgreSQL pre-7.1 Linux/Alpha Status...
Next
From: "Darren King"
Date:
Subject: RE: Bug in CREATE OPERATOR