8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/optimizer/path/joinrels.c,v 1.80 2006/10/04 00:29:54 momjian Exp $
11
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/joinrels.c,v 1.81 2006/10/24 17:50:22 tgl Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -87,9 +87,9 @@ make_rels_by_joins(PlannerInfo *root, int level, List **joinrels)
87
87
88
88
/*
89
89
* An exception occurs when there is a clauseless join inside a
90
- * construct that restricts join order, i.e., an outer join RHS or
90
+ * construct that restricts join order, i.e., an outer join or
91
91
* an IN (sub-SELECT) construct. Here, the rel may well have join
92
- * clauses against stuff outside the OJ RHS or IN sub-SELECT, but
92
+ * clauses against stuff outside its OJ side or IN sub-SELECT, but
93
93
* the clauseless join *must* be done before we can make use of
94
94
* those join clauses. So do the clauseless join bit.
95
95
*
@@ -331,7 +331,7 @@ make_rels_by_clauseless_joins(PlannerInfo *root,
331
331
/*
332
332
* has_join_restriction
333
333
* Detect whether the specified relation has join-order restrictions
334
- * due to being inside an OJ RHS or an IN (sub-SELECT).
334
+ * due to being inside an outer join or an IN (sub-SELECT).
335
335
*/
336
336
static bool
337
337
has_join_restriction (PlannerInfo * root , RelOptInfo * rel )
@@ -342,8 +342,16 @@ has_join_restriction(PlannerInfo *root, RelOptInfo *rel)
342
342
{
343
343
OuterJoinInfo * ojinfo = (OuterJoinInfo * ) lfirst (l );
344
344
345
+ /* ignore full joins --- other mechanisms preserve their ordering */
346
+ if (ojinfo -> is_full_join )
347
+ continue ;
348
+ /* anything inside the RHS is definitely restricted */
345
349
if (bms_is_subset (rel -> relids , ojinfo -> min_righthand ))
346
350
return true;
351
+ /* if it's a proper subset of the LHS, it's also restricted */
352
+ if (bms_is_subset (rel -> relids , ojinfo -> min_lefthand ) &&
353
+ !bms_equal (rel -> relids , ojinfo -> min_lefthand ))
354
+ return true;
347
355
}
348
356
349
357
foreach (l , root -> in_info_list )
0 commit comments