|
9 | 9 | * |
10 | 10 | * |
11 | 11 | * IDENTIFICATION |
12 | | - * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.195 2005/11/30 17:10:19 tgl Exp $ |
| 12 | + * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.196 2005/12/06 16:50:36 tgl Exp $ |
13 | 13 | * |
14 | 14 | *------------------------------------------------------------------------- |
15 | 15 | */ |
@@ -1357,50 +1357,40 @@ find_clauses_for_join(PlannerInfo *root, RelOptInfo *rel, |
1357 | 1357 | Relidsouter_relids,boolisouterjoin) |
1358 | 1358 | { |
1359 | 1359 | List*clause_list=NIL; |
1360 | | -booljfound= false; |
1361 | 1360 | Relidsjoin_relids; |
1362 | 1361 | ListCell*l; |
1363 | 1362 |
|
1364 | | -/* |
1365 | | - * We can always use plain restriction clauses for the rel. We scan these |
1366 | | - * first because we want them first in the clause list for the convenience |
1367 | | - * of remove_redundant_join_clauses, which can never remove non-join |
1368 | | - * clauses and hence won't be able to get rid of a non-join clause if it |
1369 | | - * appears after a join clause it is redundant with. |
1370 | | - */ |
1371 | | -foreach(l,rel->baserestrictinfo) |
1372 | | -{ |
1373 | | -RestrictInfo*rinfo= (RestrictInfo*)lfirst(l); |
1374 | | - |
1375 | | -/* Can't use pushed-down clauses in outer join */ |
1376 | | -if (isouterjoin&&rinfo->is_pushed_down) |
1377 | | -continue; |
1378 | | -clause_list=lappend(clause_list,rinfo); |
1379 | | -} |
1380 | | - |
1381 | 1363 | /* Look for joinclauses that are usable with given outer_relids */ |
1382 | 1364 | join_relids=bms_union(rel->relids,outer_relids); |
1383 | 1365 |
|
1384 | 1366 | foreach(l,rel->joininfo) |
1385 | 1367 | { |
1386 | 1368 | RestrictInfo*rinfo= (RestrictInfo*)lfirst(l); |
1387 | 1369 |
|
1388 | | -/* Can't use pushed-down clauses in outer join */ |
| 1370 | +/* Can't use pushed-downjoinclauses in outer join */ |
1389 | 1371 | if (isouterjoin&&rinfo->is_pushed_down) |
1390 | 1372 | continue; |
1391 | 1373 | if (!bms_is_subset(rinfo->required_relids,join_relids)) |
1392 | 1374 | continue; |
1393 | 1375 |
|
1394 | 1376 | clause_list=lappend(clause_list,rinfo); |
1395 | | -jfound= true; |
1396 | 1377 | } |
1397 | 1378 |
|
1398 | 1379 | bms_free(join_relids); |
1399 | 1380 |
|
1400 | 1381 | /* if no join clause was matched then forget it, per comments above */ |
1401 | | -if (!jfound) |
| 1382 | +if (clause_list==NIL) |
1402 | 1383 | returnNIL; |
1403 | 1384 |
|
| 1385 | +/* |
| 1386 | + * We can also use any plain restriction clauses for the rel. We put |
| 1387 | + * these at the front of the clause list for the convenience of |
| 1388 | + * remove_redundant_join_clauses, which can never remove non-join clauses |
| 1389 | + * and hence won't be able to get rid of a non-join clause if it appears |
| 1390 | + * after a join clause it is redundant with. |
| 1391 | + */ |
| 1392 | +clause_list=list_concat(list_copy(rel->baserestrictinfo),clause_list); |
| 1393 | + |
1404 | 1394 | /* |
1405 | 1395 | * We may now have clauses that are known redundant. Get rid of 'em. |
1406 | 1396 | */ |
|