Re: Calling PL functions with named parameters - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Calling PL functions with named parameters
Date
Msg-id 27732.1092435745@sss.pgh.pa.us
Whole thread Raw
In response to Calling PL functions with named parameters  (David Fetter <david@fetter.org>)
Responses Re: Calling PL functions with named parameters
Re: Calling PL functions with named parameters
Re: Calling PL functions with named parameters
List 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 by date:

Previous
From: Tom Lane
Date:
Subject: Re: hot spare / log shipping work on
Next
From: Oliver Jowett
Date:
Subject: Re: Calling PL functions with named parameters