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 <[email protected]> Reviewed-by: wenhui qiu <[email protected]> Discussion: https://postgr.es/m/cambws49h9khf+1gwyzd0tyaks6ce-ou+1mbuion3gzsobio...@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(-)
