]> granicus.if.org Git - postgresql/commitdiff
Fix using indices in OR.
authorVadim B. Mikheev <vadim4o@yahoo.com>
Sun, 22 Nov 1998 10:48:45 +0000 (10:48 +0000)
committerVadim B. Mikheev <vadim4o@yahoo.com>
Sun, 22 Nov 1998 10:48:45 +0000 (10:48 +0000)
EXPLAIN all indices used.

src/backend/commands/explain.c
src/backend/executor/nodeIndexscan.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/outfuncs.c
src/backend/nodes/readfuncs.c
src/backend/optimizer/plan/createplan.c
src/backend/parser/gram.c

index f7bb3e5ec44155f1fd374ee6a715ef9a48e5bfb4..2f08297d0695be429f62398dbc8e8bbd097e7201 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.26 1998/11/08 19:38:34 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.27 1998/11/22 10:48:34 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -217,9 +217,14 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
        {
                case T_IndexScan:
                        appendStringInfo(str, " using ");
-                       l = ((IndexScan *) plan)->indxid;
-                       relation = RelationIdCacheGetRelation((int) lfirst(l));
-                       appendStringInfo(str, (RelationGetRelationName(relation))->data);
+                       i = 0;
+                       foreach (l, ((IndexScan *) plan)->indxid)
+                       {
+                               relation = RelationIdCacheGetRelation((int) lfirst(l));
+                               if (++i > 1)
+                                       appendStringInfo(str, ", ");
+                               appendStringInfo(str, (RelationGetRelationName(relation))->data);
+                       }
                case T_SeqScan:
                        if (((Scan *) plan)->scanrelid > 0)
                        {
index 2df3b98a44157f9aabc7d0734a869afc58a04c73..7a087f44140380c0dfc0b193011e584e336b1d33 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.27 1998/09/01 04:28:32 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.28 1998/11/22 10:48:36 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -154,7 +154,7 @@ IndexNext(IndexScan *node)
                                         prev_index++)
                                {
                                        scanstate->cstate.cs_ExprContext->ecxt_scantuple = slot;
-                                       if (ExecQual(nth(prev_index, node->indxqual),
+                                       if (ExecQual(nth(prev_index, node->indxqualorig),
                                                                 scanstate->cstate.cs_ExprContext))
                                        {
                                                prev_matches = true;
index 6213456b0d06d1f3851fe24ce7652d5edc93459b..5809a4044c3dc908c28fd4de08f651675fa7baa2 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.49 1998/10/22 13:52:20 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.50 1998/11/22 10:48:38 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -247,6 +247,7 @@ _copyIndexScan(IndexScan *from)
         */
        newnode->indxid = listCopy(from->indxid);
        Node_Copy(from, newnode, indxqual);
+       Node_Copy(from, newnode, indxqualorig);
        Node_Copy(from, newnode, indxstate);
 
        return newnode;
index f78eb73a15bb03f54ef3199404680900995dc2e9..33bba59d65bb8ea05916c9d5b44d8db7374ef6da 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.47 1998/10/22 13:52:21 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.48 1998/11/22 10:48:39 vadim Exp $
  *
  * NOTES
  *       Every (plan) node in POSTGRES has an associated "out" routine which
@@ -517,6 +517,9 @@ _outIndexScan(StringInfo str, IndexScan *node)
        appendStringInfo(str, " :indxqual ");
        _outNode(str, node->indxqual);
 
+       appendStringInfo(str, " :indxqualorig ");
+       _outNode(str, node->indxqualorig);
+
 }
 
 /*
index e56f92f483c047c804950172dc5511c4d42aa538..c915ed6ed74fdd4b02a8eb2471300765903c40e9 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.38 1998/10/22 13:52:22 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.39 1998/11/22 10:48:40 vadim Exp $
  *
  * NOTES
  *       Most of the read functions for plan nodes are tested. (In fact, they
@@ -546,6 +546,9 @@ _readIndexScan()
        token = lsptok(NULL, &length);          /* eat :indxqual */
        local_node->indxqual = nodeRead(true);          /* now read it */
 
+       token = lsptok(NULL, &length);          /* eat :indxqualorig */
+       local_node->indxqualorig = nodeRead(true);              /* now read it */
+
        return local_node;
 }
 
index 8eba20fd68c8ba67a5d838c9cffe311851473eda..ccde0f81ea959fdd4f7fd5e051f8a4b980fa0c19 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.32 1998/09/01 04:29:47 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.33 1998/11/22 10:48:43 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -63,7 +63,7 @@ static Node *fix_indxqual_references(Node *clause, Path *index_path);
 static Temp *make_temp(List *tlist, List *keys, Oid *operators,
                  Plan *plan_node, int temptype);
 static IndexScan *make_indexscan(List *qptlist, List *qpqual, Index scanrelid,
-                          List *indxid, List *indxqual, Cost cost);
+                          List *indxid, List *indxqual, List *indxqualorig, Cost cost);
 static NestLoop *make_nestloop(List *qptlist, List *qpqual, Plan *lefttree,
                          Plan *righttree);
 static HashJoin *make_hashjoin(List *tlist, List *qpqual,
@@ -405,6 +405,7 @@ create_indexscan_node(IndexPath *best_path,
                                           lfirsti(best_path->path.parent->relids),
                                           best_path->indexid,
                                           fixed_indxqual,
+                                          indxqual,
                                           best_path->path.path_cost);
 
        return scan_node;
@@ -937,6 +938,7 @@ make_indexscan(List *qptlist,
                           Index scanrelid,
                           List *indxid,
                           List *indxqual,
+                          List *indxqualorig,
                           Cost cost)
 {
        IndexScan  *node = makeNode(IndexScan);
@@ -951,6 +953,7 @@ make_indexscan(List *qptlist,
        node->scan.scanrelid = scanrelid;
        node->indxid = indxid;
        node->indxqual = indxqual;
+       node->indxqualorig = indxqualorig;
        node->scan.scanstate = (CommonScanState *) NULL;
 
        return node;
index e231932d8c73cbda3dc7885f6fc7367a38909bf2..997c65e808cb9e49bf9fadc4b7d856c701bdbefe 100644 (file)
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/parser/Attic/gram.c,v 2.48 1998/10/30 04:54:01 scrappy Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/parser/Attic/gram.c,v 2.49 1998/11/22 10:48:45 vadim Exp $
  *
  * HISTORY
  *       AUTHOR                        DATE                    MAJOR EVENT