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

Commit bb80f8a

Browse files
committed
Fix merging pathes of pruned rels ("indices are unused" problem).
1 parent 91964bd commit bb80f8a

File tree

1 file changed

+11
-25
lines changed

1 file changed

+11
-25
lines changed

src/backend/optimizer/path/prune.c

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.12 1998/02/26 04:32:43 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.13 1998/04/02 07:27:15 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -61,39 +61,25 @@ prune_joinrels(List *rel_list)
6161
static List *
6262
prune_joinrel(Rel *rel, List *other_rels)
6363
{
64-
List *cur = NIL;
65-
List *return_list = NIL;
64+
List *i = NIL;
65+
List *result = NIL;
6666

67-
/* find first relation that doesn't match */
68-
foreach(cur, other_rels)
67+
foreach(i, other_rels)
6968
{
70-
Rel *other_rel = (Rel *) lfirst(cur);
71-
72-
if (!same(rel->relids, other_rel->relids))
73-
break;
74-
}
75-
76-
/* we now know cur doesn't match, or is NIL */
77-
return_list = cur;
78-
79-
/*
80-
* remove relations that do match, we use lnext so we can remove
81-
* easily
82-
*/
83-
while (cur != NIL && lnext(cur) != NIL)
84-
{
85-
Rel *other_rel = (Rel *) lfirst(lnext(cur));
86-
69+
Rel *other_rel = (Rel *) lfirst(i);
70+
8771
if (same(rel->relids, other_rel->relids))
8872
{
8973
rel->pathlist = add_pathlist(rel,
9074
rel->pathlist,
9175
other_rel->pathlist);
92-
lnext(cur) = lnext(lnext(cur)); /* delete it */
9376
}
94-
cur = lnext(cur);
77+
else
78+
{
79+
result = nconc(result, lcons(other_rel, NIL));
80+
}
9581
}
96-
return return_list;
82+
return (result);
9783
}
9884

9985
/*

0 commit comments

Comments
 (0)