pgsql: Optimize BooleanTest with non-nullable input

From: Richard Guo <rguo(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Optimize BooleanTest with non-nullable input
Date: 2026-02-10 01:20:34
Message-ID: E1vpcQc-002BJt-1V@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Optimize BooleanTest with non-nullable input

The BooleanTest construct (IS [NOT] TRUE/FALSE/UNKNOWN) treats a NULL
input as the logical value "unknown". However, when the input is
proven to be non-nullable, this special handling becomes redundant.
In such cases, the construct can be simplified directly to a boolean
expression or a constant.

Author: Richard Guo <guofenglinux(at)gmail(dot)com>
Reviewed-by: Tender Wang <tndrwang(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAMbWs49BMAOWvkdSHxpUDnniqJcEcGq3_8dd_5wTR4xrQY8urA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0aaf0de7fed8555114aca766e9cdc836dad763a3

Modified Files
--------------
src/backend/optimizer/util/clauses.c | 31 +++++++++
src/test/regress/expected/predicate.out | 119 ++++++++++++++++++++++++++++++++
src/test/regress/sql/predicate.sql | 54 +++++++++++++++
3 files changed, 204 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2026-02-10 03:38:06 pgsql: Add information about range type stats to pg_stats_ext_exprs
Previous Message Tom Lane 2026-02-09 21:57:46 pgsql: Stamp 14.21.