Since createplan.c no longer cares whether index operators are lossy, it has
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 13 Apr 2008 20:51:21 +0000 (20:51 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 13 Apr 2008 20:51:21 +0000 (20:51 +0000)
no particular need to do get_op_opfamily_properties() while building an
indexscan plan.  Postpone that lookup until executor start.  This simplifies
createplan.c a lot more than it complicates nodeIndexscan.c, and makes things
more uniform since we already had to do it that way for RowCompare
expressions.  Should be a bit faster too, at least for plans that aren't
re-used many times, since we avoid palloc'ing and perhaps copying the
intermediate list data structure.

13 files changed:
src/backend/executor/execQual.c
src/backend/executor/nodeBitmapIndexscan.c
src/backend/executor/nodeIndexscan.c
src/backend/executor/nodeMergejoin.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/outfuncs.c
src/backend/optimizer/path/indxpath.c
src/backend/optimizer/plan/createplan.c
src/backend/utils/adt/selfuncs.c
src/backend/utils/cache/lsyscache.c
src/include/executor/nodeIndexscan.h
src/include/nodes/plannodes.h
src/include/utils/lsyscache.h

index e55e2ed98cebd9735c9f0c9d09986b0a8c5406e6..68fe5d11c9e9369d40668b9d28d3e2b41b560372 100644 (file)
@@ -4175,14 +4175,12 @@ ExecInitExpr(Expr *node, PlanState *parent)
                                        int                     strategy;
                                        Oid                     lefttype;
                                        Oid                     righttype;
-                                       bool            recheck;
                                        Oid                     proc;
 
                                        get_op_opfamily_properties(opno, opfamily,
                                                                                           &strategy,
                                                                                           &lefttype,
-                                                                                          &righttype,
-                                                                                          &recheck);
+                                                                                          &righttype);
                                        proc = get_opfamily_proc(opfamily,
                                                                                         lefttype,
                                                                                         righttype,
index 1297fedd2a3936e43b5dabbd95344ac79704b59b..e7a81b4d8e2dcfdf006547df0cda3077ce5fa28d 100644 (file)
@@ -276,8 +276,6 @@ ExecInitBitmapIndexScan(BitmapIndexScan *node, EState *estate, int eflags)
        ExecIndexBuildScanKeys((PlanState *) indexstate,
                                                   indexstate->biss_RelationDesc,
                                                   node->indexqual,
-                                                  node->indexstrategy,
-                                                  node->indexsubtype,
                                                   &indexstate->biss_ScanKeys,
                                                   &indexstate->biss_NumScanKeys,
                                                   &indexstate->biss_RuntimeKeys,
index 656e7408622bf18cb7acba945cfd7d9a28eddece..48464bc827d3de65467a325e86185e9014977c0a 100644 (file)
@@ -576,8 +576,6 @@ ExecInitIndexScan(IndexScan *node, EState *estate, int eflags)
        ExecIndexBuildScanKeys((PlanState *) indexstate,
                                                   indexstate->iss_RelationDesc,
                                                   node->indexqual,
-                                                  node->indexstrategy,
-                                                  node->indexsubtype,
                                                   &indexstate->iss_ScanKeys,
                                                   &indexstate->iss_NumScanKeys,
                                                   &indexstate->iss_RuntimeKeys,
@@ -655,12 +653,6 @@ ExecInitIndexScan(IndexScan *node, EState *estate, int eflags)
  * planstate: executor state node we are working for
  * index: the index we are building scan keys for
  * quals: indexquals expressions
- * strategies: associated operator strategy numbers
- * subtypes: associated operator subtype OIDs
- *
- * (Any elements of the strategies and subtypes lists that correspond to
- * RowCompareExpr quals are not used here; instead we look up the info
- * afresh.)
  *
  * Output params are:
  *
@@ -675,15 +667,12 @@ ExecInitIndexScan(IndexScan *node, EState *estate, int eflags)
  * ScalarArrayOpExpr quals are not supported.
  */
 void
-ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
-                                          List *quals, List *strategies, List *subtypes,
+ExecIndexBuildScanKeys(PlanState *planstate, Relation index, List *quals,
                                           ScanKey *scanKeys, int *numScanKeys,
                                           IndexRuntimeKeyInfo **runtimeKeys, int *numRuntimeKeys,
                                           IndexArrayKeyInfo **arrayKeys, int *numArrayKeys)
 {
        ListCell   *qual_cell;
-       ListCell   *strategy_cell;
-       ListCell   *subtype_cell;
        ScanKey         scan_keys;
        IndexRuntimeKeyInfo *runtime_keys;
        IndexArrayKeyInfo *array_keys;
@@ -725,40 +714,31 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
        extra_scan_keys = n_scan_keys;
 
        /*
-        * for each opclause in the given qual, convert each qual's opclause into
+        * for each opclause in the given qual, convert the opclause into
         * a single scan key
         */
-       qual_cell = list_head(quals);
-       strategy_cell = list_head(strategies);
-       subtype_cell = list_head(subtypes);
-
-       for (j = 0; j < n_scan_keys; j++)
+       j = 0;
+       foreach(qual_cell, quals)
        {
-               ScanKey         this_scan_key = &scan_keys[j];
-               Expr       *clause;             /* one clause of index qual */
+               Expr       *clause = (Expr *) lfirst(qual_cell);
+               ScanKey         this_scan_key = &scan_keys[j++];
+               Oid                     opno;           /* operator's OID */
                RegProcedure opfuncid;  /* operator proc id used in scan */
-               StrategyNumber strategy;        /* op's strategy number */
-               Oid                     subtype;        /* op's strategy subtype */
+               Oid                     opfamily;       /* opfamily of index column */
+               int                     op_strategy; /* operator's strategy number */
+               Oid                     op_lefttype; /* operator's declared input types */
+               Oid                     op_righttype;
                Expr       *leftop;             /* expr on lhs of operator */
                Expr       *rightop;    /* expr on rhs ... */
                AttrNumber      varattno;       /* att number used in scan */
 
-               /*
-                * extract clause information from the qualification
-                */
-               clause = (Expr *) lfirst(qual_cell);
-               qual_cell = lnext(qual_cell);
-               strategy = lfirst_int(strategy_cell);
-               strategy_cell = lnext(strategy_cell);
-               subtype = lfirst_oid(subtype_cell);
-               subtype_cell = lnext(subtype_cell);
-
                if (IsA(clause, OpExpr))
                {
                        /* indexkey op const or indexkey op expression */
                        int                     flags = 0;
                        Datum           scanvalue;
 
+                       opno = ((OpExpr *) clause)->opno;
                        opfuncid = ((OpExpr *) clause)->opfuncid;
 
                        /*
@@ -776,6 +756,19 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
                                elog(ERROR, "indexqual doesn't have key on left side");
 
                        varattno = ((Var *) leftop)->varattno;
+                       if (varattno < 1 || varattno > index->rd_index->indnatts)
+                               elog(ERROR, "bogus index qualification");
+
+                       /*
+                        * We have to look up the operator's strategy number.  This
+                        * provides a cross-check that the operator does match the index.
+                        */
+                       opfamily = index->rd_opfamily[varattno - 1];
+
+                       get_op_opfamily_properties(opno, opfamily,
+                                                                          &op_strategy,
+                                                                          &op_lefttype,
+                                                                          &op_righttype);
 
                        /*
                         * rightop is the constant or variable comparison value
@@ -810,8 +803,8 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
                        ScanKeyEntryInitialize(this_scan_key,
                                                                   flags,
                                                                   varattno,    /* attribute number to scan */
-                                                                  strategy,    /* op's strategy */
-                                                                  subtype,             /* strategy subtype */
+                                                                  op_strategy, /* op's strategy */
+                                                                  op_righttype, /* strategy subtype */
                                                                   opfuncid,    /* reg proc to use */
                                                                   scanvalue);  /* constant */
                }
@@ -830,12 +823,6 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
                                ScanKey         this_sub_key = &scan_keys[extra_scan_keys];
                                int                     flags = SK_ROW_MEMBER;
                                Datum           scanvalue;
-                               Oid                     opno;
-                               Oid                     opfamily;
-                               int                     op_strategy;
-                               Oid                     op_lefttype;
-                               Oid                     op_righttype;
-                               bool            op_recheck;
 
                                /*
                                 * leftop should be the index key Var, possibly relabeled
@@ -897,8 +884,7 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
                                get_op_opfamily_properties(opno, opfamily,
                                                                                   &op_strategy,
                                                                                   &op_lefttype,
-                                                                                  &op_righttype,
-                                                                                  &op_recheck);
+                                                                                  &op_righttype);
 
                                if (op_strategy != rc->rctype)
                                        elog(ERROR, "RowCompare index qualification contains wrong operator");
@@ -941,6 +927,7 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
                        ScalarArrayOpExpr *saop = (ScalarArrayOpExpr *) clause;
 
                        Assert(saop->useOr);
+                       opno = saop->opno;
                        opfuncid = saop->opfuncid;
 
                        /*
@@ -958,6 +945,19 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
                                elog(ERROR, "indexqual doesn't have key on left side");
 
                        varattno = ((Var *) leftop)->varattno;
+                       if (varattno < 1 || varattno > index->rd_index->indnatts)
+                               elog(ERROR, "bogus index qualification");
+
+                       /*
+                        * We have to look up the operator's strategy number.  This
+                        * provides a cross-check that the operator does match the index.
+                        */
+                       opfamily = index->rd_opfamily[varattno - 1];
+
+                       get_op_opfamily_properties(opno, opfamily,
+                                                                          &op_strategy,
+                                                                          &op_lefttype,
+                                                                          &op_righttype);
 
                        /*
                         * rightop is the constant or variable array value
@@ -981,8 +981,8 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
                        ScanKeyEntryInitialize(this_scan_key,
                                                                   0,   /* flags */
                                                                   varattno,    /* attribute number to scan */
-                                                                  strategy,    /* op's strategy */
-                                                                  subtype,             /* strategy subtype */
+                                                                  op_strategy, /* op's strategy */
+                                                                  op_righttype, /* strategy subtype */
                                                                   opfuncid,    /* reg proc to use */
                                                                   (Datum) 0);  /* constant */
                }
@@ -1013,8 +1013,8 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
                        ScanKeyEntryInitialize(this_scan_key,
                                                                   SK_ISNULL | SK_SEARCHNULL,
                                                                   varattno,    /* attribute number to scan */
-                                                                  strategy,    /* op's strategy */
-                                                                  subtype,             /* strategy subtype */
+                                                                  InvalidStrategy,     /* no strategy */
+                                                                  InvalidOid,  /* no strategy subtype */
                                                                   InvalidOid,  /* no reg proc for this */
                                                                   (Datum) 0);  /* constant */
                }
index 440b7989721fbfbc874302627c4f0d6260ab974e..481e1fd098d30a8ee499e20677e75d93053f2c01 100644 (file)
@@ -180,7 +180,6 @@ MJExamineQuals(List *mergeclauses,
                int                     op_strategy;
                Oid                     op_lefttype;
                Oid                     op_righttype;
-               bool            op_recheck;
                RegProcedure cmpproc;
                AclResult       aclresult;
 
@@ -197,12 +196,10 @@ MJExamineQuals(List *mergeclauses,
                get_op_opfamily_properties(qual->opno, opfamily,
                                                                   &op_strategy,
                                                                   &op_lefttype,
-                                                                  &op_righttype,
-                                                                  &op_recheck);
+                                                                  &op_righttype);
                if (op_strategy != BTEqualStrategyNumber)               /* should not happen */
                        elog(ERROR, "cannot merge using non-equality operator %u",
                                 qual->opno);
-               Assert(!op_recheck);    /* never true for btree */
 
                /* And get the matching support procedure (comparison function) */
                cmpproc = get_opfamily_proc(opfamily,
index 77bba77a62d8dace253c75297312bd83e67667d9..5f0e7fa43bc6a21316fccd839a46fcac15b3a7ff 100644 (file)
@@ -279,8 +279,6 @@ _copyIndexScan(IndexScan *from)
        COPY_SCALAR_FIELD(indexid);
        COPY_NODE_FIELD(indexqual);
        COPY_NODE_FIELD(indexqualorig);
-       COPY_NODE_FIELD(indexstrategy);
-       COPY_NODE_FIELD(indexsubtype);
        COPY_SCALAR_FIELD(indexorderdir);
 
        return newnode;
@@ -305,8 +303,6 @@ _copyBitmapIndexScan(BitmapIndexScan *from)
        COPY_SCALAR_FIELD(indexid);
        COPY_NODE_FIELD(indexqual);
        COPY_NODE_FIELD(indexqualorig);
-       COPY_NODE_FIELD(indexstrategy);
-       COPY_NODE_FIELD(indexsubtype);
 
        return newnode;
 }
index 72ee2ff25dc4c591c07d40590c714d725f94e808..f1cd4215bf6d329cfbee80672e3fc17049aa6a65 100644 (file)
@@ -372,8 +372,6 @@ _outIndexScan(StringInfo str, IndexScan *node)
        WRITE_OID_FIELD(indexid);
        WRITE_NODE_FIELD(indexqual);
        WRITE_NODE_FIELD(indexqualorig);
-       WRITE_NODE_FIELD(indexstrategy);
-       WRITE_NODE_FIELD(indexsubtype);
        WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
 }
 
@@ -387,8 +385,6 @@ _outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
        WRITE_OID_FIELD(indexid);
        WRITE_NODE_FIELD(indexqual);
        WRITE_NODE_FIELD(indexqualorig);
-       WRITE_NODE_FIELD(indexstrategy);
-       WRITE_NODE_FIELD(indexsubtype);
 }
 
 static void
index 70ff243ec9b2f10daea64d1c6bbb486ee3539c8f..c4fab087b5b76ad5128964535fbf0d575c0eac10 100644 (file)
@@ -2465,7 +2465,6 @@ expand_indexqual_rowcompare(RestrictInfo *rinfo,
        int                     op_strategy;
        Oid                     op_lefttype;
        Oid                     op_righttype;
-       bool            op_recheck;
        int                     matching_cols;
        Oid                     expr_op;
        List       *opfamilies;
@@ -2488,8 +2487,7 @@ expand_indexqual_rowcompare(RestrictInfo *rinfo,
        get_op_opfamily_properties(expr_op, index->opfamily[indexcol],
                                                           &op_strategy,
                                                           &op_lefttype,
-                                                          &op_righttype,
-                                                          &op_recheck);
+                                                          &op_righttype);
        /* Build lists of the opfamilies and operator datatypes in case needed */
        opfamilies = list_make1_oid(index->opfamily[indexcol]);
        lefttypes = list_make1_oid(op_lefttype);
@@ -2557,8 +2555,7 @@ expand_indexqual_rowcompare(RestrictInfo *rinfo,
                get_op_opfamily_properties(expr_op, index->opfamily[i],
                                                                   &op_strategy,
                                                                   &op_lefttype,
-                                                                  &op_righttype,
-                                                                  &op_recheck);
+                                                                  &op_righttype);
                opfamilies = lappend_oid(opfamilies, index->opfamily[i]);
                lefttypes = lappend_oid(lefttypes, op_lefttype);
                righttypes = lappend_oid(righttypes, op_righttype);
index 25ad84b5dcba7baa94e949117a7e71f574f510cc..59348a28475307257939bd403c48f2754509a624 100644 (file)
@@ -67,12 +67,8 @@ static MergeJoin *create_mergejoin_plan(PlannerInfo *root, MergePath *best_path,
                                          Plan *outer_plan, Plan *inner_plan);
 static HashJoin *create_hashjoin_plan(PlannerInfo *root, HashPath *best_path,
                                         Plan *outer_plan, Plan *inner_plan);
-static void fix_indexqual_references(List *indexquals, IndexPath *index_path,
-                                                List **fixed_indexquals,
-                                                List **indexstrategy,
-                                                List **indexsubtype);
-static Node *fix_indexqual_operand(Node *node, IndexOptInfo *index,
-                                         Oid *opfamily);
+static List *fix_indexqual_references(List *indexquals, IndexPath *index_path);
+static Node *fix_indexqual_operand(Node *node, IndexOptInfo *index);
 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);
@@ -80,13 +76,10 @@ static void copy_plan_costsize(Plan *dest, Plan *src);
 static SeqScan *make_seqscan(List *qptlist, List *qpqual, Index scanrelid);
 static IndexScan *make_indexscan(List *qptlist, List *qpqual, Index scanrelid,
                           Oid indexid, List *indexqual, List *indexqualorig,
-                          List *indexstrategy, List *indexsubtype,
                           ScanDirection indexscandir);
 static BitmapIndexScan *make_bitmap_indexscan(Index scanrelid, Oid indexid,
                                          List *indexqual,
-                                         List *indexqualorig,
-                                         List *indexstrategy,
-                                         List *indexsubtype);
+                                         List *indexqualorig);
 static BitmapHeapScan *make_bitmap_heapscan(List *qptlist,
                                         List *qpqual,
                                         Plan *lefttree,
@@ -850,8 +843,6 @@ create_indexscan_plan(PlannerInfo *root,
        List       *qpqual;
        List       *stripped_indexquals;
        List       *fixed_indexquals;
-       List       *indexstrategy;
-       List       *indexsubtype;
        ListCell   *l;
        IndexScan  *scan_plan;
 
@@ -867,13 +858,9 @@ create_indexscan_plan(PlannerInfo *root,
 
        /*
         * The executor needs a copy with the indexkey on the left of each clause
-        * and with index attr numbers substituted for table ones. This pass also
-        * gets strategy info.
+        * and with index attr numbers substituted for table ones.
         */
-       fix_indexqual_references(indexquals, best_path,
-                                                        &fixed_indexquals,
-                                                        &indexstrategy,
-                                                        &indexsubtype);
+       fixed_indexquals = fix_indexqual_references(indexquals, best_path);
 
        /*
         * If this is an innerjoin scan, the indexclauses will contain join
@@ -951,8 +938,6 @@ create_indexscan_plan(PlannerInfo *root,
                                                           indexoid,
                                                           fixed_indexquals,
                                                           stripped_indexquals,
-                                                          indexstrategy,
-                                                          indexsubtype,
                                                           best_path->indexscandir);
 
        copy_path_costsize(&scan_plan->scan.plan, &best_path->path);
@@ -1193,9 +1178,7 @@ create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual,
                plan = (Plan *) make_bitmap_indexscan(iscan->scan.scanrelid,
                                                                                          iscan->indexid,
                                                                                          iscan->indexqual,
-                                                                                         iscan->indexqualorig,
-                                                                                         iscan->indexstrategy,
-                                                                                         iscan->indexsubtype);
+                                                                                         iscan->indexqualorig);
                plan->startup_cost = 0.0;
                plan->total_cost = ipath->indextotalcost;
                plan->plan_rows =
@@ -1757,52 +1740,36 @@ create_hashjoin_plan(PlannerInfo *root,
  *       Adjust indexqual clauses to the form the executor's indexqual
  *       machinery needs.
  *
- * We have four tasks here:
+ * We have three tasks here:
  *     * Remove RestrictInfo nodes from the input clauses.
  *     * Index keys must be represented by Var nodes with varattno set to the
  *       index's attribute number, not the attribute number in the original rel.
  *     * If the index key is on the right, commute the clause to put it on the
  *       left.
- *     * We must construct lists of operator strategy numbers and subtypes
- *       for the top-level operators of each index clause.
  *
- * fixed_indexquals receives a modified copy of the indexquals list --- the
+ * The result is a modified copy of the indexquals list --- the
  * original is not changed.  Note also that the copy shares no substructure
  * with the original; this is needed in case there is a subplan in it (we need
  * two separate copies of the subplan tree, or things will go awry).
- *
- * indexstrategy receives an integer list of strategy numbers.
- * indexsubtype receives an OID list of strategy subtypes.
  */
-static void
-fix_indexqual_references(List *indexquals, IndexPath *index_path,
-                                                List **fixed_indexquals,
-                                                List **indexstrategy,
-                                                List **indexsubtype)
+static List *
+fix_indexqual_references(List *indexquals, IndexPath *index_path)
 {
        IndexOptInfo *index = index_path->indexinfo;
+       List       *fixed_indexquals;
        ListCell   *l;
 
-       *fixed_indexquals = NIL;
-       *indexstrategy = NIL;
-       *indexsubtype = NIL;
+       fixed_indexquals = NIL;
 
        /*
         * For each qual clause, commute if needed to put the indexkey operand on
         * the left, and then fix its varattno.  (We do not need to change the
-        * other side of the clause.)  Then determine the operator's strategy
-        * number and subtype number.
+        * other side of the clause.)
         */
        foreach(l, indexquals)
        {
                RestrictInfo *rinfo = (RestrictInfo *) lfirst(l);
                Expr       *clause;
-               Oid                     clause_op;
-               Oid                     opfamily;
-               int                     stratno;
-               Oid                     stratlefttype;
-               Oid                     stratrighttype;
-               bool            is_null_op = false;
 
                Assert(IsA(rinfo, RestrictInfo));
 
@@ -1831,13 +1798,11 @@ fix_indexqual_references(List *indexquals, IndexPath *index_path,
                                CommuteOpExpr(op);
 
                        /*
-                        * Now, determine which index attribute this is, change the
-                        * indexkey operand as needed, and get the index opfamily.
+                        * Now, determine which index attribute this is and change the
+                        * indexkey operand as needed.
                         */
                        linitial(op->args) = fix_indexqual_operand(linitial(op->args),
-                                                                                                          index,
-                                                                                                          &opfamily);
-                       clause_op = op->opno;
+                                                                                                          index);
                }
                else if (IsA(clause, RowCompareExpr))
                {
@@ -1856,23 +1821,12 @@ 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 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_opfamily;
-
                                lfirst(lc) = fix_indexqual_operand(lfirst(lc),
-                                                                                                  index,
-                                                                                                  &tmp_opfamily);
-                               if (lc == list_head(rc->largs))
-                                       opfamily = tmp_opfamily;
+                                                                                                  index);
                        }
-                       clause_op = linitial_oid(rc->opnos);
                }
                else if (IsA(clause, ScalarArrayOpExpr))
                {
@@ -1881,13 +1835,11 @@ fix_indexqual_references(List *indexquals, IndexPath *index_path,
                        /* Never need to commute... */
 
                        /*
-                        * Now, determine which index attribute this is, change the
-                        * indexkey operand as needed, and get the index opfamily.
+                        * Determine which index attribute this is and change the
+                        * indexkey operand as needed.
                         */
                        linitial(saop->args) = fix_indexqual_operand(linitial(saop->args),
-                                                                                                                index,
-                                                                                                                &opfamily);
-                       clause_op = saop->opno;
+                                                                                                                index);
                }
                else if (IsA(clause, NullTest))
                {
@@ -1895,49 +1847,20 @@ fix_indexqual_references(List *indexquals, IndexPath *index_path,
 
                        Assert(nt->nulltesttype == IS_NULL);
                        nt->arg = (Expr *) fix_indexqual_operand((Node *) nt->arg,
-                                                                                                        index,
-                                                                                                        &opfamily);
-                       is_null_op = true;
-                       clause_op = InvalidOid;         /* keep compiler quiet */
+                                                                                                        index);
                }
                else
-               {
                        elog(ERROR, "unsupported indexqual type: %d",
                                 (int) nodeTag(clause));
-                       continue;                       /* keep compiler quiet */
-               }
 
-               *fixed_indexquals = lappend(*fixed_indexquals, clause);
-
-               if (is_null_op)
-               {
-                       /* IS NULL doesn't have a clause_op */
-                       stratno = InvalidStrategy;
-                       stratrighttype = InvalidOid;
-               }
-               else
-               {
-                       /*
-                        * 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.
-                        */
-                       bool            recheck;
-
-                       get_op_opfamily_properties(clause_op, opfamily,
-                                                                          &stratno,
-                                                                          &stratlefttype,
-                                                                          &stratrighttype,
-                                                                          &recheck);
-               }
-
-               *indexstrategy = lappend_int(*indexstrategy, stratno);
-               *indexsubtype = lappend_oid(*indexsubtype, stratrighttype);
+               fixed_indexquals = lappend(fixed_indexquals, clause);
        }
+
+       return fixed_indexquals;
 }
 
 static Node *
-fix_indexqual_operand(Node *node, IndexOptInfo *index, Oid *opfamily)
+fix_indexqual_operand(Node *node, IndexOptInfo *index)
 {
        /*
         * We represent index keys by Var nodes having the varno of the base table
@@ -1970,8 +1893,6 @@ fix_indexqual_operand(Node *node, IndexOptInfo *index, Oid *opfamily)
                                {
                                        result = (Var *) copyObject(node);
                                        result->varattno = pos + 1;
-                                       /* return the correct opfamily, too */
-                                       *opfamily = index->opfamily[pos];
                                        return (Node *) result;
                                }
                        }
@@ -1997,8 +1918,6 @@ fix_indexqual_operand(Node *node, IndexOptInfo *index, Oid *opfamily)
                                result = makeVar(index->rel->relid, pos + 1,
                                                                 exprType(lfirst(indexpr_item)), -1,
                                                                 0);
-                               /* return the correct opfamily, too */
-                               *opfamily = index->opfamily[pos];
                                return (Node *) result;
                        }
                        indexpr_item = lnext(indexpr_item);
@@ -2007,8 +1926,7 @@ fix_indexqual_operand(Node *node, IndexOptInfo *index, Oid *opfamily)
 
        /* Ooops... */
        elog(ERROR, "node is not an index attribute");
-       *opfamily = InvalidOid;         /* keep compiler quiet */
-       return NULL;
+       return NULL;                            /* keep compiler quiet */
 }
 
 /*
@@ -2229,8 +2147,6 @@ make_indexscan(List *qptlist,
                           Oid indexid,
                           List *indexqual,
                           List *indexqualorig,
-                          List *indexstrategy,
-                          List *indexsubtype,
                           ScanDirection indexscandir)
 {
        IndexScan  *node = makeNode(IndexScan);
@@ -2245,8 +2161,6 @@ make_indexscan(List *qptlist,
        node->indexid = indexid;
        node->indexqual = indexqual;
        node->indexqualorig = indexqualorig;
-       node->indexstrategy = indexstrategy;
-       node->indexsubtype = indexsubtype;
        node->indexorderdir = indexscandir;
 
        return node;
@@ -2256,9 +2170,7 @@ static BitmapIndexScan *
 make_bitmap_indexscan(Index scanrelid,
                                          Oid indexid,
                                          List *indexqual,
-                                         List *indexqualorig,
-                                         List *indexstrategy,
-                                         List *indexsubtype)
+                                         List *indexqualorig)
 {
        BitmapIndexScan *node = makeNode(BitmapIndexScan);
        Plan       *plan = &node->scan.plan;
@@ -2272,8 +2184,6 @@ make_bitmap_indexscan(Index scanrelid,
        node->indexid = indexid;
        node->indexqual = indexqual;
        node->indexqualorig = indexqualorig;
-       node->indexstrategy = indexstrategy;
-       node->indexsubtype = indexsubtype;
 
        return node;
 }
index 2355fe0c2d89cf3657c82f6b69668f394d3f9570..1d02c9594681f78d5aea8aaf945e9bf8b1aee6f2 100644 (file)
@@ -2275,7 +2275,6 @@ mergejoinscansel(PlannerInfo *root, Node *clause,
        int                     op_strategy;
        Oid                     op_lefttype;
        Oid                     op_righttype;
-       bool            op_recheck;
        Oid                     opno,
                                lsortop,
                                rsortop,
@@ -2314,10 +2313,8 @@ mergejoinscansel(PlannerInfo *root, Node *clause,
        get_op_opfamily_properties(opno, opfamily,
                                                           &op_strategy,
                                                           &op_lefttype,
-                                                          &op_righttype,
-                                                          &op_recheck);
+                                                          &op_righttype);
        Assert(op_strategy == BTEqualStrategyNumber);
-       Assert(!op_recheck);
 
        /*
         * Look up the various operators we need.  If we don't find them all, it
index 13590277487fe45fea6b1cd2c52ebecef9681068..6258be7cea3afc2f940b82f98b823b18a0ca7d4f 100644 (file)
@@ -80,8 +80,8 @@ get_op_opfamily_strategy(Oid opno, Oid opfamily)
 /*
  * get_op_opfamily_properties
  *
- *             Get the operator's strategy number, input types, and recheck (lossy)
- *             flag within the specified opfamily.
+ *             Get the operator's strategy number and declared input data types
+ *             within the specified opfamily.
  *
  * Caller should already have verified that opno is a member of opfamily,
  * therefore we raise an error if the tuple is not found.
@@ -90,8 +90,7 @@ void
 get_op_opfamily_properties(Oid opno, Oid opfamily,
                                                   int *strategy,
                                                   Oid *lefttype,
-                                                  Oid *righttype,
-                                                  bool *recheck)
+                                                  Oid *righttype)
 {
        HeapTuple       tp;
        Form_pg_amop amop_tup;
@@ -107,7 +106,6 @@ get_op_opfamily_properties(Oid opno, Oid opfamily,
        *strategy = amop_tup->amopstrategy;
        *lefttype = amop_tup->amoplefttype;
        *righttype = amop_tup->amoprighttype;
-       *recheck = amop_tup->amopreqcheck;
        ReleaseSysCache(tp);
 }
 
index cfe36bb79ae0945812af6295d5a902ecfb4ac51c..615b78bd65f6bc9bc60da37c361479058393fc88 100644 (file)
@@ -26,8 +26,7 @@ extern void ExecIndexReScan(IndexScanState *node, ExprContext *exprCtxt);
 
 /* routines exported to share code with nodeBitmapIndexscan.c */
 extern void ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
-                                          List *quals, List *strategies, List *subtypes,
-                                          ScanKey *scanKeys, int *numScanKeys,
+                                          List *quals, ScanKey *scanKeys, int *numScanKeys,
                                           IndexRuntimeKeyInfo **runtimeKeys, int *numRuntimeKeys,
                                           IndexArrayKeyInfo **arrayKeys, int *numArrayKeys);
 extern void ExecIndexEvalRuntimeKeys(ExprContext *econtext,
index 6066a82d951410faf00fb8156d7c2076644b3365..0b1f570120ed0fce0815f2d34a952b640cb0aa05 100644 (file)
@@ -241,10 +241,6 @@ typedef Scan SeqScan;
  * table).     This is a bit hokey ... would be cleaner to use a special-purpose
  * node type that could not be mistaken for a regular Var.     But it will do
  * for now.
- *
- * indexstrategy and indexsubtype are lists corresponding one-to-one with
- * indexqual; they give information about the indexable operators that appear
- * at the top of each indexqual.
  * ----------------
  */
 typedef struct IndexScan
@@ -253,8 +249,6 @@ typedef struct IndexScan
        Oid                     indexid;                /* OID of index to scan */
        List       *indexqual;          /* list of index quals (OpExprs) */
        List       *indexqualorig;      /* the same in original form */
-       List       *indexstrategy;      /* integer list of strategy numbers */
-       List       *indexsubtype;       /* OID list of strategy subtypes */
        ScanDirection indexorderdir;    /* forward or backward or don't care */
 } IndexScan;
 
@@ -281,8 +275,6 @@ typedef struct BitmapIndexScan
        Oid                     indexid;                /* OID of index to scan */
        List       *indexqual;          /* list of index quals (OpExprs) */
        List       *indexqualorig;      /* the same in original form */
-       List       *indexstrategy;      /* integer list of strategy numbers */
-       List       *indexsubtype;       /* OID list of strategy subtypes */
 } BitmapIndexScan;
 
 /* ----------------
index 50b9a37f66fb85a6076ee07125d5b5e063a061bf..a59e297a0ad80248b12f01fad8353b68298e0f8b 100644 (file)
@@ -31,8 +31,7 @@ extern int    get_op_opfamily_strategy(Oid opno, Oid opfamily);
 extern void get_op_opfamily_properties(Oid opno, Oid opfamily,
                                                   int *strategy,
                                                   Oid *lefttype,
-                                                  Oid *righttype,
-                                                  bool *recheck);
+                                                  Oid *righttype);
 extern Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype,
                                        int16 strategy);
 extern bool get_ordering_op_properties(Oid opno,