On Tue, Oct 6, 2026 at 11:50 PM Robert Haas <[email protected]> wrote: > Due to this commit, expr_is_nonnullable() claims that "IS DISTINCT > FROM never returns NULL", but execExprInterp.c's implementation for > EEOP_DISTINCT disagrees; when neither argument is NULL, it returns > null if the underlying operator does. Two Claude-written test cases > illustrating the problem are attached.
Right, thanks for the report. This needs an equality operator that returns NULL for two non-null inputs, which I think is rare in practice, but nothing forbids it, so I agree we should fix it. I think we can just remove the T_DistinctExpr case from expr_is_nonnullable(). An alternative is that we keep it, but only when the operator is a btree equality operator, as such an operator must not return NULL for non-null inputs. This keeps the optimization for nearly all real-world cases. What do you think? - Richard
