predefined functions

Started by Rafal Pietrakover 19 years ago3 messagesgeneral
Jump to latest
#1Rafal Pietrak
rafal@poczta.homelinux.com

Hi,

Is there a reason why both:

SELECT current_user;
SELECT current_database();

are correct, while neither of:

SELECT current_user(); -- syntax at '('
SELECT current_database; -- missing column

is?

This is as of postgres version 8.1.4

--
Rafal Pietrak <rafal@poczta.homelinux.com>

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Rafal Pietrak (#1)
Re: predefined functions

Rafal Pietrak <rafal@poczta.homelinux.com> writes:

Is there a reason why both:
SELECT current_user;
SELECT current_database();
are correct, while neither of:
SELECT current_user(); -- syntax at '('
SELECT current_database; -- missing column
is?

Yeah: current_user (without the parens) is specified by the SQL
standard, but we're not about to adopt such a brain-dead syntax
for any of the functions defined by Postgres itself --- as you
can see from the error messages, allowing a function to be called
without parens creates a word that can't be used as a column name.
So if current_database could be called without parens, we'd actually
be violating the SQL spec by reserving a word that's not reserved
per spec.

Consistency is not one of the hallmarks of the SQL standard :-(

regards, tom lane

#3Rafal Pietrak
rafal@zorro.isa-geek.com
In reply to: Tom Lane (#2)
Re: predefined functions

On Sun, 2006-10-08 at 01:44 -0400, Tom Lane wrote:

Yeah: current_user (without the parens) is specified by the SQL
standard, but we're not about to adopt such a brain-dead syntax
for any of the functions defined by Postgres itself --- as you

I see. One of "committee's work gems" :(

And yet, does that really imply faulting syntax on "current_user()"?

--
-R