pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix expr_is_nonnullable() for IS DISTINCT FROM
2+ messages / 1 participants
[nested] [flat]

* pgsql: Fix expr_is_nonnullable() for IS DISTINCT FROM
@ 2026-10-10 01:53  Richard Guo <rguo@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Richard Guo @ 2026-10-10 01:53 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Fix expr_is_nonnullable() for IS DISTINCT FROM
@ 2026-10-10 01:53  Richard Guo <rguo@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Richard Guo @ 2026-10-10 01:53 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-10-10 01:53 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-10-10 01:53 pgsql: Fix expr_is_nonnullable() for IS DISTINCT FROM Richard Guo <rguo@postgresql.org>
2026-10-10 01:53 pgsql: Fix expr_is_nonnullable() for IS DISTINCT FROM Richard Guo <rguo@postgresql.org>

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