Re: BUG #5620: PostgreSQL won't accept the word "user" as a valid column name

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stefan Kaltenbrunner <stefan(at)kaltenbrunner(dot)cc>
Cc: Samuel Marinov <samuel(dot)marinov(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5620: PostgreSQL won't accept the word "user" as a valid column name
Date: 2010-08-14 13:15:40
Message-ID: 7024.1281791740@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Stefan Kaltenbrunner <stefan(at)kaltenbrunner(dot)cc> writes:
> On 08/14/2010 02:14 AM, Samuel Marinov wrote:
>> ERROR: syntax error at or near "user"
>> LINE 1: create table ftp (user varchar, password varchar);

> not sure why you consider this a bug - but "user" is a reserved word in
> PostgreSQL and the SQL-Standard (see
> http://www.postgresql.org/docs/9.0/static/sql-keywords-appendix.html) so
> you would have to quote the keyword like:

> create table ftp ("user" varchar, password varchar);

> in your code - but I would advise against using reserved words at all
> because you will end up having to quote them all over the place in each
> and every query.

Yeah. The reason it's reserved is that per spec, USER is equivalent to
CURRENT_USER, ie it's a built-in function that returns the current login
name. So anytime you forgot and wrote
select user from ...
instead of
select "user" from ...
it would still work and you'd get mysteriously wrong output. You
don't want to go there.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2010-08-14 13:30:49 Re: BUG #5608: array_agg() consumes too much memory
Previous Message Stefan Kaltenbrunner 2010-08-14 08:19:01 Re: BUG #5620: PostgreSQL won't accept the word "user" as a valid column name