pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Guo <rguo@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Relax strictness detection for row-format IS NOT NULL tests
Date: Wed, 19 Aug 2026 01:25:22 +0000
Message-ID: <E1wwV3R-000000018cP-1f8z@gemulon.postgresql.org> (raw)

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@gmail.com>
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.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(-)



Message-ID: <E1wwV3R-000000018cP-1f8z@gemulon.postgresql.org>
Permalink:  ../E1wwV3R-000000018cP-1f8z@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wwV3R-000000018cP-1f8z@gemulon.postgresql.org

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: rguo@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Relax strictness detection for row-format IS NOT NULL tests
  In-Reply-To: <E1wwV3R-000000018cP-1f8z@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