diff options
Diffstat (limited to 'src/backend/optimizer/plan')
-rw-r--r-- | src/backend/optimizer/plan/createplan.c | 60 | ||||
-rw-r--r-- | src/backend/optimizer/plan/initsplan.c | 24 | ||||
-rw-r--r-- | src/backend/optimizer/plan/planagg.c | 18 | ||||
-rw-r--r-- | src/backend/optimizer/plan/subselect.c | 6 |
4 files changed, 61 insertions, 47 deletions
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 14f1f1a10f4..f924994480b 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.217 2006/10/04 00:29:54 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.218 2006/12/23 00:43:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -73,7 +73,7 @@ static void fix_indexqual_references(List *indexquals, IndexPath *index_path, List **indexstrategy, List **indexsubtype); static Node *fix_indexqual_operand(Node *node, IndexOptInfo *index, - Oid *opclass); + Oid *opfamily); static List *get_switched_clauses(List *clauses, Relids outerrelids); static List *order_qual_clauses(PlannerInfo *root, List *clauses); static void copy_path_costsize(Plan *dest, Path *src); @@ -113,7 +113,7 @@ static HashJoin *make_hashjoin(List *tlist, static Hash *make_hash(Plan *lefttree); static MergeJoin *make_mergejoin(List *tlist, List *joinclauses, List *otherclauses, - List *mergeclauses, + List *mergeclauses, List *mergefamilies, List *mergestrategies, Plan *lefttree, Plan *righttree, JoinType jointype); static Sort *make_sort(PlannerInfo *root, Plan *lefttree, int numCols, @@ -1540,6 +1540,8 @@ create_mergejoin_plan(PlannerInfo *root, joinclauses, otherclauses, mergeclauses, + best_path->path_mergefamilies, + best_path->path_mergestrategies, outer_plan, inner_plan, best_path->jpath.jointype); @@ -1676,9 +1678,10 @@ fix_indexqual_references(List *indexquals, IndexPath *index_path, RestrictInfo *rinfo = (RestrictInfo *) lfirst(l); Expr *clause; Oid clause_op; - Oid opclass; + Oid opfamily; int stratno; - Oid stratsubtype; + Oid stratlefttype; + Oid stratrighttype; bool recheck; Assert(IsA(rinfo, RestrictInfo)); @@ -1709,11 +1712,11 @@ fix_indexqual_references(List *indexquals, IndexPath *index_path, /* * Now, determine which index attribute this is, change the - * indexkey operand as needed, and get the index opclass. + * indexkey operand as needed, and get the index opfamily. */ linitial(op->args) = fix_indexqual_operand(linitial(op->args), index, - &opclass); + &opfamily); clause_op = op->opno; } else if (IsA(clause, RowCompareExpr)) @@ -1734,20 +1737,20 @@ fix_indexqual_references(List *indexquals, IndexPath *index_path, * For each column in the row comparison, determine which index * attribute this is and change the indexkey operand as needed. * - * Save the index opclass for only the first column. We will - * return the operator and opclass info for just the first column + * Save the index opfamily for only the first column. We will + * return the operator and opfamily info for just the first column * of the row comparison; the executor will have to look up the * rest if it needs them. */ foreach(lc, rc->largs) { - Oid tmp_opclass; + Oid tmp_opfamily; lfirst(lc) = fix_indexqual_operand(lfirst(lc), index, - &tmp_opclass); + &tmp_opfamily); if (lc == list_head(rc->largs)) - opclass = tmp_opclass; + opfamily = tmp_opfamily; } clause_op = linitial_oid(rc->opnos); } @@ -1759,11 +1762,11 @@ fix_indexqual_references(List *indexquals, IndexPath *index_path, /* * Now, determine which index attribute this is, change the - * indexkey operand as needed, and get the index opclass. + * indexkey operand as needed, and get the index opfamily. */ linitial(saop->args) = fix_indexqual_operand(linitial(saop->args), index, - &opclass); + &opfamily); clause_op = saop->opno; } else @@ -1776,15 +1779,18 @@ fix_indexqual_references(List *indexquals, IndexPath *index_path, *fixed_indexquals = lappend(*fixed_indexquals, clause); /* - * Look up the (possibly commuted) operator in the operator class to - * get its strategy numbers and the recheck indicator. This also + * Look up the (possibly commuted) operator in the operator family to + * get its strategy number and the recheck indicator. This also * double-checks that we found an operator matching the index. */ - get_op_opclass_properties(clause_op, opclass, - &stratno, &stratsubtype, &recheck); + get_op_opfamily_properties(clause_op, opfamily, + &stratno, + &stratlefttype, + &stratrighttype, + &recheck); *indexstrategy = lappend_int(*indexstrategy, stratno); - *indexsubtype = lappend_oid(*indexsubtype, stratsubtype); + *indexsubtype = lappend_oid(*indexsubtype, stratrighttype); /* If it's not lossy, add to nonlossy_indexquals */ if (!recheck) @@ -1793,7 +1799,7 @@ fix_indexqual_references(List *indexquals, IndexPath *index_path, } static Node * -fix_indexqual_operand(Node *node, IndexOptInfo *index, Oid *opclass) +fix_indexqual_operand(Node *node, IndexOptInfo *index, Oid *opfamily) { /* * We represent index keys by Var nodes having the varno of the base table @@ -1826,8 +1832,8 @@ fix_indexqual_operand(Node *node, IndexOptInfo *index, Oid *opclass) { result = (Var *) copyObject(node); result->varattno = pos + 1; - /* return the correct opclass, too */ - *opclass = index->classlist[pos]; + /* return the correct opfamily, too */ + *opfamily = index->opfamily[pos]; return (Node *) result; } } @@ -1853,8 +1859,8 @@ fix_indexqual_operand(Node *node, IndexOptInfo *index, Oid *opclass) result = makeVar(index->rel->relid, pos + 1, exprType(lfirst(indexpr_item)), -1, 0); - /* return the correct opclass, too */ - *opclass = index->classlist[pos]; + /* return the correct opfamily, too */ + *opfamily = index->opfamily[pos]; return (Node *) result; } indexpr_item = lnext(indexpr_item); @@ -1863,7 +1869,7 @@ fix_indexqual_operand(Node *node, IndexOptInfo *index, Oid *opclass) /* Ooops... */ elog(ERROR, "node is not an index attribute"); - *opclass = InvalidOid; /* keep compiler quiet */ + *opfamily = InvalidOid; /* keep compiler quiet */ return NULL; } @@ -2327,6 +2333,8 @@ make_mergejoin(List *tlist, List *joinclauses, List *otherclauses, List *mergeclauses, + List *mergefamilies, + List *mergestrategies, Plan *lefttree, Plan *righttree, JoinType jointype) @@ -2340,6 +2348,8 @@ make_mergejoin(List *tlist, plan->lefttree = lefttree; plan->righttree = righttree; node->mergeclauses = mergeclauses; + node->mergefamilies = mergefamilies; + node->mergestrategies = mergestrategies; node->join.jointype = jointype; node->join.joinqual = joinclauses; diff --git a/src/backend/optimizer/plan/initsplan.c b/src/backend/optimizer/plan/initsplan.c index da321a637b2..229b779af03 100644 --- a/src/backend/optimizer/plan/initsplan.c +++ b/src/backend/optimizer/plan/initsplan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.124 2006/12/07 19:33:40 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.125 2006/12/23 00:43:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1109,10 +1109,10 @@ process_implied_equality(PlannerInfo *root, /* * Let's just make sure this appears to be a compatible operator. + * + * XXX needs work */ - if (pgopform->oprlsortop != sortop1 || - pgopform->oprrsortop != sortop2 || - pgopform->oprresult != BOOLOID) + if (pgopform->oprresult != BOOLOID) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("equality operator for types %s and %s should be merge-joinable, but isn't", @@ -1276,6 +1276,7 @@ check_mergejoinable(RestrictInfo *restrictinfo) Oid opno, leftOp, rightOp; + Oid opfamily; if (restrictinfo->pseudoconstant) return; @@ -1286,14 +1287,17 @@ check_mergejoinable(RestrictInfo *restrictinfo) opno = ((OpExpr *) clause)->opno; - if (op_mergejoinable(opno, - &leftOp, - &rightOp) && + if (op_mergejoinable(opno) && !contain_volatile_functions((Node *) clause)) { - restrictinfo->mergejoinoperator = opno; - restrictinfo->left_sortop = leftOp; - restrictinfo->right_sortop = rightOp; + /* XXX for the moment, continue to force use of particular sortops */ + if (get_op_mergejoin_info(opno, &leftOp, &rightOp, &opfamily)) + { + restrictinfo->mergejoinoperator = opno; + restrictinfo->left_sortop = leftOp; + restrictinfo->right_sortop = rightOp; + restrictinfo->mergeopfamily = opfamily; + } } } diff --git a/src/backend/optimizer/plan/planagg.c b/src/backend/optimizer/plan/planagg.c index e64340ed21c..fcc8d510786 100644 --- a/src/backend/optimizer/plan/planagg.c +++ b/src/backend/optimizer/plan/planagg.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/planagg.c,v 1.22 2006/10/04 00:29:54 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/planagg.c,v 1.23 2006/12/23 00:43:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -340,8 +340,8 @@ build_minmax_path(PlannerInfo *root, RelOptInfo *rel, MinMaxAggInfo *info) Assert(is_opclause(rinfo->clause)); strategy = - get_op_opclass_strategy(((OpExpr *) rinfo->clause)->opno, - index->classlist[prevcol]); + get_op_opfamily_strategy(((OpExpr *) rinfo->clause)->opno, + index->opfamily[prevcol]); if (strategy == BTEqualStrategyNumber) break; } @@ -390,10 +390,10 @@ build_minmax_path(PlannerInfo *root, RelOptInfo *rel, MinMaxAggInfo *info) * Does an aggregate match an index column? * * It matches if its argument is equal to the index column's data and its - * sortop is either the LessThan or GreaterThan member of the column's opclass. + * sortop is either a LessThan or GreaterThan member of the column's opfamily. * - * We return ForwardScanDirection if match the LessThan member, - * BackwardScanDirection if match the GreaterThan member, + * We return ForwardScanDirection if match a LessThan member, + * BackwardScanDirection if match a GreaterThan member, * and NoMovementScanDirection if there's no match. */ static ScanDirection @@ -405,9 +405,9 @@ match_agg_to_index_col(MinMaxAggInfo *info, IndexOptInfo *index, int indexcol) if (!match_index_to_operand((Node *) info->target, indexcol, index)) return NoMovementScanDirection; - /* Look up the operator in the opclass */ - strategy = get_op_opclass_strategy(info->aggsortop, - index->classlist[indexcol]); + /* Look up the operator in the opfamily */ + strategy = get_op_opfamily_strategy(info->aggsortop, + index->opfamily[indexcol]); if (strategy == BTLessStrategyNumber) return ForwardScanDirection; if (strategy == BTGreaterStrategyNumber) diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c index 7793d071cda..f42a28cddd5 100644 --- a/src/backend/optimizer/plan/subselect.c +++ b/src/backend/optimizer/plan/subselect.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.114 2006/12/10 22:13:26 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.115 2006/12/23 00:43:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -689,11 +689,11 @@ convert_IN_to_join(PlannerInfo *root, SubLink *sublink) return NULL; if (sublink->testexpr && IsA(sublink->testexpr, OpExpr)) { - List *opclasses; + List *opfamilies; List *opstrats; get_op_btree_interpretation(((OpExpr *) sublink->testexpr)->opno, - &opclasses, &opstrats); + &opfamilies, &opstrats); if (!list_member_int(opstrats, ROWCOMPARE_EQ)) return NULL; } |