Re: Calling PL functions with named parameters

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Calling PL functions with named parameters
Дата
Msg-id 27732.1092435745@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Calling PL functions with named parameters  (David Fetter <david@fetter.org>)
Ответы Re: Calling PL functions with named parameters  ("Jim C. Nasby" <decibel@decibel.org>)
Re: Calling PL functions with named parameters  (Oliver Jowett <oliver@opencloud.com>)
Re: Calling PL functions with named parameters  (Andreas Pflug <pgadmin@pse-consulting.de>)
Список pgsql-hackers
David Fetter <david@fetter.org> writes:
> CREATE OR REPLACE FUNCTION foo_func(name TEXT, val INTEGER) AS ...

> SELECT foo_func(val AS 23, name AS 'Name goes here');

I don't think that syntax will work.  You could possibly do it the other
way round:

SELECT foo_func(23 AS val, 'Name goes here' AS name);

which would have some commonality with SELECT's column-labeling syntax
but otherwise seems to have little to recommend it.  Are there any other
vendors supporting such things in SQL, and if so how do they do it?

A bigger issue is how do you see this interacting with resolution of
ambiguous/overloaded function names.

> On a related note, it would also be nice to have default
> parameters and some way to say to use them.

That is fundamentally not ever going to happen, because it blows
overloaded-function resolution out of the water: there is no way to
choose whether "foo(42, 2.5)" matches foo(int, float) or
foo(int, float, something-with-a-default).  Let's try to limit our
attention to something that might actually work.
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: hot spare / log shipping work on
Следующее
От: Oliver Jowett
Дата:
Сообщение: Re: Calling PL functions with named parameters