Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3468093

Browse files
committed
Fix using indices in OR.
EXPLAIN all indices used.
1 parent 1f00f0d commit 3468093

File tree

7 files changed

+27
-12
lines changed

7 files changed

+27
-12
lines changed

src/backend/commands/explain.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.26 1998/11/08 19:38:34 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.27 1998/11/22 10:48:34 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -217,9 +217,14 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
217217
{
218218
case T_IndexScan:
219219
appendStringInfo(str, " using ");
220-
l = ((IndexScan *) plan)->indxid;
221-
relation = RelationIdCacheGetRelation((int) lfirst(l));
222-
appendStringInfo(str, (RelationGetRelationName(relation))->data);
220+
i = 0;
221+
foreach (l, ((IndexScan *) plan)->indxid)
222+
{
223+
relation = RelationIdCacheGetRelation((int) lfirst(l));
224+
if (++i > 1)
225+
appendStringInfo(str, ", ");
226+
appendStringInfo(str, (RelationGetRelationName(relation))->data);
227+
}
223228
case T_SeqScan:
224229
if (((Scan *) plan)->scanrelid > 0)
225230
{

src/backend/executor/nodeIndexscan.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.27 1998/09/01 04:28:32 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.28 1998/11/22 10:48:36 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -154,7 +154,7 @@ IndexNext(IndexScan *node)
154154
prev_index++)
155155
{
156156
scanstate->cstate.cs_ExprContext->ecxt_scantuple = slot;
157-
if (ExecQual(nth(prev_index, node->indxqual),
157+
if (ExecQual(nth(prev_index, node->indxqualorig),
158158
scanstate->cstate.cs_ExprContext))
159159
{
160160
prev_matches = true;

src/backend/nodes/copyfuncs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.49 1998/10/22 13:52:20 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.50 1998/11/22 10:48:38 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -247,6 +247,7 @@ _copyIndexScan(IndexScan *from)
247247
*/
248248
newnode->indxid = listCopy(from->indxid);
249249
Node_Copy(from, newnode, indxqual);
250+
Node_Copy(from, newnode, indxqualorig);
250251
Node_Copy(from, newnode, indxstate);
251252

252253
return newnode;

src/backend/nodes/outfuncs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.47 1998/10/22 13:52:21 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.48 1998/11/22 10:48:39 vadim Exp $
1111
*
1212
* NOTES
1313
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -517,6 +517,9 @@ _outIndexScan(StringInfo str, IndexScan *node)
517517
appendStringInfo(str, " :indxqual ");
518518
_outNode(str, node->indxqual);
519519

520+
appendStringInfo(str, " :indxqualorig ");
521+
_outNode(str, node->indxqualorig);
522+
520523
}
521524

522525
/*

src/backend/nodes/readfuncs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.38 1998/10/22 13:52:22 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.39 1998/11/22 10:48:40 vadim Exp $
1111
*
1212
* NOTES
1313
* Most of the read functions for plan nodes are tested. (In fact, they
@@ -546,6 +546,9 @@ _readIndexScan()
546546
token = lsptok(NULL, &length); /* eat :indxqual */
547547
local_node->indxqual = nodeRead(true); /* now read it */
548548

549+
token = lsptok(NULL, &length); /* eat :indxqualorig */
550+
local_node->indxqualorig = nodeRead(true); /* now read it */
551+
549552
return local_node;
550553
}
551554

src/backend/optimizer/plan/createplan.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.32 1998/09/01 04:29:47 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.33 1998/11/22 10:48:43 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -63,7 +63,7 @@ static Node *fix_indxqual_references(Node *clause, Path *index_path);
6363
static Temp *make_temp(List *tlist, List *keys, Oid *operators,
6464
Plan *plan_node, int temptype);
6565
static IndexScan *make_indexscan(List *qptlist, List *qpqual, Index scanrelid,
66-
List *indxid, List *indxqual, Cost cost);
66+
List *indxid, List *indxqual, List *indxqualorig, Cost cost);
6767
static NestLoop *make_nestloop(List *qptlist, List *qpqual, Plan *lefttree,
6868
Plan *righttree);
6969
static HashJoin *make_hashjoin(List *tlist, List *qpqual,
@@ -405,6 +405,7 @@ create_indexscan_node(IndexPath *best_path,
405405
lfirsti(best_path->path.parent->relids),
406406
best_path->indexid,
407407
fixed_indxqual,
408+
indxqual,
408409
best_path->path.path_cost);
409410

410411
return scan_node;
@@ -937,6 +938,7 @@ make_indexscan(List *qptlist,
937938
Index scanrelid,
938939
List *indxid,
939940
List *indxqual,
941+
List *indxqualorig,
940942
Cost cost)
941943
{
942944
IndexScan *node = makeNode(IndexScan);
@@ -951,6 +953,7 @@ make_indexscan(List *qptlist,
951953
node->scan.scanrelid = scanrelid;
952954
node->indxid = indxid;
953955
node->indxqual = indxqual;
956+
node->indxqualorig = indxqualorig;
954957
node->scan.scanstate = (CommonScanState *) NULL;
955958

956959
return node;

src/backend/parser/gram.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229
*
230230
*
231231
* IDENTIFICATION
232-
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/gram.c,v 2.48 1998/10/30 04:54:01 scrappy Exp $
232+
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/gram.c,v 2.49 1998/11/22 10:48:45 vadim Exp $
233233
*
234234
* HISTORY
235235
* AUTHOR DATE MAJOR EVENT

0 commit comments

Comments
 (0)