Re: BUG #5258: Unique and foreign key constraints fail on columns with reserved names, but not check constraints

From: Ben Woosley <ben(dot)woosley(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5258: Unique and foreign key constraints fail on columns with reserved names, but not check constraints
Date: 2010-01-04 17:57:42
Message-ID: 627a64321001040957n5ad98b21kb0392744006f1b46@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

These work:
alter table books add constraint books_from_within check (books.from >= 5
and books.from < 11);
alter table books add constraint books_as_whitelist check (books.as in
('whitelisted1','whitelisted2','whitelisted3'));

These don't:
alter table books add constraint books_from_reference foreign key (from)
references authors (id) ;
alter table books add constraint books_as_unique unique (as);

The key being that the former are scoped by table while the latter are
standalone, and the parser doesn't allow scoping. However, the statement
itself has the table information, and AFAIK, these constraints are always
table-specific, so you should be able to check whether the column exists on
the table.

Basically, though the words are reserved, in the scope they're being used,
it seems they're unambiguous as to what use they're taking.

On Mon, Jan 4, 2010 at 5:36 AM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:

> On mån, 2010-01-04 at 03:48 +0000, Ben Woosley wrote:
> > However, unique and foreign key constraints added using the "alter
> > table add
> > constraint" syntax fail on the column name. At this point the
> > statement has
> > enough information (the host table name) to properly identify the
> > column
> > despite the unorthodox name. Alternatively, you could allow the .
> > syntax
> > qualification inside the argument to the constraint.
>
> Example please?
>
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Robert Haas 2010-01-04 18:12:46 Re: BUG #5258: Unique and foreign key constraints fail on columns with reserved names, but not check constraints
Previous Message Tom Lane 2010-01-04 17:55:24 Re: BUG #5259: the table name double