Re: Column name 'user' not allowed? - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Column name 'user' not allowed?
Date
Msg-id 20040708062906.J90613@megazone.bigpanda.com
Whole thread Raw
In response to Re: Column name 'user' not allowed?  (Alberto Cabello Sanchez <alberto@unex.es>)
Responses Re: Column name 'user' not allowed?
List pgsql-general
On Thu, 8 Jul 2004, Alberto Cabello Sanchez wrote:

> On Wed, Jul 07, 2004 at 05:17:08PM -0400, Bill Moran wrote:
> > Thomas Mueller <news-exp-dec04@tmueller.com> wrote:
> > > now I can create the table! I don't see a reason why column name USER
> > > isn't allowed?!
> >
> > Because it's a reserved word in PostgreSQL's SQL syntax.
> >
> > You can also work around this by enclosing the name in quotes.  This also
> > makes the column name case-sensitive though, so you need to be sure that
> > _all_ processes/code/whatever that accesses this table can properly address
> > the column with the proper case.  i.e. if you use "USER" and later try to
> > SELECT user FROM poc_user_account, you'll get an error that the column
> > doesn't exist.
>
> Even worse, you don't get an error at all, but you get your current connection
> username:
>
> alberto=# select user from pg_database;
>  current_user
> --------------
>  alberto
>  alberto
>  alberto
> (3 rows)

Right, because USER effectively means CURRENT_USER (as per the rules in
SQL92 6.2/SQL99 6.3). The choice of having USER be a reserved word which
basically means the same thing as CURRENT_USER by the committee doing the
SQL spec was unfortunate.

pgsql-general by date:

Previous
From:
Date:
Subject: Re: SUBSTRING for a regular expression
Next
From: Richard Huxton
Date:
Subject: Re: unexpected update behavior with temp tables