diff options
Diffstat (limited to 'src/backend/optimizer/geqo/geqo_eval.c')
| -rw-r--r-- | src/backend/optimizer/geqo/geqo_eval.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/backend/optimizer/geqo/geqo_eval.c b/src/backend/optimizer/geqo/geqo_eval.c index 91b6c75e8e..d53a160a4e 100644 --- a/src/backend/optimizer/geqo/geqo_eval.c +++ b/src/backend/optimizer/geqo/geqo_eval.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/geqo_eval.c,v 1.60 2002/12/16 21:30:29 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/geqo_eval.c,v 1.61 2003/01/20 18:54:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -22,8 +22,8 @@ #include "postgres.h" #include <float.h> -#include <math.h> #include <limits.h> +#include <math.h> #include "optimizer/geqo.h" #include "optimizer/pathnode.h" @@ -91,7 +91,10 @@ geqo_eval(Query *root, List *initial_rels, Gene *tour, int num_gene) * XXX geqo does not currently support optimization for partial result * retrieval --- how to fix? */ - fitness = joinrel->cheapest_total_path->total_cost; + if (joinrel) + fitness = joinrel->cheapest_total_path->total_cost; + else + fitness = DBL_MAX; /* restore join_rel_list */ root->join_rel_list = savelist; @@ -113,7 +116,7 @@ geqo_eval(Query *root, List *initial_rels, Gene *tour, int num_gene) * 'tour' is the proposed join order, of length 'num_gene' * * Returns a new join relation whose cheapest path is the best plan for - * this join order. + * this join order. NB: will return NULL if join order is invalid. * * Note that at each step we consider using the next rel as both left and * right side of a join. However, we cannot build general ("bushy") plan @@ -154,6 +157,10 @@ gimme_tree(Query *root, List *initial_rels, */ new_rel = make_join_rel(root, joinrel, inner_rel, JOIN_INNER); + /* Fail if join order is not valid */ + if (new_rel == NULL) + return NULL; + /* Find and save the cheapest paths for this rel */ set_cheapest(new_rel); |
