diff options
Diffstat (limited to 'src/backend/optimizer/path')
-rw-r--r-- | src/backend/optimizer/path/indxpath.c | 24 | ||||
-rw-r--r-- | src/backend/optimizer/path/joinrels.c | 16 |
2 files changed, 30 insertions, 10 deletions
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index 984c930e3a6..228a876f71a 100644 --- a/src/backend/optimizer/path/indxpath.c +++ b/src/backend/optimizer/path/indxpath.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.129 2002/12/15 16:17:49 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.130 2002/12/16 21:30:29 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1398,6 +1398,7 @@ best_inner_indexscan(Query *root, RelOptInfo *rel, List *ilist; List *jlist; InnerIndexscanInfo *info; + MemoryContext oldcontext; /* * Nestloop only supports inner and left joins. @@ -1415,15 +1416,27 @@ best_inner_indexscan(Query *root, RelOptInfo *rel, } /* * If there are no indexable joinclauses for this rel, exit quickly. - * Otherwise, intersect the given outer_relids with index_outer_relids - * to find the set of outer relids actually relevant for this index. - * If there are none, again we can fail immediately. */ if (!rel->index_outer_relids) return NULL; + /* + * Otherwise, we have to do path selection in the memory context of + * the given rel, so that any created path can be safely attached to + * the rel's cache of best inner paths. (This is not currently an + * issue for normal planning, but it is an issue for GEQO planning.) + */ + oldcontext = MemoryContextSwitchTo(GetMemoryChunkContext(rel)); + /* + * Intersect the given outer_relids with index_outer_relids + * to find the set of outer relids actually relevant for this index. + * If there are none, again we can fail immediately. + */ outer_relids = set_intersecti(rel->index_outer_relids, outer_relids); if (!outer_relids) + { + MemoryContextSwitchTo(oldcontext); return NULL; + } /* * Look to see if we already computed the result for this set of * relevant outerrels. (We include the isouterjoin status in the @@ -1437,6 +1450,7 @@ best_inner_indexscan(Query *root, RelOptInfo *rel, info->isouterjoin == isouterjoin) { freeList(outer_relids); + MemoryContextSwitchTo(oldcontext); return info->best_innerpath; } } @@ -1517,6 +1531,8 @@ best_inner_indexscan(Query *root, RelOptInfo *rel, info->best_innerpath = cheapest; rel->index_inner_paths = lcons(info, rel->index_inner_paths); + MemoryContextSwitchTo(oldcontext); + return cheapest; } diff --git a/src/backend/optimizer/path/joinrels.c b/src/backend/optimizer/path/joinrels.c index 58772c0bc03..037733d5d72 100644 --- a/src/backend/optimizer/path/joinrels.c +++ b/src/backend/optimizer/path/joinrels.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.57 2002/06/20 20:29:30 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.58 2002/12/16 21:30:30 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -18,8 +18,12 @@ #include "optimizer/paths.h" -static RelOptInfo *make_join_rel(Query *root, RelOptInfo *rel1, - RelOptInfo *rel2, JoinType jointype); +static List *make_rels_by_clause_joins(Query *root, + RelOptInfo *old_rel, + List *other_rels); +static List *make_rels_by_clauseless_joins(Query *root, + RelOptInfo *old_rel, + List *other_rels); /* @@ -246,7 +250,7 @@ make_rels_by_joins(Query *root, int level, List **joinrels) * no extra test for overlap for initial rels, since the is_subset test can * only succeed when other_rel is not already part of old_rel.) */ -List * +static List * make_rels_by_clause_joins(Query *root, RelOptInfo *old_rel, List *other_rels) @@ -297,7 +301,7 @@ make_rels_by_clause_joins(Query *root, * Currently, this is only used with initial rels in other_rels, but it would * work for joining to joinrels too. */ -List * +static List * make_rels_by_clauseless_joins(Query *root, RelOptInfo *old_rel, List *other_rels) @@ -392,7 +396,7 @@ make_jointree_rel(Query *root, Node *jtnode) * (The join rel may already contain paths generated from other * pairs of rels that add up to the same set of base rels.) */ -static RelOptInfo * +RelOptInfo * make_join_rel(Query *root, RelOptInfo *rel1, RelOptInfo *rel2, JoinType jointype) { |