Skip site navigation (1) Skip section navigation (2)

Re: CHECK constraint names

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
Cc: Pgsql-Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CHECK constraint names
Date: 2000-12-20 17:36:49
Message-ID: Pine.BSF.4.21.0012200930450.81979-100000@megazone23.bigpanda.com (view raw or flat)
Thread:
Lists: 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(at)bigpanda(dot)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)
> 


In response to

pgsql-hackers by date

Next:From: Darren KingDate: 2000-12-20 17:40:18
Subject: RE: Bug in CREATE OPERATOR
Previous:From: Bruce MomjianDate: 2000-12-20 17:25:31
Subject: Re: [HACKERS] PostgreSQL pre-7.1 Linux/Alpha Status...

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group