Re: Is current_user a function ?

Lists: pgsql-hackers
From: Masaru Sugawara <rk73(at)sea(dot)plala(dot)or(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Is current_user a function ?
Date: 2002-11-28 16:31:47
Message-ID: 20021129010833.1CFB.RK73@sea.plala.or.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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)


From: Rod Taylor <rbt(at)rbt(dot)ca>
To: Masaru Sugawara <rk73(at)sea(dot)plala(dot)or(dot)jp>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Is current_user a function ?
Date: 2002-11-28 16:34:49
Message-ID: 1038501288.54963.16.camel@jester
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Force the system to use it as a function.

select "current_user"();

On Thu, 2002-11-28 at 11:31, Masaru Sugawara wrote:
> 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 majordomo(at)postgresql(dot)org
--
Rod Taylor <rbt(at)rbt(dot)ca>


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Masaru Sugawara <rk73(at)sea(dot)plala(dot)or(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Is current_user a function ?
Date: 2002-11-28 22:20:59
Message-ID: 16577.1038522059@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Masaru Sugawara <rk73(at)sea(dot)plala(dot)or(dot)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


From: Masaru Sugawara <rk73(at)sea(dot)plala(dot)or(dot)jp>
To: Rod Taylor <rbt(at)rbt(dot)ca>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Is current_user a function ?
Date: 2002-11-29 12:16:23
Message-ID: 20021129175301.5664.RK73@sea.plala.or.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 28 Nov 2002 11:34:49 -0500
Rod Taylor <rbt(at)rbt(dot)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 <tgl(at)sss(dot)pgh(dot)pa(dot)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