Re: Information Schema and constraint names not unique

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
Cc: 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-06 16:57:57
Message-ID: 20577.1068137877@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> writes:
> On Thu, Nov 06, 2003 at 11:42:13AM -0500, Tom Lane wrote:
>> I don't have a problem with switching from "$1" to "tablename_$1", or
>> some such, for auto-generated constraint names. But if it's not
>> guaranteed unique, does it really satisfy Philip's concern?

> It certainly _is_ unique within a schema ...
> (But what happens to the constraint name when the table is renamed?)

Exactly. Also consider manually-assigned constraint names that happen
to look like "foo_$n" --- these could cause trouble if table foo is
created later. To make a guarantee of uniqueness would require more
infrastructure than just a simple hack of the constraint name generator
logic.

BTW we also have some problems with auto-generated names for column
constraints; these generally look like "tablename_columnname", and
that's not unique:

regression=# create table foo (f1 int check (f1 > 0) check (f1 < 10));
ERROR: check constraint "foo_f1" already exists

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2003-11-06 17:01:17 Re: Information Schema and constraint names not unique
Previous Message Alvaro Herrera 2003-11-06 16:49:56 Re: Information Schema and constraint names not unique