Re: Strict functions with variadic "any" argument bug - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Strict functions with variadic "any" argument bug
Date
Msg-id 2382304.1765054079@sss.pgh.pa.us
Whole thread Raw
In response to Strict functions with variadic "any" argument bug  (Svetlana Derevyanko <s.derevyanko@postgrespro.ru>)
List pgsql-hackers
Svetlana Derevyanko <s.derevyanko@postgrespro.ru> writes:
> A few days ago Karina Litskevich noticed that strict function with 
> variadic argument containing a few values, only one of which was NULL, 
> returned NULL without evaluating the function itself. It didn't match 
> with documented behaviour:

> "If a function is declared STRICT with a VARIADIC argument, the 
> strictness check tests that the variadic array as a whole is non-null. 
> The function will still be called if the array has null elements."

> After some digging it turned out that since VARIADIC "any" argument 
> contents are not (can not?) transformed into single array (due to being 
> possibly of different types), the corresponding parameters are checked 
> in evaluate_function individually.

Yeah.  I don't think this is actually a bug, and I don't agree with
trying to make it work.  Since variadic-ANY isn't implemented with
an array, the documentation fragment you quote isn't very on-point.
The actual implementation is that all arguments are checked
individually, and if you change that what is likely to happen is
crashes of variadic-ANY functions that aren't expecting nulls.
If the function author wants to handle nulls, the function should
be marked not-strict.

The documentation about this could use some work, perhaps.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Something in our JIT code is screwing up PG_PRINTF_ATTRIBUTE
Next
From: Marcos Magueta
Date:
Subject: WIP - xmlvalidate implementation from TODO list