On Sunday, August 29, 2021, PG Bug reporting form <
noreply@postgresql.org> wrote:
It is rather curious that a
simple order affects the type of $1. I would imagine that, as $1 IS NULL has
no type implications, the col = $1 would determine the type of $1.
The system resolves the type of each argument at its first encounter while parsing. It has to make a choice, and since “is null” doesn’t provide any help, it is unable to make a decision. Null “values” are still typed.
This is documented under the PREPARE SQL command reference (the only pure sql way to use numbered parameters) and so is definitely not a bug.
David J.