Re: About the function current_user

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

Thanks a lot.&nbsp;
And how to understand below result?&nbsp;

postgres=# select current_database();
&nbsp;current_database
------------------
&nbsp;postgres
(1 row)

postgres=# select current_database;
ERROR:&nbsp; column "current_database" does not exist
LINE 1: select current_database;

------------------&nbsp;Original&nbsp;------------------
From: "Daniel Gustafsson" <daniel(at)yesql(dot)se&gt;;
Date:&nbsp;Mon, Mar 20, 2023 04:16 PM
To:&nbsp;"Pavel Stehule"<pavel(dot)stehule(at)gmail(dot)com&gt;;
Cc:&nbsp;"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

&gt; On 20 Mar 2023, at 08:05, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com&gt; wrote:
&gt; po 20. 3. 2023 v 8:01 odesílatel Xiong He <iihero(at)qq(dot)com <mailto:iihero(at)qq(dot)com&gt;&gt; napsal:

&gt; why current_user() is not recognized?&nbsp;
&gt;
&gt; this is not real function - it is pseudo constant
&gt;
&gt; 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.&nbsp; 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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Uytterhoeven Patrik 2023-03-20 09:10:14 Postgres common repo is missing geos310-3.10.3-1.rhel8.x86_64
Previous Message John Naylor 2023-03-20 08:49:55 Re: About the function current_user