pgsql: Fix another cause of "wrong varnullingrels" planner failures. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix another cause of "wrong varnullingrels" planner failures.
Date
Msg-id E1qBcze-002k8s-PI@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix another cause of "wrong varnullingrels" planner failures.

I removed the delay_upper_joins mechanism in commit b448f1c8d,
reasoning that it was only needed when we have a single-table
(SELECT ... WHERE) as the immediate RHS child of a left join,
and we could get rid of that by hoisting the WHERE condition into
the parent join's quals.  However that new code missed a case:
we could have "foo LEFT JOIN ((SELECT ... WHERE) LEFT JOIN bar)",
and if the two left joins can be commuted then we now have the
problematic query shape.  We can fix this too easily enough,
by allowing the syntactically-lower left join to pass through
its parent qual location pointer recursively.  That lets
prepjointree.c discard the SELECT by temporarily hoisting the
WHERE condition into the ancestor join's qual.

Per bug #17978 from Zuming Jiang.

Discussion: https://postgr.es/m/17978-12f3d93a55297266@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3af87736bf5d5c7bea086d962afc2bbf4f29279a

Modified Files
--------------
src/backend/optimizer/prep/prepjointree.c | 19 +++++++++++++++----
src/test/regress/expected/join.out        | 31 ++++++++++++++++++++++++++++---
src/test/regress/sql/join.sql             |  8 ++++++++
3 files changed, 51 insertions(+), 7 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Centralize fixups for mismatched nullingrels in nestloop params.
Next
From: Bruce Momjian
Date:
Subject: pgsql: docs: adjust tag indenting and add MERGE mention