From: Xiong He <iihero@qq.com>
To: Daniel Gustafsson <daniel@yesql.se>
To: 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 16:56:44 +0800
Message-ID: <tencent_7EEB7D854EF5B86B3B057C63F73219FD3308@qq.com> (raw)
In-Reply-To: <89A42BDF-D1C2-4D28-9970-54EA3EF60815@yesql.se>
References: <tencent_AECDFA4FA154BDEBDA5541EA988C8C56BF06@qq.com>
<CAFj8pRD-_mptStv288kHAPE4UeeJR1cXALioJgG1wNQ_oR-pPQ@mail.gmail.com>
<89A42BDF-D1C2-4D28-9970-54EA3EF60815@yesql.se>
Thanks a lot.
And how to understand below result?
postgres=# select current_database();
current_database
------------------
postgres
(1 row)
postgres=# select current_database;
ERROR: column "current_database" does not exist
LINE 1: select current_database;
------------------ Original ------------------
From: "Daniel Gustafsson" <daniel@yesql.se>;
Date: Mon, Mar 20, 2023 04:16 PM
To: "Pavel Stehule"<pavel.stehule@gmail.com>;
Cc: "Xiong He"<iihero@qq.com>;"pgsql-bugs"<pgsql-bugs@lists.postgresql.org>;
Subject: Re: About the function current_user
> On 20 Mar 2023, at 08:05, Pavel Stehule <pavel.stehule@gmail.com> wrote:
> po 20. 3. 2023 v 8:01 odesÃlatel Xiong He <iihero@qq.com <mailto:iihero@qq.com>> napsal:
> why current_user() is not recognized?
>
> this is not real function - it is pseudo constant
>
> The real function in postgres has a record in the pg_proc table.
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."
Given that current_schema and other current_xx functions accept parenthesis
it's easy to understand the confusion though.
--
Daniel Gustafsson
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, daniel@yesql.se, pavel.stehule@gmail.com
Subject: Re: About the function current_user
In-Reply-To: <tencent_7EEB7D854EF5B86B3B057C63F73219FD3308@qq.com>
References: <tencent_AECDFA4FA154BDEBDA5541EA988C8C56BF06@qq.com> <CAFj8pRD-_mptStv288kHAPE4UeeJR1cXALioJgG1wNQ_oR-pPQ@mail.gmail.com> <89A42BDF-D1C2-4D28-9970-54EA3EF60815@yesql.se> <tencent_7EEB7D854EF5B86B3B057C63F73219FD3308@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