Commit fdd48b18 authored by Tom Lane's avatar Tom Lane

Ooops ... make_outerjoininfo wasn't actually enforcing the join order

restrictions specified for semijoins in optimizer/README, to wit that
you can't reassociate outer joins into or out of the RHS of a semijoin.
Per report from Heikki.
parent 223431cb
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.152 2009/05/06 20:31:18 tgl Exp $ * $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.153 2009/05/07 20:13:09 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -654,7 +654,8 @@ make_outerjoininfo(PlannerInfo *root, ...@@ -654,7 +654,8 @@ make_outerjoininfo(PlannerInfo *root,
* lower join's RHS and the lower OJ's join condition is strict, we * lower join's RHS and the lower OJ's join condition is strict, we
* can interchange the ordering of the two OJs; otherwise we must add * can interchange the ordering of the two OJs; otherwise we must add
* lower OJ's full syntactic relset to min_righthand. Here, we must * lower OJ's full syntactic relset to min_righthand. Here, we must
* preserve ordering anyway if the lower OJ is an antijoin. * preserve ordering anyway if either the current join is a semijoin,
* or the lower OJ is an antijoin.
* *
* Here, we have to consider that "our join condition" includes any * Here, we have to consider that "our join condition" includes any
* clauses that syntactically appeared above the lower OJ and below * clauses that syntactically appeared above the lower OJ and below
...@@ -670,6 +671,7 @@ make_outerjoininfo(PlannerInfo *root, ...@@ -670,6 +671,7 @@ make_outerjoininfo(PlannerInfo *root,
if (bms_overlap(right_rels, otherinfo->syn_righthand)) if (bms_overlap(right_rels, otherinfo->syn_righthand))
{ {
if (bms_overlap(clause_relids, otherinfo->syn_righthand) || if (bms_overlap(clause_relids, otherinfo->syn_righthand) ||
jointype == JOIN_SEMI ||
otherinfo->jointype == JOIN_ANTI || otherinfo->jointype == JOIN_ANTI ||
!otherinfo->lhs_strict || otherinfo->delay_upper_joins) !otherinfo->lhs_strict || otherinfo->delay_upper_joins)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment