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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #5620: PostgreSQL won't accept the word "user" as a valid column name
Дата
Msg-id 7024.1281791740@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: BUG #5620: PostgreSQL won't accept the word "user" as a valid column name  (Stefan Kaltenbrunner <stefan@kaltenbrunner.cc>)
Список pgsql-bugs
Stefan Kaltenbrunner <stefan@kaltenbrunner.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

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Stefan Kaltenbrunner
Дата:
Сообщение: Re: BUG #5620: PostgreSQL won't accept the word "user" as a valid column name
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #5608: array_agg() consumes too much memory