Re: now() vs current_user

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: "Ottó Havasvölgyi" <havasvolgyi(dot)otto(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: now() vs current_user
Date: 2007-09-05 20:43:02
Message-ID: DF356A91-7364-43D7-A682-CBC1FF68528E@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rodrigo De León 2007-09-05 20:44:03 Re: now() vs current_user
Previous Message Ottó Havasvölgyi 2007-09-05 20:31:11 now() vs current_user