Re: Strange CREATE VIEW behavior??

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Strange CREATE VIEW behavior??
Дата
Msg-id 16780.992500654@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Strange CREATE VIEW behavior??  (pgsql-bugs@postgresql.org)
Список pgsql-bugs
pgsql-bugs@postgresql.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

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

Предыдущее
От: Mister X
Дата:
Сообщение: ODBC Interface version 07_01_0005, problem with C++ exceptions
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Segmentation fault in psql