Re: About the function current_user

Поиск
Список
Период
Сортировка
От John Naylor
Тема Re: About the function current_user
Дата
Msg-id CAFBsxsFOHN7xDZ0XHN298NriwXDim3PTPefLt-8sEBWVe+OLaQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: About the function current_user  (Daniel Gustafsson <daniel@yesql.se>)
Ответы Re: About the function current_user  ("Xiong He" <iihero@qq.com>)
Список pgsql-bugs

On Mon, Mar 20, 2023 at 3:16 PM Daniel Gustafsson <daniel@yesql.se> wrote:

> The syntax of current_user and current_role are mandated by the SQL
> specification, we have this note in the documentation:
>
>         "current_catalog, current_role, current_schema, current_user,
>         session_user, and user have special syntactic status in SQL: they must
>         be called without trailing parentheses.  In PostgreSQL, parentheses can
>         optionally be used with current_schema, but not with the others."

To further illuminate why the last one is special: It's not a fully-reserved keyword:

$ grep current_ src/include/parser/kwlist.h
PG_KEYWORD("current_catalog", CURRENT_CATALOG, RESERVED_KEYWORD, BARE_LABEL)
PG_KEYWORD("current_date", CURRENT_DATE, RESERVED_KEYWORD, BARE_LABEL)
PG_KEYWORD("current_role", CURRENT_ROLE, RESERVED_KEYWORD, BARE_LABEL)
PG_KEYWORD("current_schema", CURRENT_SCHEMA, TYPE_FUNC_NAME_KEYWORD, BARE_LABEL)
PG_KEYWORD("current_time", CURRENT_TIME, RESERVED_KEYWORD, BARE_LABEL)
PG_KEYWORD("current_timestamp", CURRENT_TIMESTAMP, RESERVED_KEYWORD, BARE_LABEL)
PG_KEYWORD("current_user", CURRENT_USER, RESERVED_KEYWORD, BARE_LABEL)

--
John Naylor
EDB: http://www.enterprisedb.com

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

Предыдущее
От: Daniel Gustafsson
Дата:
Сообщение: Re: About the function current_user
Следующее
От: "Xiong He"
Дата:
Сообщение: Re: About the function current_user