From: Richard Guo <rguo@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix expr_is_nonnullable() for IS DISTINCT FROM
Date: Sat, 10 Oct 2026 01:53:48 +0000
Message-ID: <E1xFMHU-000000011hP-2jen@gemulon.postgresql.org> (raw)
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
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/f5635c2786af2322e1e21006a13a2c19f68fa591
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(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: rguo@postgresql.org
Subject: Re: pgsql: Fix expr_is_nonnullable() for IS DISTINCT FROM
In-Reply-To: <E1xFMHU-000000011hP-2jen@gemulon.postgresql.org>
References: <E1xFMHU-000000011hP-2jen@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox