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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-bugs by date

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