Re: About the function current_user

From: Xiong He <iihero(at)qq(dot)com>
To: John Naylor <john(dot)naylor(at)enterprisedb(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: About the function current_user
Date: 2023-03-20 09:35:29
Message-ID: tencent_D9C5CAFCF577ADF7148ED7BFAFD115E48D0A@qq.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Great. So if it's in the PG_KEYWORD list,&nbsp; we should not use current_*()?&nbsp;&nbsp;

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

On Mon, Mar 20, 2023 at 3:16 PM Daniel Gustafsson <daniel(at)yesql(dot)se&gt; wrote:

&gt; The syntax of current_user and current_role are mandated by the SQL
&gt; specification, we have this note in the documentation:
&gt;
&gt; &nbsp; &nbsp; &nbsp; &nbsp; "current_catalog, current_role, current_schema, current_user,
&gt; &nbsp; &nbsp; &nbsp; &nbsp; session_user, and user have special syntactic status in SQL: they must
&gt; &nbsp; &nbsp; &nbsp; &nbsp; be called without trailing parentheses.&nbsp; In PostgreSQL, parentheses can
&gt; &nbsp; &nbsp; &nbsp; &nbsp; 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

In response to

Responses

Browse pgsql-bugs by date

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