Skip to content

Commit fdd48b1

Browse files
committed
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.
1 parent 223431c commit fdd48b1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/backend/optimizer/plan/initsplan.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.152 2009/05/06 20:31:18 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.153 2009/05/07 20:13:09 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -654,7 +654,8 @@ make_outerjoininfo(PlannerInfo *root,
654654
* lower join's RHS and the lower OJ's join condition is strict, we
655655
* can interchange the ordering of the two OJs; otherwise we must add
656656
* lower OJ's full syntactic relset to min_righthand. Here, we must
657-
* preserve ordering anyway if the lower OJ is an antijoin.
657+
* preserve ordering anyway if either the current join is a semijoin,
658+
* or the lower OJ is an antijoin.
658659
*
659660
* Here, we have to consider that "our join condition" includes any
660661
* clauses that syntactically appeared above the lower OJ and below
@@ -670,6 +671,7 @@ make_outerjoininfo(PlannerInfo *root,
670671
if (bms_overlap(right_rels, otherinfo->syn_righthand))
671672
{
672673
if (bms_overlap(clause_relids, otherinfo->syn_righthand) ||
674+
jointype == JOIN_SEMI ||
673675
otherinfo->jointype == JOIN_ANTI ||
674676
!otherinfo->lhs_strict || otherinfo->delay_upper_joins)
675677
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy