Re: patch: disable bypass of expand variadic for "ANY" variable function, format_array function for formatting with params in array - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: patch: disable bypass of expand variadic for "ANY" variable function, format_array function for formatting with params in array
Date
Msg-id CAFj8pRCo+AEL1bbGs=i0hQBK459MA=u_cm5B7k4xoOsVwUD09A@mail.gmail.com
Whole thread Raw
In response to Re: patch: disable bypass of expand variadic for "ANY" variable function, format_array function for formatting with params in array  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
2012/9/8 Tom Lane <tgl@sss.pgh.pa.us>:
> Pavel Stehule <pavel.stehule@gmail.com> writes:
>> This patch disable bypassing of parameters for variadic function with
>> "ANY" type variadic parameter.
>
> This seems completely silly.  If you think it's broken now (which I
> don't particularly agree with: "does not do what you want in some corner
> cases" is not "broken") then propose a fix.  Breaking it worse is not an
> improvement.

it is broken

format('%s %s", 'Hello', 'World') -- is ok -- case A
format('%s %s', variadic array['Hello', 'World']) -- fails  -- case B

Now, there are no possibility detect from function if there is a A
case or B case.

probably there are three fixes:

a) enhance FunctionCallInfoData by "expand_variadic" field - and then
different behave should be implemented in function,

b) enhance executor to use a updated FmgrInfo for every call of
function. FmgrInfo should be updated every call because fn_nargs can
be changed every call,

c) change mechanism how variadic parameters are passed to variadic
"any" function. Now we use FunctionCallInfoData. We can pass only
pointer to some structure with parameters enhanced about type info.
This mechanism can be same for A case and B case. And we can share
FmgrInfo - because there will be only one real parameter of type
internal. But this change is not compatible with current design. But
is a most simple probably and decrease difference between variadic
"any" functions and others variadic functions.

We can inplement a new datatype "any"[] - and this can be flag for new
implementation and "any" for old implementation. So there should not
be problem with compatibility.

Regards

Pavel


>
>                         regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: patch: disable bypass of expand variadic for "ANY" variable function, format_array function for formatting with params in array
Next
From: Jeff Davis
Date:
Subject: Question about SSI, subxacts, and aborted read-only xacts