| From: | Richard Guo <rguo(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Relax strictness detection for row-format IS NOT NULL tests |
| Date: | 2026-08-19 01:25:22 |
| Message-ID: | E1wwV3R-000000018cP-1f8z@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Relax strictness detection for row-format IS NOT NULL tests
find_nonnullable_rels() and find_nonnullable_vars() declined to look
through a NullTest with argisrow set, treating row-format IS NOT NULL
as proving nothing. But such a test returns FALSE, not TRUE, both
when the composite datum is NULL and when any of its fields is NULL,
so its truth implies a non-null input just as the plain test does.
That is the only property strictness detection relies on, so the
argisrow restriction can simply be dropped.
This lets "a LEFT JOIN b ... WHERE b IS NOT NULL" reduce to an inner
join, the IS NOT NULL counterpart of the whole-row anti-join reduction
in the preceding commit. make_outerjoininfo() likewise picks up such
tests when it computes join strictness for outer-join ordering.
Row-format tests on composite-type columns now also prove those
columns non-null, which can feed the anti-join proofs.
The stronger implication of a row-format test, that every field of the
row is non-null, remains unexploited: a whole-row Var reported by
find_nonnullable_vars() promises only a non-null datum, since the same
entry can arise from contexts that are merely strict at the datum
level, such as record comparisons.
Author: Richard Guo <guofenglinux(at)gmail(dot)com>
Reviewed-by: wenhui qiu <qiuwenhuifx(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAMbWs49H9khf+1GwyzD0TYaks6cE-OU+1mbUiOn3gZSoBiO7zg@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/f863be3e2dbeed457885a109904b30bb8edcfcde
Modified Files
--------------
src/backend/optimizer/util/clauses.c | 24 ++++++++--
src/test/regress/expected/join.out | 90 ++++++++++++++++++++++++++++++++++++
src/test/regress/sql/join.sql | 39 ++++++++++++++++
3 files changed, 149 insertions(+), 4 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-08-19 02:33:22 | pgsql: Fix relcache reference leak when decoding TRUNCATE |
| Previous Message | Michael Paquier | 2026-08-19 00:52:47 | pgsql: Report single-page checksum failures in pg_stat_database |