Re: variadic flag doesn't work with "any" type - Mailing list pgsql-bugs

From Pavel Stehule
Subject Re: variadic flag doesn't work with "any" type
Date
Msg-id AANLkTinU-jsNCiL9XUgnfatKZTixvSxWeG1N35XBfR2S@mail.gmail.com
Whole thread Raw
In response to Re: variadic flag doesn't work with "any" type  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: variadic flag doesn't work with "any" type  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
2010/12/9 Tom Lane <tgl@sss.pgh.pa.us>:
> Pavel Stehule <pavel.stehule@gmail.com> writes:
>> There is missing expansion for variadic parameter from any array to
>> real parameters when variadic type is "any".
>
> That's not a bug, it's intentional. =C2=A0Variadic any is intended to let=
 the
> C function accept any old parameter list. =C2=A0We should not assume that=
 we
> should do something special with a parameter that happens to be an array.
>
> Possibly variadic anyarray will do what you are after.

I didn't explain it well, sorry

so I have a function foo(variadic "any")

usual calling like foo(10,20) or foo('a',10) working perfectly. But I
have a problem with call with VARIADIC keyword

like foo(VARIADIC ARRAY[10,20]) or foo(VARIADIC ARRAY['a','10']).

Keyword VARIADIC is allowed, and this a calling doesn't raise any
error. But there isn't transformation to standard parameters. It's in
negation to other than "any" types. And because parser doesn't expand
array to parameters and just ignore VARIADIC keyword I am must not fix
it inside custom function.

so:

   FUNCTION foo(VARIADIC text[])
            -------- CALL foo(10,20,20) ---> real call
foo(ARRAY['10','20','20']);
            -------- CALL foo (VARIADIC ARRAY['10','20','20']) --->
real call foo(ARRAY['10','20','20'])

-- same mechanism should be for "any" type - in reverse order

FUNCTION foo(VARIADIC "any")
             -------- CALL foo(10,20,20)  ---> real call foo(10,20,20);
             -------- CALL foo(VARIADIC ARRAY[10,20,20]) ---> real
call foo(10,20,20) -- but it doesn't work now.

Pavel



>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0regards, tom lane
>

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: variadic flag doesn't work with "any" type
Next
From: Tom Lane
Date:
Subject: Re: variadic flag doesn't work with "any" type