Re: WIP: default values for function parameters - Mailing list pgsql-hackers

From Robert Haas
Subject Re: WIP: default values for function parameters
Date
Msg-id 603c8f070812120622r64966fdel210187cb728e947@mail.gmail.com
Whole thread Raw
In response to Re: WIP: default values for function parameters  ("David E. Wheeler" <david@kineticode.com>)
List pgsql-hackers
> I'm okay with AS if that's the way it has to be, but what about a colon
> right at the end of the label? A cast is two colons, so no conflict there:
>
>  SELECT foo(1, name: 'bar', quantity: 10);
>
> No doubt I'm missing something…

I'd just like to mention that there are two different cases to
consider here.  One is when you want to pass some optional parameters,
but there are enough of them that it's inconvenient to have them in
some particular order.  This is the case I think you're primarily
catering to here.

The other is when you want the function that gets called to magically
know what name the system would have assigned to the column had the
expression been used in a select list, so that you can write things
xmlify(foo) and get <foo>...data from foo...</foo>.

I think the AS syntax makes a lot of sense for the second one, but not
so much for the first one.  Maybe we need both:

[keyword:] paramater_expression [AS label]

...Robert


pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: WIP: default values for function parameters
Next
From: Tom Lane
Date:
Subject: Re: benchmarking the query planner