Re: now() vs current_user - Mailing list pgsql-general

From Michael Glaesemann
Subject Re: now() vs current_user
Date
Msg-id DF356A91-7364-43D7-A682-CBC1FF68528E@seespotcode.net
Whole thread Raw
In response to now() vs current_user  ("Ottó Havasvölgyi" <havasvolgyi.otto@gmail.com>)
List pgsql-general
On Sep 5, 2007, at 15:31 , Ottó Havasvölgyi wrote:

> What is the cause that "now()" works but "now" does not and

now() is a PostgreSQL extension and not required by the SQL spec. For
the most part, PostgreSQL extensions are functions and look like
them. CURRENT_TIMESTAMP and CURRENT_DATE are required by the SQL spec
and return the appropriate values. IIRC, they call now() with casts,
if appropriate.

> "current_user" works

IIRC, CURRENT_USER (without parens) is required by the SQL spec. It's
most likely implemented in PostgreSQL using the current_user function
and special rules are added to the grammar to allow CURRENT_USER to
be accepted without parens.

> How can I decide if a function
> needs parentheses or not if it has no parameters?

Via the documentation. In general functions require parens. AIUI its
only when they are also SQL keywords that the parens are omitted (as
required by the spec).

Michael Glaesemann
grzm seespotcode net



pgsql-general by date:

Previous
From: "Ottó Havasvölgyi"
Date:
Subject: now() vs current_user
Next
From: "Rodrigo De León"
Date:
Subject: Re: now() vs current_user