*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.71 1999/02/15 03:21:58 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.72 1999/02/15 05:21:01 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* copy remainder of node
* ----------------
*/
- newnode->otherrels = listCopy(from->otherrels);
+ newnode->unjoined_rels = listCopy(from->unjoined_rels);
Node_Copy(from, newnode, jinfo_restrictinfo);
newnode->mergejoinable = from->mergejoinable;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.33 1999/02/15 03:21:59 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.34 1999/02/15 05:21:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
Assert(IsA(a, JoinInfo));
Assert(IsA(b, JoinInfo));
- if (!equal(a->otherrels, b->otherrels))
+ if (!equal(a->unjoined_rels, b->unjoined_rels))
return false;
if (!equal(a->jinfo_restrictinfo, b->jinfo_restrictinfo))
return false;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.11 1999/02/15 03:21:59 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.12 1999/02/15 05:21:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* free remainder of node
* ----------------
*/
- freeList(node->otherrels);
+ freeList(node->unjoined_rels);
freeObject(node->jinfo_restrictinfo);
pfree(node);
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: outfuncs.c,v 1.73 1999/02/15 03:21:59 momjian Exp $
+ * $Id: outfuncs.c,v 1.74 1999/02/15 05:21:02 momjian Exp $
*
* NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which
static void
_outJoinInfo(StringInfo str, JoinInfo *node)
{
- appendStringInfo(str, " JINFO :otherrels ");
- _outIntList(str, node->otherrels);
+ appendStringInfo(str, " JINFO :unjoined_rels ");
+ _outIntList(str, node->unjoined_rels);
appendStringInfo(str, " :jinfo_restrictinfo ");
_outNode(str, node->jinfo_restrictinfo);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.57 1999/02/13 23:16:02 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.58 1999/02/15 05:21:03 momjian Exp $
*
* NOTES
* Most of the read functions for plan nodes are tested. (In fact, they
local_node = makeNode(JoinInfo);
- token = lsptok(NULL, &length); /* get :otherrels */
- local_node->otherrels = toIntList(nodeRead(true)); /* now read it */
+ token = lsptok(NULL, &length); /* get :unjoined_rels */
+ local_node->unjoined_rels = toIntList(nodeRead(true)); /* now read it */
token = lsptok(NULL, &length); /* get :jinfo_restrictinfo */
local_node->jinfo_restrictinfo = nodeRead(true); /* now read it */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.36 1999/02/15 03:59:27 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.37 1999/02/15 05:21:03 momjian Exp $
*
*-------------------------------------------------------------------------
*/
int32 _use_geqo_rels_ = GEQO_RELS;
-static void find_base_rel_paths(Query *root, List *rels);
-static RelOptInfo *make_one_rel_by_joins(Query *root, List *outer_rels, int levels_needed);
+static void set_base_rel_pathlist(Query *root, List *rels);
+static RelOptInfo *make_one_rel_by_joins(Query *root, List *rels,
+ int levels_needed);
#ifdef OPTIMIZER_DEBUG
static void debug_print_rel(Query *root, RelOptInfo *rel);
if (levels_needed <= 0)
return NULL;
- find_base_rel_paths(root, rels);
+ set_base_rel_pathlist(root, rels);
if (levels_needed <= 1)
{
else
{
/*
- * this means that joins or sorts are required. set selectivities
+ * This means that joins or sorts are required. set selectivities
* of clauses that have not been set by an index.
*/
set_rest_relselec(root, rels);
}
/*
- * find_base_rel_paths
+ * set_base_rel_pathlist
* Finds all paths available for scanning each relation entry in
* 'rels'. Sequential scan and any available indices are considered
* if possible(indices are not considered for lower nesting levels).
* MODIFIES: rels
*/
static void
-find_base_rel_paths(Query *root, List *rels)
+set_base_rel_pathlist(Query *root, List *rels)
{
List *temp;
* Find all possible joinpaths(bushy trees) for a query by systematically
* finding ways to join relations(both original and derived) together.
*
- * 'outer_rels' is the current list of relations for which join paths
+ * 'rels' is the current list of relations for which join paths
* are to be found, i.e., the current list of relations that
* have already been derived.
* 'levels_needed' is the number of iterations needed
* the result of joining all the original relations together.
*/
static RelOptInfo *
-make_one_rel_by_joins(Query *root, List *outer_rels, int levels_needed)
+make_one_rel_by_joins(Query *root, List *rels, int levels_needed)
{
List *x;
List *joined_rels = NIL;
{
/*
* Determine all possible pairs of relations to be joined at this
- * level. Determine paths for joining these relation pairs and
+ * level. Determine paths for joining these relation pairs and
* modify 'joined_rels' accordingly, then eliminate redundant join
* relations.
*/
- joined_rels = make_rels_by_joins(root, outer_rels);
+ joined_rels = make_rels_by_joins(root, rels);
update_rels_pathlist_for_joins(root, joined_rels);
* involves the join relation to the joininfo list of the
* other relation
*/
- add_rel_to_rel_joininfos(root, joined_rels, outer_rels);
+ add_rel_to_rel_joininfos(root, joined_rels, rels);
}
#endif
* prune rels that have been completely incorporated into new
* join rels
*/
- outer_rels = del_rels_all_bushy_inactive(outer_rels);
+ rels = del_rels_all_bushy_inactive(rels);
/*
* merge join rels if then contain the same list of base rels
*/
- outer_rels = merge_rels_with_same_relids(joined_rels, outer_rels);
- root->join_rel_list = outer_rels;
+ joined_rels = merge_rels_with_same_relids(joined_rels, rels);
}
- else
#endif
- root->join_rel_list = joined_rels;
-
-#ifdef NOT_USED
- if (!BushyPlanFlag)
-#endif
- outer_rels = joined_rels;
-
+ root->join_rel_list = rels = joined_rels;
}
- Assert(length(joined_rels) == 1);
+ Assert(BushyPlanFlag || length(rels) == 1);
#ifdef NOT_USED
if (BushyPlanFlag)
- return final_join_rels(outer_rels);
+ return get_cheapest_complete_rel(rels);
else
#endif
- return lfirst(joined_rels);
+ return lfirst(rels);
}
/*****************************************************************************
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.47 1999/02/15 03:22:05 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.48 1999/02/15 05:21:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
List *clauses = lfirst(clausegroups);
- ((RestrictInfo *) lfirst(clauses))->restrictinfojoinid = joininfo->otherrels;
+ ((RestrictInfo *) lfirst(clauses))->restrictinfojoinid = joininfo->unjoined_rels;
}
cg_list = nconc(cg_list, clausegroups);
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.24 1999/02/15 03:59:27 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.25 1999/02/15 05:21:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (!joininfo->bushy_inactive)
{
- List *other_rels = joininfo->otherrels;
+ List *unjoined_rels = joininfo->unjoined_rels;
- if (other_rels != NIL)
+ if (unjoined_rels != NIL)
{
- if (length(other_rels) == 1 &&
+ if (length(unjoined_rels) == 1 &&
(only_relids == NIL ||
/* geqo only wants certain relids to make new rels */
- same(joininfo->otherrels, only_relids)))
+ same(joininfo->unjoined_rels, only_relids)))
{
rel = make_join_rel(outer_rel,
- get_base_rel(root, lfirsti(other_rels)),
+ get_base_rel(root, lfirsti(unjoined_rels)),
joininfo);
/* how about right-sided plan ? */
if (_use_right_sided_plans_ &&
if (rel != NULL)
join_list = lappend(join_list, rel);
rel = make_join_rel(get_base_rel(root,
- lfirsti(other_rels)),
+ lfirsti(unjoined_rels)),
outer_rel,
joininfo);
}
else if (BushyPlanFlag)
{
rel = make_join_rel(outer_rel,
- get_join_rel(root, other_rels),
+ get_join_rel(root, unjoined_rels),
joininfo);
}
#endif
new_joininfo_list(List *joininfo_list, List *join_relids)
{
List *current_joininfo_list = NIL;
- List *new_otherrels = NIL;
+ List *new_unjoined_rels = NIL;
JoinInfo *other_joininfo = (JoinInfo *) NULL;
List *xjoininfo = NIL;
List *or;
JoinInfo *joininfo = (JoinInfo *) lfirst(xjoininfo);
- new_otherrels = joininfo->otherrels;
- foreach(or, new_otherrels)
+ new_unjoined_rels = joininfo->unjoined_rels;
+ foreach(or, new_unjoined_rels)
{
if (intMember(lfirsti(or), join_relids))
- new_otherrels = lremove((void *) lfirst(or), new_otherrels);
+ new_unjoined_rels = lremove((void *) lfirst(or), new_unjoined_rels);
}
- joininfo->otherrels = new_otherrels;
- if (new_otherrels != NIL)
+ joininfo->unjoined_rels = new_unjoined_rels;
+ if (new_unjoined_rels != NIL)
{
- other_joininfo = joininfo_member(new_otherrels,
+ other_joininfo = joininfo_member(new_unjoined_rels,
current_joininfo_list);
if (other_joininfo)
{
{
other_joininfo = makeNode(JoinInfo);
- other_joininfo->otherrels = joininfo->otherrels;
+ other_joininfo->unjoined_rels = joininfo->unjoined_rels;
other_joininfo->jinfo_restrictinfo = joininfo->jinfo_restrictinfo;
other_joininfo->mergejoinable = joininfo->mergejoinable;
other_joininfo->hashjoinable = joininfo->hashjoinable;
foreach(xjoininfo, joinrel->joininfo)
{
JoinInfo *joininfo = (JoinInfo *) lfirst(xjoininfo);
- List *other_rels = joininfo->otherrels;
+ List *unjoined_rels = joininfo->unjoined_rels;
List *restrict_info = joininfo->jinfo_restrictinfo;
bool mergejoinable = joininfo->mergejoinable;
bool hashjoinable = joininfo->hashjoinable;
- foreach(xrelid, other_rels)
+ foreach(xrelid, unjoined_rels)
{
Relid relid = (Relid) lfirst(xrelid);
RelOptInfo *rel = get_join_rel(root, relid);
List *xsuper_rel = NIL;
JoinInfo *new_joininfo = makeNode(JoinInfo);
- new_joininfo->otherrels = joinrel->relids;
+ new_joininfo->unjoined_rels = joinrel->relids;
new_joininfo->jinfo_restrictinfo = restrict_info;
new_joininfo->mergejoinable = mergejoinable;
new_joininfo->hashjoinable = hashjoinable;
{
JoinInfo *new_joininfo = makeNode(JoinInfo);
- new_joininfo->otherrels = new_relids;
+ new_joininfo->unjoined_rels = new_relids;
new_joininfo->jinfo_restrictinfo = restrict_info;
new_joininfo->mergejoinable = mergejoinable;
new_joininfo->hashjoinable = hashjoinable;
#ifdef NOT_USED
/*
- * final_join_rels
+ * get_cheapest_complete_rel
* Find the join relation that includes all the original
* relations, i.e. the final join result.
*
* Returns the list of final join relations.
*/
RelOptInfo *
-final_join_rels(List *join_rel_list)
+get_cheapest_complete_rel(List *join_rel_list)
{
List *xrel = NIL;
RelOptInfo *final_rel = NULL;
/*
* find the relations that has no further joins, i.e., its joininfos
- * all have otherrels nil.
+ * all have unjoined_rels nil.
*/
foreach(xrel, join_rel_list)
{
{
JoinInfo *joininfo = (JoinInfo *) lfirst(xjoininfo);
- if (joininfo->otherrels != NIL)
+ if (joininfo->unjoined_rels != NIL)
{
final = false;
break;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.34 1999/02/15 03:59:27 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.35 1999/02/15 05:21:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "utils/elog.h"
-static List *merge_rel_with_same_relids(RelOptInfo *rel, List *other_rels);
+static List *merge_rel_with_same_relids(RelOptInfo *rel, List *unjoined_rels);
/*
* merge_rels_with_same_relids
}
/*
- * merge_rel_with_same_relids
- * Prunes those relations from 'other_rels' that are redundant with
+ * merge_rel_with_same_relids
+ * Prunes those relations from 'unjoined_rels' that are redundant with
* 'rel'. A relation is redundant if it is built up of the same
* relations as 'rel'. Paths for the redundant relation are merged into
* the pathlist of 'rel'.
*
*/
static List *
-merge_rel_with_same_relids(RelOptInfo *rel, List *other_rels)
+merge_rel_with_same_relids(RelOptInfo *rel, List *unjoined_rels)
{
List *i = NIL;
List *result = NIL;
- foreach(i, other_rels)
+ foreach(i, unjoined_rels)
{
- RelOptInfo *other_rel = (RelOptInfo *) lfirst(i);
+ RelOptInfo *unjoined_rel = (RelOptInfo *) lfirst(i);
- if (same(rel->relids, other_rel->relids))
+ if (same(rel->relids, unjoined_rel->relids))
/*
* This are on the same relations,
* so get the best of their pathlists.
*/
rel->pathlist = add_pathlist(rel,
rel->pathlist,
- other_rel->pathlist);
+ unjoined_rel->pathlist);
else
- result = lappend(result, other_rel);
+ result = lappend(result, unjoined_rel);
}
return result;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.26 1999/02/15 03:22:11 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.27 1999/02/15 05:21:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
foreach(join_relid, join_relids)
{
JoinInfo *joininfo;
- List *other_rels = NIL;
+ List *unjoined_rels = NIL;
List *rel;
foreach(rel, join_relids)
{
if (lfirsti(rel) != lfirsti(join_relid))
- other_rels = lappendi(other_rels, lfirsti(rel));
+ unjoined_rels = lappendi(unjoined_rels, lfirsti(rel));
}
joininfo = find_joininfo_node(get_base_rel(root, lfirsti(join_relid)),
- other_rels);
- joininfo->jinfo_restrictinfo = lcons(copyObject((void *) restrictinfo), joininfo->jinfo_restrictinfo);
+ unjoined_rels);
+ joininfo->jinfo_restrictinfo = lcons(copyObject((void *) restrictinfo),
+ joininfo->jinfo_restrictinfo);
}
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.16 1999/02/15 03:22:16 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.17 1999/02/15 05:21:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
foreach(i, joininfo_list)
{
other_rels = lfirst(i);
- if (same(join_relids, ((JoinInfo *) other_rels)->otherrels))
+ if (same(join_relids, ((JoinInfo *) other_rels)->unjoined_rels))
return (JoinInfo *) other_rels;
}
return (JoinInfo *) NULL;
if (joininfo == NULL)
{
joininfo = makeNode(JoinInfo);
- joininfo->otherrels = join_relids;
+ joininfo->unjoined_rels = join_relids;
joininfo->jinfo_restrictinfo = NIL;
joininfo->mergejoinable = false;
joininfo->hashjoinable = false;
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: relation.h,v 1.24 1999/02/15 03:22:23 momjian Exp $
+ * $Id: relation.h,v 1.25 1999/02/15 05:21:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
typedef struct JoinInfo
{
NodeTag type;
- List *otherrels;
+ List *unjoined_rels;
List *jinfo_restrictinfo;
bool mergejoinable;
bool hashjoinable;