Re: Information Schema and constraint names not unique

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Postgresql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Information Schema and constraint names not unique
Date: 2003-11-07 15:26:13
Message-ID: 200311071526.hA7FQDB03784@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Tom Lane wrote:
> >> regression=# create table foo (f1 int check (f1 > 0) check (f1 < 10));
> >> ERROR: check constraint "foo_f1" already exists
>
> > Is this a TODO to fix?
>
> Probably should be. I'd be inclined to try to fix it by generating
> "foo_f1_1", "foo_f1_2", etc until a non-conflicting name is found.
>
> (Note: the reason it's okay to search for a non-conflicting name in this
> context is we only need a lock on the single table in question. It's
> no problem anyway in CREATE TABLE, but can still work in ALTER TABLE.)

Added:

* Allow CREATE TABLE foo (f1 INT CHECK (f1 > 0) CHECK (f1 < 10)) to work
by searching for non-conflicting constraint names, and prefix with table name

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2003-11-07 15:27:25 Re: Performance features the 4th
Previous Message Bruce Momjian 2003-11-07 15:24:04 Re: [HACKERS] Changes to Contributor List