Thread: Is level a reserved keyword?

Is level a reserved keyword?

From
"Morten W. Petersen"
Date:
We've been running a customer telephone service, and we've been storing
the customers subscription as levels; ie, we have a table, named customer
with the column "level". INSERT and SELECT have worked on this table, just
as they should; but now, after moving between two databases of the same
version, both the psql client, and the pg python adapter complains near
the word "level". Any ideas? Seems like a bug?

Regards, Morten

-------------------------------------------------------------
How to reply to email:
  http://home.sol.no/~vidaandr/news/OBSquoting.html (norsk)
  http://home.sol.no/~vidaandr/news/FAQquoting.html (english)

Who is the bigger fool? The fool or the fool who follows him?


Re: Is level a reserved keyword?

From
"Morten W. Petersen"
Date:
> the word "level". Any ideas? Seems like a bug?

This is PostgreSQL 6.5 btw.

Regards, Morten


Re: Is level a reserved keyword? (FYI)

From
"Morten W. Petersen"
Date:
> > the word "level". Any ideas? Seems like a bug?
>
> This is PostgreSQL 6.5 btw.
>

I found the error. The original (accepting level db) was version 6.5.3,
while the non-accepting was 6.5.0

Regards, Morten


Re: Is level a reserved keyword?

From
Tom Lane
Date:
"Morten W. Petersen" <morten@src.no> writes:
>> the word "level". Any ideas? Seems like a bug?
> This is PostgreSQL 6.5 btw.

> Regards, Morten

Re: Is level a reserved keyword?

From
Tom Lane
Date:
"Morten W. Petersen" <morten@src.no> writes:
> We've been running a customer telephone service, and we've been storing
> the customers subscription as levels; ie, we have a table, named customer
> with the column "level". INSERT and SELECT have worked on this table, just
> as they should; but now, after moving between two databases of the same
> version, both the psql client, and the pg python adapter complains near
> the word "level". Any ideas? Seems like a bug?

LEVEL is a keyword, but it should not be a reserved word, and it's not
in 7.0:

regression=# create table f1 (level int);
CREATE

I believe 6.5 was missing a whole bunch of entries from the parser's
list of keywords-that-can-also-be-column-names, so it doesn't surprise
me that you see this problem in 6.5.

You could update to 7.0 (recommended solution ;-)), or put double
quotes around "level" in all your queries, or rename the column,
or modify src/backend/parser/gram.y to add a production for LEVEL
to the ColId list.

            regards, tom lane

Re: Is level a reserved keyword? (FYI)

From
Peter Eisentraut
Date:
Morten W. Petersen writes:

> > > the word "level". Any ideas? Seems like a bug?
> >
> > This is PostgreSQL 6.5 btw.
> >
>
> I found the error. The original (accepting level db) was version 6.5.3,
> while the non-accepting was 6.5.0

"level", as in `set transaction isolation level serializable', is in
general "subject to being a keyword". It might not be in some versions,
but parsers are so subtle that could be again in the future.


--
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden