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

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: disable bypass of expand variadic for "ANY" variable function, format_array function for formatting with params in array
Date: 2012-09-08 15:57:10
Message-ID: CAFj8pRCo+AEL1bbGs=i0hQBK459MA=u_cm5B7k4xoOsVwUD09A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2012/9/8 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)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

In response to

Browse pgsql-hackers by date

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