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: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5258: Unique and foreign key constraints fail on columns with reserved names, but not check constraints
Date: 2010-01-04 03:48:59
Message-ID: 201001040348.o043mxeS037581@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 5258
Logged by: Ben Woosley
Email address: ben(dot)woosley(at)gmail(dot)com
PostgreSQL version: 8.4.2
Operating system: Mac OS 10.6
Description: Unique and foreign key constraints fail on columns with
reserved names, but not check constraints
Details:

Check constraints successfully accept columns named with reserved words when
they are qualified by table using the . syntax, e.g. "check (mod(table.as,
2) = 0)"

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.

Now, you may say that this is a reserved word and should never be used, but
coming from the Ruby world, where reserved words are only reserved when
they're truly ambiguous, I very much appreciate the freedom of using these
names when it's unambiguous. This particularly so given that keywords are
often chosen for their terseness and overlap with the most appropriate
column name.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David 2010-01-04 06:26:18 BUG #5259: the table name double
Previous Message Craig Ringer 2010-01-03 02:33:04 Re: Failed to run initdb - not resolved bug 5130