Fix expr_is_nonnullable() for IS DISTINCT FROM Commit c8d2f68cc taught expr_is_nonnullable() to treat a DistinctExpr as never returning NULL. That is wrong: when neither input is NULL, the result is NULL if the underlying equality operator returns NULL, which nothing forbids. This could lead to wrong query results.
To fix, remove the DistinctExpr case, along with its test case. While at it, test the relkind before calling has_subclass() in var_is_nonnullable(), to avoid a useless syscache lookup for partitioned tables. Reported-by: Robert Haas <[email protected]> Author: Richard Guo <[email protected]> Discussion: https://postgr.es/m/ca+tgmoalcsmc9wejr1yo1x1swzjx1t4xxhj0sjzh8xztmn9...@mail.gmail.com Backpatch-through: 19 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/5690aaa92cad8d34e769b973eb5ade856e3a468a Modified Files -------------- src/backend/optimizer/util/clauses.c | 12 ++---------- src/test/regress/expected/predicate.out | 10 ---------- src/test/regress/sql/predicate.sql | 4 ---- 3 files changed, 2 insertions(+), 24 deletions(-)
