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 ([EMAIL PROTECTED]) 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 [EMAIL PROTECTED] so that your >message can get through to the mailing list cleanly > > ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]