| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Svetlana Derevyanko <s(dot)derevyanko(at)postgrespro(dot)ru> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Strict functions with variadic "any" argument bug |
| Date: | 2025-12-06 20:47:59 |
| Message-ID: | 2382304.1765054079@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Svetlana Derevyanko <s(dot)derevyanko(at)postgrespro(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Marcos Magueta | 2025-12-06 23:38:24 | WIP - xmlvalidate implementation from TODO list |
| Previous Message | Tom Lane | 2025-12-06 20:40:25 | Re: Something in our JIT code is screwing up PG_PRINTF_ATTRIBUTE |