* get_join_index_paths * Generate index paths using clauses from the specified outer relations. * In addition to generating paths, relids is added to *considered_relids * if not already present. * * Workhorse for consider_index_join_clauses; see notes therein for rationale. * * 'rel', 'index', 'rclauseset', 'jclauseset', 'eclauseset', * 'bitindexpaths', 'considered_relids' as above
| 610 | * one or more outer rels) |
| 611 | */ |
| 612 | static void |
| 613 | get_join_index_paths(PlannerInfo *root, RelOptInfo *rel, |
| 614 | IndexOptInfo *index, |
| 615 | IndexClauseSet *rclauseset, |
| 616 | IndexClauseSet *jclauseset, |
| 617 | IndexClauseSet *eclauseset, |
| 618 | List **bitindexpaths, |
| 619 | Relids relids, |
| 620 | List **considered_relids) |
| 621 | { |
| 622 | IndexClauseSet clauseset; |
| 623 | int indexcol; |
| 624 | |
| 625 | /* If we already considered this relids set, don't repeat the work */ |
| 626 | if (bms_equal_any(relids, *considered_relids)) |
| 627 | return; |
| 628 | |
| 629 | /* Identify indexclauses usable with this relids set */ |
| 630 | MemSet(&clauseset, 0, sizeof(clauseset)); |
| 631 | |
| 632 | for (indexcol = 0; indexcol < index->nkeycolumns; indexcol++) |
| 633 | { |
| 634 | ListCell *lc; |
| 635 | |
| 636 | /* First find applicable simple join clauses */ |
| 637 | foreach(lc, jclauseset->indexclauses[indexcol]) |
| 638 | { |
| 639 | IndexClause *iclause = (IndexClause *) lfirst(lc); |
| 640 | |
| 641 | if (bms_is_subset(iclause->rinfo->clause_relids, relids)) |
| 642 | clauseset.indexclauses[indexcol] = |
| 643 | lappend(clauseset.indexclauses[indexcol], iclause); |
| 644 | } |
| 645 | |
| 646 | /* |
| 647 | * Add applicable eclass join clauses. The clauses generated for each |
| 648 | * column are redundant (cf generate_implied_equalities_for_column), |
| 649 | * so we need at most one. This is the only exception to the general |
| 650 | * rule of using all available index clauses. |
| 651 | */ |
| 652 | foreach(lc, eclauseset->indexclauses[indexcol]) |
| 653 | { |
| 654 | IndexClause *iclause = (IndexClause *) lfirst(lc); |
| 655 | |
| 656 | if (bms_is_subset(iclause->rinfo->clause_relids, relids)) |
| 657 | { |
| 658 | clauseset.indexclauses[indexcol] = |
| 659 | lappend(clauseset.indexclauses[indexcol], iclause); |
| 660 | break; |
| 661 | } |
| 662 | } |
| 663 | |
| 664 | /* Add restriction clauses */ |
| 665 | clauseset.indexclauses[indexcol] = |
| 666 | list_concat(clauseset.indexclauses[indexcol], |
| 667 | rclauseset->indexclauses[indexcol]); |
| 668 | |
| 669 | if (clauseset.indexclauses[indexcol] != NIL) |
no test coverage detected