Commit c5449d53 authored by Bruce Momjian's avatar Bruce Momjian

otherrels is now unjoined_rels

parent 82682ff3
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1428,7 +1428,7 @@ _copyJoinInfo(JoinInfo *from) ...@@ -1428,7 +1428,7 @@ _copyJoinInfo(JoinInfo *from)
* copy remainder of node * copy remainder of node
* ---------------- * ----------------
*/ */
newnode->otherrels = listCopy(from->otherrels); newnode->unjoined_rels = listCopy(from->unjoined_rels);
Node_Copy(from, newnode, jinfo_restrictinfo); Node_Copy(from, newnode, jinfo_restrictinfo);
newnode->mergejoinable = from->mergejoinable; newnode->mergejoinable = from->mergejoinable;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -526,7 +526,7 @@ _equalJoinInfo(JoinInfo *a, JoinInfo *b) ...@@ -526,7 +526,7 @@ _equalJoinInfo(JoinInfo *a, JoinInfo *b)
{ {
Assert(IsA(a, JoinInfo)); Assert(IsA(a, JoinInfo));
Assert(IsA(b, JoinInfo)); Assert(IsA(b, JoinInfo));
if (!equal(a->otherrels, b->otherrels)) if (!equal(a->unjoined_rels, b->unjoined_rels))
return false; return false;
if (!equal(a->jinfo_restrictinfo, b->jinfo_restrictinfo)) if (!equal(a->jinfo_restrictinfo, b->jinfo_restrictinfo))
return false; return false;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1024,7 +1024,7 @@ _freeJoinInfo(JoinInfo *node) ...@@ -1024,7 +1024,7 @@ _freeJoinInfo(JoinInfo *node)
* free remainder of node * free remainder of node
* ---------------- * ----------------
*/ */
freeList(node->otherrels); freeList(node->unjoined_rels);
freeObject(node->jinfo_restrictinfo); freeObject(node->jinfo_restrictinfo);
pfree(node); pfree(node);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * 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 * NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which * Every (plan) node in POSTGRES has an associated "out" routine which
...@@ -1198,8 +1198,8 @@ _outHashInfo(StringInfo str, HashInfo *node) ...@@ -1198,8 +1198,8 @@ _outHashInfo(StringInfo str, HashInfo *node)
static void static void
_outJoinInfo(StringInfo str, JoinInfo *node) _outJoinInfo(StringInfo str, JoinInfo *node)
{ {
appendStringInfo(str, " JINFO :otherrels "); appendStringInfo(str, " JINFO :unjoined_rels ");
_outIntList(str, node->otherrels); _outIntList(str, node->unjoined_rels);
appendStringInfo(str, " :jinfo_restrictinfo "); appendStringInfo(str, " :jinfo_restrictinfo ");
_outNode(str, node->jinfo_restrictinfo); _outNode(str, node->jinfo_restrictinfo);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* Most of the read functions for plan nodes are tested. (In fact, they * Most of the read functions for plan nodes are tested. (In fact, they
...@@ -1982,8 +1982,8 @@ _readJoinInfo() ...@@ -1982,8 +1982,8 @@ _readJoinInfo()
local_node = makeNode(JoinInfo); local_node = makeNode(JoinInfo);
token = lsptok(NULL, &length); /* get :otherrels */ token = lsptok(NULL, &length); /* get :unjoined_rels */
local_node->otherrels = toIntList(nodeRead(true)); /* now read it */ local_node->unjoined_rels = toIntList(nodeRead(true)); /* now read it */
token = lsptok(NULL, &length); /* get :jinfo_restrictinfo */ token = lsptok(NULL, &length); /* get :jinfo_restrictinfo */
local_node->jinfo_restrictinfo = nodeRead(true); /* now read it */ local_node->jinfo_restrictinfo = nodeRead(true); /* now read it */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -43,8 +43,9 @@ bool _use_geqo_ = false; ...@@ -43,8 +43,9 @@ bool _use_geqo_ = false;
int32 _use_geqo_rels_ = GEQO_RELS; int32 _use_geqo_rels_ = GEQO_RELS;
static void find_base_rel_paths(Query *root, List *rels); static void set_base_rel_pathlist(Query *root, List *rels);
static RelOptInfo *make_one_rel_by_joins(Query *root, List *outer_rels, int levels_needed); static RelOptInfo *make_one_rel_by_joins(Query *root, List *rels,
int levels_needed);
#ifdef OPTIMIZER_DEBUG #ifdef OPTIMIZER_DEBUG
static void debug_print_rel(Query *root, RelOptInfo *rel); static void debug_print_rel(Query *root, RelOptInfo *rel);
...@@ -71,7 +72,7 @@ make_one_rel(Query *root, List *rels) ...@@ -71,7 +72,7 @@ make_one_rel(Query *root, List *rels)
if (levels_needed <= 0) if (levels_needed <= 0)
return NULL; return NULL;
find_base_rel_paths(root, rels); set_base_rel_pathlist(root, rels);
if (levels_needed <= 1) if (levels_needed <= 1)
{ {
...@@ -83,7 +84,7 @@ make_one_rel(Query *root, List *rels) ...@@ -83,7 +84,7 @@ make_one_rel(Query *root, List *rels)
else 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. * of clauses that have not been set by an index.
*/ */
set_rest_relselec(root, rels); set_rest_relselec(root, rels);
...@@ -93,7 +94,7 @@ make_one_rel(Query *root, List *rels) ...@@ -93,7 +94,7 @@ make_one_rel(Query *root, List *rels)
} }
/* /*
* find_base_rel_paths * set_base_rel_pathlist
* Finds all paths available for scanning each relation entry in * Finds all paths available for scanning each relation entry in
* 'rels'. Sequential scan and any available indices are considered * 'rels'. Sequential scan and any available indices are considered
* if possible(indices are not considered for lower nesting levels). * if possible(indices are not considered for lower nesting levels).
...@@ -102,7 +103,7 @@ make_one_rel(Query *root, List *rels) ...@@ -102,7 +103,7 @@ make_one_rel(Query *root, List *rels)
* MODIFIES: rels * MODIFIES: rels
*/ */
static void static void
find_base_rel_paths(Query *root, List *rels) set_base_rel_pathlist(Query *root, List *rels)
{ {
List *temp; List *temp;
...@@ -150,7 +151,7 @@ find_base_rel_paths(Query *root, List *rels) ...@@ -150,7 +151,7 @@ find_base_rel_paths(Query *root, List *rels)
* Find all possible joinpaths(bushy trees) for a query by systematically * Find all possible joinpaths(bushy trees) for a query by systematically
* finding ways to join relations(both original and derived) together. * 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 * are to be found, i.e., the current list of relations that
* have already been derived. * have already been derived.
* 'levels_needed' is the number of iterations needed * 'levels_needed' is the number of iterations needed
...@@ -159,7 +160,7 @@ find_base_rel_paths(Query *root, List *rels) ...@@ -159,7 +160,7 @@ find_base_rel_paths(Query *root, List *rels)
* the result of joining all the original relations together. * the result of joining all the original relations together.
*/ */
static RelOptInfo * 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 *x;
List *joined_rels = NIL; List *joined_rels = NIL;
...@@ -180,11 +181,11 @@ make_one_rel_by_joins(Query *root, List *outer_rels, int levels_needed) ...@@ -180,11 +181,11 @@ make_one_rel_by_joins(Query *root, List *outer_rels, int levels_needed)
{ {
/* /*
* Determine all possible pairs of relations to be joined at this * 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 * modify 'joined_rels' accordingly, then eliminate redundant join
* relations. * 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); update_rels_pathlist_for_joins(root, joined_rels);
...@@ -211,7 +212,7 @@ make_one_rel_by_joins(Query *root, List *outer_rels, int levels_needed) ...@@ -211,7 +212,7 @@ make_one_rel_by_joins(Query *root, List *outer_rels, int levels_needed)
* involves the join relation to the joininfo list of the * involves the join relation to the joininfo list of the
* other relation * other relation
*/ */
add_rel_to_rel_joininfos(root, joined_rels, outer_rels); add_rel_to_rel_joininfos(root, joined_rels, rels);
} }
#endif #endif
...@@ -236,33 +237,25 @@ make_one_rel_by_joins(Query *root, List *outer_rels, int levels_needed) ...@@ -236,33 +237,25 @@ make_one_rel_by_joins(Query *root, List *outer_rels, int levels_needed)
* prune rels that have been completely incorporated into new * prune rels that have been completely incorporated into new
* join rels * 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 * merge join rels if then contain the same list of base rels
*/ */
outer_rels = merge_rels_with_same_relids(joined_rels, outer_rels); joined_rels = merge_rels_with_same_relids(joined_rels, rels);
root->join_rel_list = outer_rels;
} }
else
#endif #endif
root->join_rel_list = joined_rels; root->join_rel_list = rels = joined_rels;
#ifdef NOT_USED
if (!BushyPlanFlag)
#endif
outer_rels = joined_rels;
} }
Assert(length(joined_rels) == 1); Assert(BushyPlanFlag || length(rels) == 1);
#ifdef NOT_USED #ifdef NOT_USED
if (BushyPlanFlag) if (BushyPlanFlag)
return final_join_rels(outer_rels); return get_cheapest_complete_rel(rels);
else else
#endif #endif
return lfirst(joined_rels); return lfirst(rels);
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1208,7 +1208,7 @@ indexable_joinclauses(RelOptInfo *rel, RelOptInfo *index, ...@@ -1208,7 +1208,7 @@ indexable_joinclauses(RelOptInfo *rel, RelOptInfo *index,
{ {
List *clauses = lfirst(clausegroups); List *clauses = lfirst(clausegroups);
((RestrictInfo *) lfirst(clauses))->restrictinfojoinid = joininfo->otherrels; ((RestrictInfo *) lfirst(clauses))->restrictinfojoinid = joininfo->unjoined_rels;
} }
cg_list = nconc(cg_list, clausegroups); cg_list = nconc(cg_list, clausegroups);
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -113,17 +113,17 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *outer_rel, ...@@ -113,17 +113,17 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *outer_rel,
if (!joininfo->bushy_inactive) 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 || (only_relids == NIL ||
/* geqo only wants certain relids to make new rels */ /* 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, rel = make_join_rel(outer_rel,
get_base_rel(root, lfirsti(other_rels)), get_base_rel(root, lfirsti(unjoined_rels)),
joininfo); joininfo);
/* how about right-sided plan ? */ /* how about right-sided plan ? */
if (_use_right_sided_plans_ && if (_use_right_sided_plans_ &&
...@@ -132,7 +132,7 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *outer_rel, ...@@ -132,7 +132,7 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *outer_rel,
if (rel != NULL) if (rel != NULL)
join_list = lappend(join_list, rel); join_list = lappend(join_list, rel);
rel = make_join_rel(get_base_rel(root, rel = make_join_rel(get_base_rel(root,
lfirsti(other_rels)), lfirsti(unjoined_rels)),
outer_rel, outer_rel,
joininfo); joininfo);
} }
...@@ -141,7 +141,7 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *outer_rel, ...@@ -141,7 +141,7 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *outer_rel,
else if (BushyPlanFlag) else if (BushyPlanFlag)
{ {
rel = make_join_rel(outer_rel, rel = make_join_rel(outer_rel,
get_join_rel(root, other_rels), get_join_rel(root, unjoined_rels),
joininfo); joininfo);
} }
#endif #endif
...@@ -328,7 +328,7 @@ static List * ...@@ -328,7 +328,7 @@ static List *
new_joininfo_list(List *joininfo_list, List *join_relids) new_joininfo_list(List *joininfo_list, List *join_relids)
{ {
List *current_joininfo_list = NIL; List *current_joininfo_list = NIL;
List *new_otherrels = NIL; List *new_unjoined_rels = NIL;
JoinInfo *other_joininfo = (JoinInfo *) NULL; JoinInfo *other_joininfo = (JoinInfo *) NULL;
List *xjoininfo = NIL; List *xjoininfo = NIL;
...@@ -337,16 +337,16 @@ new_joininfo_list(List *joininfo_list, List *join_relids) ...@@ -337,16 +337,16 @@ new_joininfo_list(List *joininfo_list, List *join_relids)
List *or; List *or;
JoinInfo *joininfo = (JoinInfo *) lfirst(xjoininfo); JoinInfo *joininfo = (JoinInfo *) lfirst(xjoininfo);
new_otherrels = joininfo->otherrels; new_unjoined_rels = joininfo->unjoined_rels;
foreach(or, new_otherrels) foreach(or, new_unjoined_rels)
{ {
if (intMember(lfirsti(or), join_relids)) 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; joininfo->unjoined_rels = new_unjoined_rels;
if (new_otherrels != NIL) if (new_unjoined_rels != NIL)
{ {
other_joininfo = joininfo_member(new_otherrels, other_joininfo = joininfo_member(new_unjoined_rels,
current_joininfo_list); current_joininfo_list);
if (other_joininfo) if (other_joininfo)
{ {
...@@ -357,7 +357,7 @@ new_joininfo_list(List *joininfo_list, List *join_relids) ...@@ -357,7 +357,7 @@ new_joininfo_list(List *joininfo_list, List *join_relids)
{ {
other_joininfo = makeNode(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->jinfo_restrictinfo = joininfo->jinfo_restrictinfo;
other_joininfo->mergejoinable = joininfo->mergejoinable; other_joininfo->mergejoinable = joininfo->mergejoinable;
other_joininfo->hashjoinable = joininfo->hashjoinable; other_joininfo->hashjoinable = joininfo->hashjoinable;
...@@ -410,12 +410,12 @@ add_rel_to_rel_joininfos(Query *root, List *joinrels, List *outerrels) ...@@ -410,12 +410,12 @@ add_rel_to_rel_joininfos(Query *root, List *joinrels, List *outerrels)
foreach(xjoininfo, joinrel->joininfo) foreach(xjoininfo, joinrel->joininfo)
{ {
JoinInfo *joininfo = (JoinInfo *) lfirst(xjoininfo); JoinInfo *joininfo = (JoinInfo *) lfirst(xjoininfo);
List *other_rels = joininfo->otherrels; List *unjoined_rels = joininfo->unjoined_rels;
List *restrict_info = joininfo->jinfo_restrictinfo; List *restrict_info = joininfo->jinfo_restrictinfo;
bool mergejoinable = joininfo->mergejoinable; bool mergejoinable = joininfo->mergejoinable;
bool hashjoinable = joininfo->hashjoinable; bool hashjoinable = joininfo->hashjoinable;
foreach(xrelid, other_rels) foreach(xrelid, unjoined_rels)
{ {
Relid relid = (Relid) lfirst(xrelid); Relid relid = (Relid) lfirst(xrelid);
RelOptInfo *rel = get_join_rel(root, relid); RelOptInfo *rel = get_join_rel(root, relid);
...@@ -423,7 +423,7 @@ add_rel_to_rel_joininfos(Query *root, List *joinrels, List *outerrels) ...@@ -423,7 +423,7 @@ add_rel_to_rel_joininfos(Query *root, List *joinrels, List *outerrels)
List *xsuper_rel = NIL; List *xsuper_rel = NIL;
JoinInfo *new_joininfo = makeNode(JoinInfo); JoinInfo *new_joininfo = makeNode(JoinInfo);
new_joininfo->otherrels = joinrel->relids; new_joininfo->unjoined_rels = joinrel->relids;
new_joininfo->jinfo_restrictinfo = restrict_info; new_joininfo->jinfo_restrictinfo = restrict_info;
new_joininfo->mergejoinable = mergejoinable; new_joininfo->mergejoinable = mergejoinable;
new_joininfo->hashjoinable = hashjoinable; new_joininfo->hashjoinable = hashjoinable;
...@@ -449,7 +449,7 @@ add_rel_to_rel_joininfos(Query *root, List *joinrels, List *outerrels) ...@@ -449,7 +449,7 @@ add_rel_to_rel_joininfos(Query *root, List *joinrels, List *outerrels)
{ {
JoinInfo *new_joininfo = makeNode(JoinInfo); JoinInfo *new_joininfo = makeNode(JoinInfo);
new_joininfo->otherrels = new_relids; new_joininfo->unjoined_rels = new_relids;
new_joininfo->jinfo_restrictinfo = restrict_info; new_joininfo->jinfo_restrictinfo = restrict_info;
new_joininfo->mergejoinable = mergejoinable; new_joininfo->mergejoinable = mergejoinable;
new_joininfo->hashjoinable = hashjoinable; new_joininfo->hashjoinable = hashjoinable;
...@@ -473,7 +473,7 @@ add_rel_to_rel_joininfos(Query *root, List *joinrels, List *outerrels) ...@@ -473,7 +473,7 @@ add_rel_to_rel_joininfos(Query *root, List *joinrels, List *outerrels)
#ifdef NOT_USED #ifdef NOT_USED
/* /*
* final_join_rels * get_cheapest_complete_rel
* Find the join relation that includes all the original * Find the join relation that includes all the original
* relations, i.e. the final join result. * relations, i.e. the final join result.
* *
...@@ -482,14 +482,14 @@ add_rel_to_rel_joininfos(Query *root, List *joinrels, List *outerrels) ...@@ -482,14 +482,14 @@ add_rel_to_rel_joininfos(Query *root, List *joinrels, List *outerrels)
* Returns the list of final join relations. * Returns the list of final join relations.
*/ */
RelOptInfo * RelOptInfo *
final_join_rels(List *join_rel_list) get_cheapest_complete_rel(List *join_rel_list)
{ {
List *xrel = NIL; List *xrel = NIL;
RelOptInfo *final_rel = NULL; RelOptInfo *final_rel = NULL;
/* /*
* find the relations that has no further joins, i.e., its joininfos * 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) foreach(xrel, join_rel_list)
{ {
...@@ -501,7 +501,7 @@ final_join_rels(List *join_rel_list) ...@@ -501,7 +501,7 @@ final_join_rels(List *join_rel_list)
{ {
JoinInfo *joininfo = (JoinInfo *) lfirst(xjoininfo); JoinInfo *joininfo = (JoinInfo *) lfirst(xjoininfo);
if (joininfo->otherrels != NIL) if (joininfo->unjoined_rels != NIL)
{ {
final = false; final = false;
break; break;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "utils/elog.h" #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_rels_with_same_relids
...@@ -48,8 +48,8 @@ merge_rels_with_same_relids(List *rel_list) ...@@ -48,8 +48,8 @@ merge_rels_with_same_relids(List *rel_list)
} }
/* /*
* merge_rel_with_same_relids * merge_rel_with_same_relids
* Prunes those relations from 'other_rels' that are redundant with * Prunes those relations from 'unjoined_rels' that are redundant with
* 'rel'. A relation is redundant if it is built up of the same * 'rel'. A relation is redundant if it is built up of the same
* relations as 'rel'. Paths for the redundant relation are merged into * relations as 'rel'. Paths for the redundant relation are merged into
* the pathlist of 'rel'. * the pathlist of 'rel'.
...@@ -59,25 +59,25 @@ merge_rels_with_same_relids(List *rel_list) ...@@ -59,25 +59,25 @@ merge_rels_with_same_relids(List *rel_list)
* *
*/ */
static List * 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 *i = NIL;
List *result = 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, * This are on the same relations,
* so get the best of their pathlists. * so get the best of their pathlists.
*/ */
rel->pathlist = add_pathlist(rel, rel->pathlist = add_pathlist(rel,
rel->pathlist, rel->pathlist,
other_rel->pathlist); unjoined_rel->pathlist);
else else
result = lappend(result, other_rel); result = lappend(result, unjoined_rel);
} }
return result; return result;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -246,18 +246,19 @@ add_join_info_to_rels(Query *root, RestrictInfo *restrictinfo, List *join_relids ...@@ -246,18 +246,19 @@ add_join_info_to_rels(Query *root, RestrictInfo *restrictinfo, List *join_relids
foreach(join_relid, join_relids) foreach(join_relid, join_relids)
{ {
JoinInfo *joininfo; JoinInfo *joininfo;
List *other_rels = NIL; List *unjoined_rels = NIL;
List *rel; List *rel;
foreach(rel, join_relids) foreach(rel, join_relids)
{ {
if (lfirsti(rel) != lfirsti(join_relid)) 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)), joininfo = find_joininfo_node(get_base_rel(root, lfirsti(join_relid)),
other_rels); unjoined_rels);
joininfo->jinfo_restrictinfo = lcons(copyObject((void *) restrictinfo), joininfo->jinfo_restrictinfo); joininfo->jinfo_restrictinfo = lcons(copyObject((void *) restrictinfo),
joininfo->jinfo_restrictinfo);
} }
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -44,7 +44,7 @@ joininfo_member(List *join_relids, List *joininfo_list) ...@@ -44,7 +44,7 @@ joininfo_member(List *join_relids, List *joininfo_list)
foreach(i, joininfo_list) foreach(i, joininfo_list)
{ {
other_rels = lfirst(i); 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 *) other_rels;
} }
return (JoinInfo *) NULL; return (JoinInfo *) NULL;
...@@ -70,7 +70,7 @@ find_joininfo_node(RelOptInfo *this_rel, List *join_relids) ...@@ -70,7 +70,7 @@ find_joininfo_node(RelOptInfo *this_rel, List *join_relids)
if (joininfo == NULL) if (joininfo == NULL)
{ {
joininfo = makeNode(JoinInfo); joininfo = makeNode(JoinInfo);
joininfo->otherrels = join_relids; joininfo->unjoined_rels = join_relids;
joininfo->jinfo_restrictinfo = NIL; joininfo->jinfo_restrictinfo = NIL;
joininfo->mergejoinable = false; joininfo->mergejoinable = false;
joininfo->hashjoinable = false; joininfo->hashjoinable = false;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * 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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -246,7 +246,7 @@ typedef struct MergeInfo ...@@ -246,7 +246,7 @@ typedef struct MergeInfo
typedef struct JoinInfo typedef struct JoinInfo
{ {
NodeTag type; NodeTag type;
List *otherrels; List *unjoined_rels;
List *jinfo_restrictinfo; List *jinfo_restrictinfo;
bool mergejoinable; bool mergejoinable;
bool hashjoinable; bool hashjoinable;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment