@ -2141,21 +2141,21 @@ remove_self_joins_one_group(PlannerInfo *root, Relids relids)
while ( ( r = bms_next_member ( relids , r ) ) > 0 )
{
RelOptInfo * inner = root - > simple_rel_array [ r ] ;
RelOptInfo * rrel = root - > simple_rel_array [ r ] ;
k = r ;
while ( ( k = bms_next_member ( relids , k ) ) > 0 )
{
Relids joinrelids = NULL ;
RelOptInfo * outer = root - > simple_rel_array [ k ] ;
RelOptInfo * krel = root - > simple_rel_array [ k ] ;
List * restrictlist ;
List * selfjoinquals ;
List * otherjoinquals ;
ListCell * lc ;
bool jinfo_check = true ;
PlanRowMark * o mark = NULL ;
PlanRowMark * i mark = NULL ;
PlanRowMark * k mark = NULL ;
PlanRowMark * r mark = NULL ;
List * uclauses = NIL ;
/* A sanity check: the relations have the same Oid. */
@ -2195,19 +2195,19 @@ remove_self_joins_one_group(PlannerInfo *root, Relids relids)
if ( rowMark - > rti = = k )
{
Assert ( i mark = = NULL ) ;
i mark = rowMark ;
Assert ( r mark = = NULL ) ;
r mark = rowMark ;
}
else if ( rowMark - > rti = = r )
{
Assert ( o mark = = NULL ) ;
o mark = rowMark ;
Assert ( k mark = = NULL ) ;
k mark = rowMark ;
}
if ( omark & & i mark)
if ( kmark & & r mark)
break ;
}
if ( omark & & imark & & o mark- > markType ! = i mark- > markType )
if ( kmark & & rmark & & k mark- > markType ! = r mark- > markType )
continue ;
/*
@ -2228,8 +2228,8 @@ remove_self_joins_one_group(PlannerInfo *root, Relids relids)
* build_joinrel_restrictlist ( ) routine .
*/
restrictlist = generate_join_implied_equalities ( root , joinrelids ,
inner - > relids ,
outer , NULL ) ;
rrel - > relids ,
krel , NULL ) ;
if ( restrictlist = = NIL )
continue ;
@ -2239,7 +2239,7 @@ remove_self_joins_one_group(PlannerInfo *root, Relids relids)
* otherjoinquals .
*/
split_selfjoin_quals ( root , restrictlist , & selfjoinquals ,
& otherjoinquals , inner - > relid , outer - > relid ) ;
& otherjoinquals , rrel - > relid , krel - > relid ) ;
Assert ( list_length ( restrictlist ) = =
( list_length ( selfjoinquals ) + list_length ( otherjoinquals ) ) ) ;
@ -2250,17 +2250,17 @@ remove_self_joins_one_group(PlannerInfo *root, Relids relids)
* degenerate case works only if both sides have the same clause .
* So doesn ' t matter which side to add .
*/
selfjoinquals = list_concat ( selfjoinquals , outer - > baserestrictinfo ) ;
selfjoinquals = list_concat ( selfjoinquals , krel - > baserestrictinfo ) ;
/*
* Determine if the inner table can duplicate outer rows . We must
* bypass the unique rel cache here since we ' re possibly using a
* subset of join quals . We can use ' force_cache ' = = true when all
* join quals are self - join quals . Otherwise , we could end up
* putting false negatives in the cache .
* Determine if the rrel can duplicate outer rows . We must bypass
* the unique rel cache here since we ' re possibly using a subset
* of join quals . We can use ' force_cache ' = = true when all join
* quals are self - join quals . Otherwise , we could end up putting
* false negatives in the cache .
*/
if ( ! innerrel_is_unique_ext ( root , joinrelids , inner - > relids ,
outer , JOIN_INNER , selfjoinquals ,
if ( ! innerrel_is_unique_ext ( root , joinrelids , rrel - > relids ,
krel , JOIN_INNER , selfjoinquals ,
list_length ( otherjoinquals ) = = 0 ,
& uclauses ) )
continue ;
@ -2276,14 +2276,14 @@ remove_self_joins_one_group(PlannerInfo *root, Relids relids)
* expressions , or we won ' t match the same row on each side of the
* join .
*/
if ( ! match_unique_clauses ( root , inner , uclauses , outer - > relid ) )
if ( ! match_unique_clauses ( root , rrel , uclauses , krel - > relid ) )
continue ;
/*
* We can remove either relation , so remove the inner one in order
* to simplify this loop .
* Remove rrel ReloptInfo from the planner structures and the
* corresponding row mark .
*/
remove_self_join_rel ( root , omark , imark , outer , inner , restrictlist ) ;
remove_self_join_rel ( root , kmark , rmark , krel , rrel , restrictlist ) ;
result = bms_add_member ( result , r ) ;