pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Xiong He <iihero@qq.com>
To: John Naylor <john.naylor@enterprisedb.com>
To: Daniel Gustafsson <daniel@yesql.se>
Cc: Pavel Stehule <pavel.stehule@gmail.com>
Cc: pgsql-bugs <pgsql-bugs@lists.postgresql.org>
Subject: Re: About the function current_user
Date: Mon, 20 Mar 2023 17:35:29 +0800
Message-ID: <tencent_D9C5CAFCF577ADF7148ED7BFAFD115E48D0A@qq.com> (raw)
In-Reply-To: <CAFBsxsFOHN7xDZ0XHN298NriwXDim3PTPefLt-8sEBWVe+OLaQ@mail.gmail.com>
References: <tencent_AECDFA4FA154BDEBDA5541EA988C8C56BF06@qq.com>
	<CAFj8pRD-_mptStv288kHAPE4UeeJR1cXALioJgG1wNQ_oR-pPQ@mail.gmail.com>
	<89A42BDF-D1C2-4D28-9970-54EA3EF60815@yesql.se>
	<CAFBsxsFOHN7xDZ0XHN298NriwXDim3PTPefLt-8sEBWVe+OLaQ@mail.gmail.com>

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

view thread (9+ messages)  latest in thread

Message-ID: <tencent_D9C5CAFCF577ADF7148ED7BFAFD115E48D0A@qq.com>
Permalink:  ../tencent_D9C5CAFCF577ADF7148ED7BFAFD115E48D0A@qq.com/
Also on:    postgresql.org/message-id/tencent_D9C5CAFCF577ADF7148ED7BFAFD115E48D0A@qq.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: iihero@qq.com, john.naylor@enterprisedb.com, daniel@yesql.se, pavel.stehule@gmail.com
  Subject: Re: About the function current_user
  In-Reply-To: <tencent_D9C5CAFCF577ADF7148ED7BFAFD115E48D0A@qq.com>
  References: <tencent_AECDFA4FA154BDEBDA5541EA988C8C56BF06@qq.com> <CAFj8pRD-_mptStv288kHAPE4UeeJR1cXALioJgG1wNQ_oR-pPQ@mail.gmail.com> <89A42BDF-D1C2-4D28-9970-54EA3EF60815@yesql.se> <CAFBsxsFOHN7xDZ0XHN298NriwXDim3PTPefLt-8sEBWVe+OLaQ@mail.gmail.com> <tencent_D9C5CAFCF577ADF7148ED7BFAFD115E48D0A@qq.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox