pgsql: Fix expr_is_nonnullable() for IS DISTINCT FROM - Mailing list pgsql-committers

From Richard Guo
Subject pgsql: Fix expr_is_nonnullable() for IS DISTINCT FROM
Date
Msg-id E1xFMHU-000000011hR-2rzL@gemulon.postgresql.org
Whole thread
List pgsql-committers
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 <robertmhaas@gmail.com>
Author: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CA+TgmoaLcsmc9weJr1yo1X1SwZJX1t4XXHj0SJzH8XztmN9Hdg@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(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Doc: remove some annoying zero-width spaces.
Next
From: Bruce Momjian
Date:
Subject: pgsql: doc PG 19 relnotes: update to current