Re: Column name 'user' not allowed?

From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>, Thomas Mueller <news-exp-dec04(at)tmueller(dot)com>
Subject: Re: Column name 'user' not allowed?
Date: 2004-07-08 16:39:56
Message-ID: 1089304796.30980.560.camel@camel
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 2004-07-08 at 09:35, Stephan Szabo wrote:
> 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(at)tmueller(dot)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.
>

That said, the choice of USER as a column name in phpopenchat is even
more unfortunate. Someone should open a bug report with them and site
the sql spec so that they change the column to a friendlier (and more
compliant) name.

Robert Treat
--
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Marc Slemko 2004-07-08 17:00:21 Re: Enough RAM for entire Database.. cost aside, is this
Previous Message Bruce Momjian 2004-07-08 16:28:50 Re: enable thready safety on Mac OS X 10.3.4