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

Commit f2ed835

Browse files
committed
Fix some typos in geqo optimizer --- it now generates
reasonable plans again. Still eats memory like there's no tomorrow, however :-(.
1 parent cf11642 commit f2ed835

File tree

1 file changed

+14
-37
lines changed

1 file changed

+14
-37
lines changed

src/backend/optimizer/geqo/geqo_eval.c

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 1994, Regents of the University of California
77
*
8-
* $Id: geqo_eval.c,v 1.35 1999/02/18 05:26:18 momjian Exp $
8+
* $Id: geqo_eval.c,v 1.36 1999/05/16 19:45:00 tgl Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -48,8 +48,6 @@
4848
#include "optimizer/geqo_gene.h"
4949
#include "optimizer/geqo.h"
5050

51-
static RelOptInfo *geqo_nth(int stop, List *rels);
52-
5351
/*
5452
* geqo_eval
5553
*
@@ -62,31 +60,28 @@ geqo_eval(Query *root, Gene *tour, int num_gene)
6260
Cost fitness;
6361
List *temp;
6462

65-
66-
/* remember root->join_rel_list ... */
67-
/* because root->join_rel_list will be changed during the following */
63+
/* remember root->join_rel_list ... */
64+
/* because root->join_rel_list will be changed during the following */
6865
temp = listCopy(root->join_rel_list);
6966

70-
/* joinrel is readily processed query tree -- left-sided ! */
67+
/* joinrel is readily processed query tree -- left-sided ! */
7168
joinrel = gimme_tree(root, tour, 0, num_gene, NULL);
7269

73-
/* compute fitness */
70+
/* compute fitness */
7471
fitness = (Cost) joinrel->cheapestpath->path_cost;
7572

76-
root->join_rel_list = listCopy(temp);
73+
root->join_rel_list = temp;
7774

7875
pfree(joinrel);
79-
freeList(temp);
8076

8177
return fitness;
82-
8378
}
8479

8580
/*
8681
* gimme_tree
8782
* this program presumes that only LEFT-SIDED TREES are considered!
8883
*
89-
* 'old_rel' is the preceeding join
84+
* 'old_rel' is the preceding join
9085
*
9186
* Returns a new join relation incorporating all joins in a left-sided tree.
9287
*/
@@ -95,17 +90,16 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *old
9590
{
9691
RelOptInfo *inner_rel; /* current relation */
9792
int base_rel_index;
98-
99-
List *new_rels = NIL;
100-
RelOptInfo *new_rel = NULL;
93+
List *new_rels;
94+
RelOptInfo *new_rel;
10195

10296
if (rel_count < num_gene)
10397
{ /* tree not yet finished */
10498

10599
/* tour[0] = 3; tour[1] = 1; tour[2] = 2 */
106100
base_rel_index = (int) tour[rel_count];
107101

108-
inner_rel = (RelOptInfo *) geqo_nth(base_rel_index, root->base_rel_list);
102+
inner_rel = (RelOptInfo *) nth(base_rel_index-1, root->base_rel_list);
109103

110104
if (rel_count == 0)
111105
{ /* processing first join with
@@ -116,11 +110,11 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *old
116110
else
117111
{ /* tree main part */
118112
if (!(new_rels = make_rels_by_clause_joins(root, old_rel,
119-
inner_rel->joininfo,
113+
old_rel->joininfo,
120114
inner_rel->relids)))
121115
{
122116
new_rels = make_rels_by_clauseless_joins(old_rel,
123-
lcons(inner_rel,NIL));
117+
lcons(inner_rel,NIL));
124118
/* we don't do bushy plans in geqo, do we? bjm 02/18/1999
125119
new_rels = append(new_rels,
126120
make_rels_by_clauseless_joins(old_rel,
@@ -151,12 +145,12 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *old
151145
elog(DEBUG, "gimme_tree: still %d relations left", length(new_rels));
152146
}
153147

148+
rels_set_cheapest(new_rels);
149+
154150
/* get essential new relation */
155151
new_rel = (RelOptInfo *) lfirst(new_rels);
156152
rel_count++;
157153

158-
set_cheapest(new_rel, new_rel->pathlist);
159-
160154
/* processing of other new_rel attributes */
161155
if (new_rel->size <= 0)
162156
new_rel->size = compute_rel_size(new_rel);
@@ -166,24 +160,7 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *old
166160

167161
return gimme_tree(root, tour, rel_count, num_gene, new_rel);
168162
}
169-
170163
}
171164

172165
return old_rel; /* tree finished ... */
173166
}
174-
175-
static RelOptInfo *
176-
geqo_nth(int stop, List *rels)
177-
{
178-
List *r;
179-
int i = 1;
180-
181-
foreach(r, rels)
182-
{
183-
if (i == stop)
184-
return lfirst(r);
185-
i++;
186-
}
187-
elog(ERROR, "geqo_nth: Internal error - ran off end of list");
188-
return NULL; /* to keep compiler happy */
189-
}

0 commit comments

Comments
 (0)