Re: variadic function support

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: variadic function support
Date: 2008-06-24 02:41:09
Message-ID: 7480.1214275269@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> But if I have
> foo( a text, b int[])
> it looks odd if both these calls are legal:
> foo('a',1,2,3,)
> foo('a',ARRAY[1,2,3])
> which I understand would be the case with the current patch.

Maybe I misunderstand what is supposed to happen, but I believe that
if the function is marked VARIADIC then the second case would in fact
be rejected: the signature of the function for parameter-matching
purposes is text followed by one or more ints, never text and int[].

> I'm also still curious to know how the following would be handled:
> foo(a text[], b text[])

I think a is just text[], full stop. Only the last parameter is
interpreted differently for variadic.

Your point about the syntax is good though. It would be better if
the syntax were like

create function foo (a text, variadic b int[])

or maybe even better

create function foo (a text, variadic b int)

since (a) this makes it much more obvious to the reader what the
function might match, and (b) it leaves the door open for marking
multiple parameters as variadic, if we can figure out what that means.

regards, tom lane

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Andrew Dunstan 2008-06-24 03:42:48 Re: variadic function support
Previous Message Andrew Dunstan 2008-06-24 02:29:48 Re: variadic function support