Re: WIP: default values for function parameters

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dimitri Fontaine <dfontaine(at)hi-media(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org, Michael Meskes <meskes(at)postgresql(dot)org>, "David E(dot) Wheeler" <david(at)kineticode(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Gregory Stark <stark(at)enterprisedb(dot)com>, Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Subject: Re: WIP: default values for function parameters
Date: 2008-12-13 16:05:53
Message-ID: 26519.1229184353@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dimitri Fontaine <dfontaine(at)hi-media(dot)com> writes:
> Le 13 dc. 08 11:39, Peter Eisentraut a crit :
>> I personally thought that AS was a better idea.

> It seems some people want to be able to overload some default
> parameters (but not others) and at the same time alias them to some
> new label. I'm not sure I understand it all, but it seems an example
> of it would be like:
> SELECT xml_function(a, b: 'foo' AS bar);

> If this is what some people want when all the spare parts are bound
> together, we don't have the option to use AS for both the meanings.

I personally agree that AS seems more SQL-ish, but that's in the eye
of the beholder.

The argument about ambiguity in XMLELEMENT is bogus becase XMLELEMENT
doesn't (and won't) have named parameters. But it is true that
XMLELEMENT is doing something subtly different with the AS clause than
what a named parameter would do; so you could argue that there's a
potential for user confusion there.

However, after looking at the precedent of XMLELEMENT, it's hard to deny
that if the SQL committee ever chose to standardize named parameters,
AS is what they would use. The chances that ":" would become the
standard are negligible --- that's not the sort of syntax they like
to standardize.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2008-12-13 16:09:50 Re: WIP: default values for function parameters
Previous Message Simon Riggs 2008-12-13 13:34:42 Re: Sync Rep: First Thoughts on Code