fixing variadic parameters for type "ANY" - Mailing list pgsql-hackers

From Pavel Stehule
Subject fixing variadic parameters for type "ANY"
Date
Msg-id CAFj8pRAsPJvDG2MQ6oJ=AO+zjzj6xFhibzDtHfxeyrSEau1AbQ@mail.gmail.com
Whole thread Raw
List 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



pgsql-hackers by date:

Previous
From: Daniel Bausch
Date:
Subject: Re: State of the on-disk bitmap index
Next
From: Magnus Hagander
Date:
Subject: Re: Proof of concept: standalone backend with full FE/BE protocol