Re: Bug #545: Keyword USER not detected in CREATE VIEW

Поиск
Список
Период
Сортировка
От Darcy Buskermolen
Тема Re: Bug #545: Keyword USER not detected in CREATE VIEW
Дата
Msg-id 3.0.32.20011228084257.01e327b0@mail.ok-connect.com
обсуждение исходный текст
Ответ на Bug #545: Keyword USER not detected in CREATE VIEW  (pgsql-bugs@postgresql.org)
Список pgsql-bugs
This is because user is a "reserved" word.
user is a macro for the function current_user()
Try this SQL:   SELECT user;

It is best to change the table name from user to username;

However it is probably a wise idea for Postgres to emit some sort of error
on the create mentioning the reserved word.


At 11:23 AM 12/28/01 -0500, you wrote:
>Avi Kivity (avi@argo.co.il) reports a bug with a severity of 3
>The lower the number the more severe it is.
>
>Short Description
>Keyword USER not detected in CREATE VIEW
>
>Long Description
>The reserved keyword USER is rejected in CREATE TABLE, as expected:
>
>  avi=> create table x (user varchar);
>  ERROR:  parser: parse error at or near "user"
>
>In my ignorance, however, I tried to create a view with a field named user:
>
>  avi=> create table y (x varchar);
>  CREATE
>  avi=> create view z as select x as user from y;
>  CREATE
>
>Note no error.
>
>  avi=> \d z
>                   View "z"
>   Attribute |       Type        | Modifier
>  -----------+-------------------+----------
>   user      | character varying |
>  View definition: SELECT y.x AS "user" FROM y;
>
>  avi=> insert into y values ('zz');
>  INSERT 43771 1
>  avi=> select user from z;
>   current_user
>  --------------
>   avi
>  (1 row)
>
>Wrong value returned.
>
>  avi=> select "user" from z;
>   user
>  ------
>   zz
>  (1 row)
>
>Correct value returned.
>
>My expected result: an error message in CREATE VIEW
>
>
>Sample Code
>
>
>No file was uploaded with this report
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: if posting/reading through Usenet, please send an appropriate
>subscribe-nomail command to majordomo@postgresql.org so that your
>message can get through to the mailing list cleanly
>
>

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

Предыдущее
От: pgsql-bugs@postgresql.org
Дата:
Сообщение: Bug #545: Keyword USER not detected in CREATE VIEW
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Bug #545: Keyword USER not detected in CREATE VIEW