diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-01-20 18:55:07 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-01-20 18:55:07 +0000 |
| commit | bdfbfde1b168b3332c4cdac34ac86a80aaf4d442 (patch) | |
| tree | f35bf1af04733069f3a6b0a2698ac10dbd6544ed /src/backend/optimizer/geqo/geqo_eval.c | |
| parent | be2b660ecd5ca205570825633e7b8479379ddc64 (diff) | |
| download | postgresql-bdfbfde1b168b3332c4cdac34ac86a80aaf4d442.tar.gz | |
IN clauses appearing at top level of WHERE can now be handled as joins.
There are two implementation techniques: the executor understands a new
JOIN_IN jointype, which emits at most one matching row per left-hand row,
or the result of the IN's sub-select can be fed through a DISTINCT filter
and then joined as an ordinary relation.
Along the way, some minor code cleanup in the optimizer; notably, break
out most of the jointree-rearrangement preprocessing in planner.c and
put it in a new file prep/prepjointree.c.
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); |
