@@ -2142,21 +2142,21 @@ remove_self_joins_one_group(PlannerInfo *root, Relids relids)
21422142
21432143while ((r = bms_next_member (relids ,r ))> 0 )
21442144{
2145- RelOptInfo * inner = root -> simple_rel_array [r ];
2145+ RelOptInfo * rrel = root -> simple_rel_array [r ];
21462146
21472147k = r ;
21482148
21492149while ((k = bms_next_member (relids ,k ))> 0 )
21502150{
21512151Relids joinrelids = NULL ;
2152- RelOptInfo * outer = root -> simple_rel_array [k ];
2152+ RelOptInfo * krel = root -> simple_rel_array [k ];
21532153List * restrictlist ;
21542154List * selfjoinquals ;
21552155List * otherjoinquals ;
21562156ListCell * lc ;
21572157bool jinfo_check = true;
2158- PlanRowMark * omark = NULL ;
2159- PlanRowMark * imark = NULL ;
2158+ PlanRowMark * kmark = NULL ;
2159+ PlanRowMark * rmark = NULL ;
21602160List * uclauses = NIL ;
21612161
21622162/* A sanity check: the relations have the same Oid. */
@@ -2196,19 +2196,19 @@ remove_self_joins_one_group(PlannerInfo *root, Relids relids)
21962196
21972197if (rowMark -> rti == k )
21982198{
2199- Assert (imark == NULL );
2200- imark = rowMark ;
2199+ Assert (rmark == NULL );
2200+ rmark = rowMark ;
22012201}
22022202else if (rowMark -> rti == r )
22032203{
2204- Assert (omark == NULL );
2205- omark = rowMark ;
2204+ Assert (kmark == NULL );
2205+ kmark = rowMark ;
22062206}
22072207
2208- if (omark && imark )
2208+ if (kmark && rmark )
22092209break ;
22102210}
2211- if (omark && imark && omark -> markType != imark -> markType )
2211+ if (kmark && rmark && kmark -> markType != rmark -> markType )
22122212continue ;
22132213
22142214/*
@@ -2229,8 +2229,8 @@ remove_self_joins_one_group(PlannerInfo *root, Relids relids)
22292229 * build_joinrel_restrictlist() routine.
22302230 */
22312231restrictlist = generate_join_implied_equalities (root ,joinrelids ,
2232- inner -> relids ,
2233- outer ,NULL );
2232+ rrel -> relids ,
2233+ krel ,NULL );
22342234if (restrictlist == NIL )
22352235continue ;
22362236
@@ -2240,7 +2240,7 @@ remove_self_joins_one_group(PlannerInfo *root, Relids relids)
22402240 * otherjoinquals.
22412241 */
22422242split_selfjoin_quals (root ,restrictlist ,& selfjoinquals ,
2243- & otherjoinquals ,inner -> relid ,outer -> relid );
2243+ & otherjoinquals ,rrel -> relid ,krel -> relid );
22442244
22452245Assert (list_length (restrictlist )==
22462246 (list_length (selfjoinquals )+ list_length (otherjoinquals )));
@@ -2251,17 +2251,17 @@ remove_self_joins_one_group(PlannerInfo *root, Relids relids)
22512251 * degenerate case works only if both sides have the same clause.
22522252 * So doesn't matter which side to add.
22532253 */
2254- selfjoinquals = list_concat (selfjoinquals ,outer -> baserestrictinfo );
2254+ selfjoinquals = list_concat (selfjoinquals ,krel -> baserestrictinfo );
22552255
22562256/*
2257- * Determine if theinner table can duplicate outer rows. We must
2258- *bypass the unique rel cache here since we're possibly using a
2259- *subset of join quals. We can use 'force_cache' == true when all
2260- *join quals are self-join quals. Otherwise, we could end up
2261- *putting false negatives in the cache.
2257+ * Determine if therrel can duplicate outer rows. We must bypass
2258+ * the unique rel cache here since we're possibly using a subset
2259+ * of join quals. We can use 'force_cache' == true when all join
2260+ * quals are self-join quals. Otherwise, we could end up putting
2261+ * false negatives in the cache.
22622262 */
2263- if (!innerrel_is_unique_ext (root ,joinrelids ,inner -> relids ,
2264- outer ,JOIN_INNER ,selfjoinquals ,
2263+ if (!innerrel_is_unique_ext (root ,joinrelids ,rrel -> relids ,
2264+ krel ,JOIN_INNER ,selfjoinquals ,
22652265list_length (otherjoinquals )== 0 ,
22662266& uclauses ))
22672267continue ;
@@ -2277,14 +2277,14 @@ remove_self_joins_one_group(PlannerInfo *root, Relids relids)
22772277 * expressions, or we won't match the same row on each side of the
22782278 * join.
22792279 */
2280- if (!match_unique_clauses (root ,inner ,uclauses ,outer -> relid ))
2280+ if (!match_unique_clauses (root ,rrel ,uclauses ,krel -> relid ))
22812281continue ;
22822282
22832283/*
2284- *We can remove either relation, so remove theinner one in order
2285- *to simplify this loop .
2284+ *Remove rrel ReloptInfo from theplanner structures and the
2285+ *corresponding row mark .
22862286 */
2287- remove_self_join_rel (root ,omark , imark , outer , inner ,restrictlist );
2287+ remove_self_join_rel (root ,kmark , rmark , krel , rrel ,restrictlist );
22882288
22892289result = bms_add_member (result ,r );
22902290