Re: About the function current_user - Mailing list pgsql-bugs

From Xiong He
Subject Re: About the function current_user
Date
Msg-id tencent_D9C5CAFCF577ADF7148ED7BFAFD115E48D0A@qq.com
Whole thread Raw
In response to Re: About the function current_user  (John Naylor <john.naylor@enterprisedb.com>)
Responses Re: About the function current_user
List pgsql-bugs
Great. So if it's in the PG_KEYWORD list,  we should not use current_*()?  

------------------ Original ------------------
From: "John Naylor" <john.naylor@enterprisedb.com>;
Date: Mon, Mar 20, 2023 04:49 PM
To: "Daniel Gustafsson"<daniel@yesql.se>;
Cc: "Pavel Stehule"<pavel.stehule@gmail.com>;"Xiong He"<iihero@qq.com>;"pgsql-bugs"<pgsql-bugs@lists.postgresql.org>;
Subject: Re: About the function current_user


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 by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: BUG #17774: Assert triggered on brin_minmax_multi.c
Next
From: PG Bug reporting form
Date:
Subject: BUG #17854: nothing provides proj90 >= 9.0.1 needed by postgis33_14-3.3.2-1.rhel8.x86_64