fixing variadic parameters for type "ANY"

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: fixing variadic parameters for type "ANY"
Date: 2012-09-05 10:10:17
Message-ID: CAFj8pRAsPJvDG2MQ6oJ=AO+zjzj6xFhibzDtHfxeyrSEau1AbQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

Our customer reported issue with "format" function -
http://archives.postgresql.org/pgsql-bugs/2012-09/msg00011.php.

This issue is related to our implementation of variadic functions -
there are gap in implemented functionality - parameter cannot be
marked as VARIADIC in function call, when variadic parameter is "ANY"
type.

In this case VARIADIC keyword is quietly ignored now, that is bug.

I though about some solution in relation to function format. Sometimes

SELECT format(' a = %s, b = %s', VARIADIC ARRAY[10,20])

can be useful.

But implementation is relative harder - because for type "ANY" we
don't do any magic with parameters - in this case we should to unpack
array and unpacked values should be appended on end of parameter
lists. But it cannot be done, because then function signature cannot
be calculated in analyze time - and it does problems across function
call processing. So I propose enhancing FuncExpr and fmgr_info about
boolean "arrayva" field, that is true, when function should to expand
of variadic parameter by self. Polymorphic functions with "ANY"
parameters should be careful now when it use parameters, so it is not
significant difference to current design.

Regards

Pavel

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2012-09-05 10:27:55 Re: Proof of concept: standalone backend with full FE/BE protocol
Previous Message Daniel Bausch 2012-09-05 09:28:18 Re: State of the on-disk bitmap index