Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is current_user a function ?

0 views
Skip to first unread message

Masaru Sugawara

unread,
Nov 28, 2002, 11:30:13 AM11/28/02
to
Hi,

As for some current_*** functions, "select current_user;" seems to
work, but "select current_user();" doesn't . Though current_user is
defined as one of functions, why does such an error occur ?

renew=# select current_user();
ERROR: parser: parse error at or near "(" at character 20


Regards,
Masaru Sugawara


renew=# \df
List of functions
Result data type | Schema | Name | Argument data types
---------------------+------------+-----------------------+-----------
...
name | pg_catalog | current_database |
name | pg_catalog | current_schema |
name[] | pg_catalog | current_schemas | boolean
text | pg_catalog | current_setting | text
name | pg_catalog | current_user |
...


renew=# select current_user();
ERROR: parser: parse error at or near "(" at character 20

renew=# select current_database();
current_database
------------------
renew
(1 row)

renew=# select current_schema();
current_schema
----------------
public
(1 row)

renew=# select current_schema(true);
current_schemas
---------------------
{pg_catalog,postgres,public}
(1 row)

renew=# select current_schema(false);
current_schemas
---------------------
{postgres,public}
(1 row)

renew=# select current_setting('search_path');
current_setting
-----------------
$user,public
(1 row)

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majo...@postgresql.org

Rod Taylor

unread,
Nov 28, 2002, 11:34:02 AM11/28/02
to
Force the system to use it as a function.

select "current_user"();

--
Rod Taylor <r...@rbt.ca>


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majo...@postgresql.org so that your
message can get through to the mailing list cleanly

Tom Lane

unread,
Nov 28, 2002, 5:21:02 PM11/28/02
to
Masaru Sugawara <rk...@sea.plala.or.jp> writes:
> As for some current_*** functions, "select current_user;" seems to
> work, but "select current_user();" doesn't .

Complain to the SQL spec authors --- they mandated this peculiar keyword
syntax for what is really a function call.

regards, tom lane

Masaru Sugawara

unread,
Nov 29, 2002, 7:15:22 AM11/29/02
to
On 28 Nov 2002 11:34:49 -0500
Rod Taylor <r...@rbt.ca> wrote:

> Force the system to use it as a function.
> select "current_user"();


On Thu, 28 Nov 2002 17:20:59 -0500
Tom Lane <t...@sss.pgh.pa.us> wrote:

> > As for some current_*** functions, "select current_user;" seems to
> > work, but "select current_user();" doesn't .
>
> Complain to the SQL spec authors --- they mandated this peculiar keyword
> syntax for what is really a function call.


Since current_user() can be used in 7.2, I have thought it would work in 7.3 too.
I now understand it doesn't work any more -- as well, session_user(), user(),
current_date(), current_time(), current_timestamp() and etc.


Thank you, Rod and Tom.

Regards,
Masaru Sugawara


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majo...@postgresql.org)

0 new messages