Sunday, August 17, 2008

Re: [HACKERS] proposal sql: labeled function params

> Actually the most "natural" syntax to me is just f(name=value) similar
> to how UPDATE does it. It has the added benefit of _not_ forcing us to
> make a operator reserved (AFAIK "=" can't be used to define new ops)

The problem with this is that

SELECT foo(a = b)

...is already valid syntax. It means compare a with b and pass the
resulting boolean to foo. I'm almost positive that changing this
would break all kinds of existing code (and probably create a lot of
grammar problems too). It's not an issue with SET because in that
case the "name=" part of the syntax is required rather than optional.

Any other operator you pick is going to have this same problem unless
it's already impossible to use that operator as part of an expression.
For that reason, while I'm not convinced of the value of the feature,
if we're going to support it then ISTM that expr AS label is the way
to go. That also has the advantage of being consistent with the
syntax for table and column aliasing.

...Robert

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

No comments: