pgsql: Optimize BooleanTest with non-nullable input

Started by Richard Guo6 months ago1 messagescomitters
Jump to latest
#1Richard Guo
rguo@postgresql.org

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@gmail.com>
Reviewed-by: Tender Wang <tndrwang@gmail.com>
Discussion: /messages/by-id/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(+)