pgsql: Fix another cause of "wrong varnullingrels" planner failures.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix another cause of "wrong varnullingrels" planner failures.
Date: 2023-06-20 15:10:07
Message-ID: E1qBcze-002k8s-PI@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2023-06-20 17:15:43 pgsql: docs: adjust tag indenting and add MERGE mention
Previous Message Tom Lane 2023-06-20 14:30:05 pgsql: Don't include outer join relids in lateral_relids bitmapsets.