Skip site navigation (1) Skip section navigation (2)

Re: Strange CREATE VIEW behavior??

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: evseenko(at)msiu(dot)ru, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Strange CREATE VIEW behavior??
Date: 2001-06-14 06:37:34
Message-ID: 16780.992500654@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
pgsql-bugs(at)postgresql(dot)org writes:
> View definition: SELECT zz.ff AS "user", zz.ss AS num FROM zz;

> View definition: SELECT zz.ff AS user1, zz.ss AS num FROM zz;

> Why in the first case column has name "user" (with '"') ?

USER is a keyword.  It happens not to be reserved, so you can use it for
an AS name without quoting it, but the view decompiler doesn't want to
take any chances so it quotes it anyway.

It would be correct and 100% safe for Postgres to display these rules
with all identifiers quoted:

View definition: SELECT "zz"."ff" AS "user1", "zz"."ss" AS "num" FROM "zz";

but since that's pretty unreadable, we try to suppress the quotes where
they're not essential.  The decompiler just errs on the side of safety
when it sees that the identifier matches a keyword: rather than trying
to figure out if the keyword is reserved in this particular context,
it just adds the quotes always.

			regards, tom lane

In response to

pgsql-bugs by date

Next:From: Tom LaneDate: 2001-06-14 06:39:31
Subject: Re: Segmentation fault in psql
Previous:From: Stephan SzaboDate: 2001-06-14 06:21:46
Subject: Re: Strange CREATE VIEW behavior??

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group