pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedFunctions vs. Columns?????
4+ messages / 4 participants
[nested] [flat]
* Functions vs. Columns?????
@ 2000-02-16 02:00 Byron Nikolaidis <byron.nikolaidis@home.com>
0 siblings, 3 replies; 4+ messages in thread
From: Byron Nikolaidis @ 2000-02-16 02:00 UTC (permalink / raw)
To: pgsql-interfaces
Hi,
I have a question as to how postgres handles some built-in functions,
for example:
Works Doesn't Work
------ ------------
select now(); select now;
select current_date; select current_date();
It seems that there should be some consistency here in the use of
parenthesis. I don't really know how these things are handled on the
backend, but it seems that parenthesis are the more correct way, or at
least both should be allowed.
Any thoughts?
Byron
^ permalink raw reply [nested|flat] 4+ messages in thread
* RE: [INTERFACES] Functions vs. Columns?????
@ 2000-02-16 03:09 Hiroshi Inoue <Inoue@tpf.co.jp>
parent: Byron Nikolaidis <byron.nikolaidis@home.com>
2 siblings, 0 replies; 4+ messages in thread
From: Hiroshi Inoue @ 2000-02-16 03:09 UTC (permalink / raw)
To: Byron Nikolaidis <byron.nikolaidis@home.com>; +Cc: pgsql-interfaces
> -----Original Message-----
> From: owner-pgsql-interfaces@postgreSQL.org
> [mailto:owner-pgsql-interfaces@postgreSQL.org]On Behalf Of Byron
> Nikolaidis
>
> Hi,
>
> I have a question as to how postgres handles some built-in functions,
> for example:
>
> Works Doesn't Work
> ------ ------------
> select now(); select now;
> select current_date; select current_date();
>
> It seems that there should be some consistency here in the use of
> parenthesis. I don't really know how these things are handled on the
> backend, but it seems that parenthesis are the more correct way, or at
> least both should be allowed.
>
> Any thoughts?
>
Parenthesis are needed in order to call functions in PostgreSQL.
current_date isn't a built-in function of PostgreSQL.
It's an SQL standard function and it's a special work of PostgreSQL
parser to change current_date to call another built-in function.
Regards.
Hiroshi Inoue
Inoue@tpf.co.jp
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [INTERFACES] Functions vs. Columns?????
@ 2000-02-16 05:12 Tom Lane <tgl@sss.pgh.pa.us>
parent: Byron Nikolaidis <byron.nikolaidis@home.com>
2 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2000-02-16 05:12 UTC (permalink / raw)
To: Byron Nikolaidis <byron.nikolaidis@home.com>; +Cc: pgsql-interfaces
Byron Nikolaidis <byron.nikolaidis@home.com> writes:
> Works Doesn't Work
> ------ ------------
> select now(); select now;
> select current_date; select current_date();
> It seems that there should be some consistency here in the use of
> parenthesis.
Consistency? Who needs consistency ;-) ?
What you're seeing here is the conflict of two cultures. The SQL92
standard mandates a keyword CURRENT_DATE, with *no* parentheses,
as the way to get the current date. now() comes out of the Berkeley
Postquel code, which inherits from an academic tradition that doesn't
like inventing reserved words without need, and also thinks that
things that look like constants ought to *be* constants. The way
to resolve that tension, in academese, is to invent parameterless
functions. But the folks who wrote the SQL92 spec seem to have been
raised on COBOL, which never met a reserved word it didn't like.
Anyway, Postgres supports both the SQL92 notation and the notation
we inherited from Postquel. I don't think that adding with-or-
without-parentheses-take-your-pick-for-both syntax freedom would be
a step forward... that path leads to way too many traps for the
unwary programmer.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [INTERFACES] Functions vs. Columns?????
@ 2000-02-16 06:04 Thomas Lockhart <lockhart@alumni.caltech.edu>
parent: Byron Nikolaidis <byron.nikolaidis@home.com>
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Lockhart @ 2000-02-16 06:04 UTC (permalink / raw)
To: Byron Nikolaidis <byron.nikolaidis@home.com>; +Cc: pgsql-interfaces
> It seems that there should be some consistency here in the use of
> parenthesis. I don't really know how these things are handled on the
> backend, but it seems that parenthesis are the more correct way, or at
> least both should be allowed.
The ones without parens are SQL-mandated "constants" which are
translated in the parser front end into function calls (usually with
some other name for historical reasons). Other function calls, like
now(), are really that: function calls.
> Any thoughts?
Uh, sure ;)
- Thomas
--
Thomas Lockhart lockhart@alumni.caltech.edu
South Pasadena, California
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2000-02-16 06:04 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-02-16 02:00 Functions vs. Columns????? Byron Nikolaidis <byron.nikolaidis@home.com>
2000-02-16 03:09 ` Hiroshi Inoue <Inoue@tpf.co.jp>
2000-02-16 05:12 ` Tom Lane <tgl@sss.pgh.pa.us>
2000-02-16 06:04 ` Thomas Lockhart <lockhart@alumni.caltech.edu>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox