*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: geqo_misc.c,v 1.15 1999/02/12 06:43:26 momjian Exp $
+ * $Id: geqo_misc.c,v 1.16 1999/02/12 17:24:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
geqo_print_path(Query *root, Path *path, int indent)
{
char *ptype = NULL;
- NestPath *jp;
+ JoinPath *jp;
bool join = false;
int i;
{
int size = path->parent->size;
- jp = (NestPath *) path;
+ jp = (JoinPath *) path;
printf("%s size=%d cost=%f\n", ptype, size, path->path_cost);
switch (nodeTag(path))
{
for (i = 0; i < indent + 1; i++)
printf("\t");
printf(" clauses=(");
- geqo_print_joinclauses(root, ((NestPath *) path)->pathinfo);
+ geqo_print_joinclauses(root, ((JoinPath *) path)->pathinfo);
printf(")\n");
if (nodeTag(path) == T_MergePath)
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: geqo_paths.c,v 1.18 1999/02/12 06:43:26 momjian Exp $
+ * $Id: geqo_paths.c,v 1.19 1999/02/12 17:24:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
void
geqo_set_cheapest(RelOptInfo *rel)
{
- NestPath *cheapest = (NestPath *)set_cheapest(rel, rel->pathlist);
+ JoinPath *cheapest = (JoinPath *)set_cheapest(rel, rel->pathlist);
if (IsA_JoinPath(cheapest))
rel->size = compute_joinrel_size(cheapest);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.29 1999/02/12 06:43:28 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.30 1999/02/12 17:24:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
print_path(Query *root, Path *path, int indent)
{
char *ptype = NULL;
- NestPath *jp;
+ JoinPath *jp;
bool join = false;
int i;
{
int size = path->parent->size;
- jp = (NestPath *) path;
+ jp = (JoinPath *) path;
printf("%s size=%d cost=%f\n", ptype, size, path->path_cost);
switch (nodeTag(path))
{
for (i = 0; i < indent + 1; i++)
printf("\t");
printf(" clauses=(");
- print_joinclauses(root, ((NestPath *) path)->pathinfo);
+ print_joinclauses(root, ((JoinPath *) path)->pathinfo);
printf(")\n");
if (nodeTag(path) == T_MergePath)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.30 1999/02/12 06:43:28 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.31 1999/02/12 17:24:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* Returns a fixnum.
*/
int
-compute_joinrel_size(NestPath *joinpath)
+compute_joinrel_size(JoinPath *joinpath)
{
Cost temp = 1.0;
int temp1 = 0;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.21 1999/02/12 06:43:30 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.22 1999/02/12 17:24:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
innerrel->pathlist,
INNER);
+ /* Should we use the mergeinner, or sort the cheapest inner? */
path_is_cheaper_than_sort = (bool) (mergeinnerpath &&
(mergeinnerpath->path_cost <
(cheapest_inner->path_cost +
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/predmig.c,v 1.16 1999/02/12 06:43:31 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/predmig.c,v 1.17 1999/02/12 17:24:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* (not a join) iff it has
* a non-NULL cinfo field */
-static void xfunc_predmig(NestPath pathnode, Stream streamroot,
+static void xfunc_predmig(JoinPath pathnode, Stream streamroot,
Stream laststream, bool *progressp);
static bool xfunc_series_llel(Stream stream);
static bool xfunc_llel_chains(Stream root, Stream bottom);
static Stream xfunc_complete_stream(Stream stream);
static bool xfunc_prdmig_pullup(Stream origstream, Stream pullme,
- NestPath joinpath);
+ JoinPath joinpath);
static void xfunc_form_groups(Stream root, Stream bottom);
static void xfunc_free_stream(Stream root);
static Stream xfunc_add_clauses(Stream current);
do
{
progress = false;
- Assert(IsA(root, NestPath));
- xfunc_predmig((NestPath) root, (Stream) NULL, (Stream) NULL,
+ Assert(IsA(root, JoinPath));
+ xfunc_predmig((JoinPath) root, (Stream) NULL, (Stream) NULL,
&progress);
if (changed && progress)
elog(DEBUG, "Needed to do a second round of predmig!\n");
** Destructively modifies the join tree (via predicate pullup).
*/
static void
-xfunc_predmig(NestPath pathnode,/* root of the join tree */
+xfunc_predmig(JoinPath pathnode,/* root of the join tree */
Stream streamroot,
Stream laststream,/* for recursive calls -- these are the
* root of the stream under construction,
else
{
/* visit left child */
- xfunc_predmig((NestPath) get_outerjoinpath(pathnode),
+ xfunc_predmig((JoinPath) get_outerjoinpath(pathnode),
streamroot, newstream, progressp);
/* visit right child */
- xfunc_predmig((NestPath) get_innerjoinpath(pathnode),
+ xfunc_predmig((JoinPath) get_innerjoinpath(pathnode),
streamroot, newstream, progressp);
}
*/
Assert(xfunc_num_relids(pathstream) > xfunc_num_relids(tmpstream));
progress = xfunc_prdmig_pullup(origstream, tmpstream,
- (NestPath) get_pathptr(pathstream));
+ (JoinPath) get_pathptr(pathstream));
}
if (get_downstream(tmpstream))
pathstream = (Stream) xfunc_get_downjoin((Stream) get_downstream(tmpstream));
/*
** xfunc_prdmig_pullup
- ** pullup a clause in a path above joinpath. Since the NestPath tree
+ ** pullup a clause in a path above joinpath. Since the JoinPath tree
** doesn't have upward pointers, it's difficult to deal with. Thus we
** require the original stream, which maintains pointers to all the path
** nodes. We use the original stream to find out what joins are
** above the clause.
*/
static bool
-xfunc_prdmig_pullup(Stream origstream, Stream pullme, NestPath joinpath)
+xfunc_prdmig_pullup(Stream origstream, Stream pullme, JoinPath joinpath)
{
RestrictInfo restrictinfo = get_cinfo(pullme);
bool progress = false;
/* pull up this node as far as it should go */
for (upjoin = (Stream) xfunc_get_upjoin(orignode);
upjoin != (Stream) NULL
- && (NestPath) get_pathptr((Stream) xfunc_get_downjoin(upjoin))
+ && (JoinPath) get_pathptr((Stream) xfunc_get_downjoin(upjoin))
!= joinpath;
upjoin = (Stream) xfunc_get_upjoin(upjoin))
{
#endif
/* move clause up in path */
if (get_pathptr((Stream) get_downstream(upjoin))
- == (pathPtr) get_outerjoinpath((NestPath) get_pathptr(upjoin)))
+ == (pathPtr) get_outerjoinpath((JoinPath) get_pathptr(upjoin)))
whichchild = OUTER;
else
whichchild = INNER;
restrictinfo = xfunc_pullup((Path) get_pathptr((Stream) get_downstream(upjoin)),
- (NestPath) get_pathptr(upjoin),
+ (JoinPath) get_pathptr(upjoin),
restrictinfo,
whichchild,
get_clausetype(orignode));
temp = (Stream) get_downstream(temp))
set_pathptr
(temp, (pathPtr)
- get_outerjoinpath((NestPath) get_pathptr(upjoin)));
+ get_outerjoinpath((JoinPath) get_pathptr(upjoin)));
set_pathptr
(temp,
- (pathPtr) get_outerjoinpath((NestPath) get_pathptr(upjoin)));
+ (pathPtr) get_outerjoinpath((JoinPath) get_pathptr(upjoin)));
}
else
{
temp = (Stream) get_downstream(temp))
set_pathptr
(temp, (pathPtr)
- get_innerjoinpath((NestPath) get_pathptr(upjoin)));
+ get_innerjoinpath((JoinPath) get_pathptr(upjoin)));
set_pathptr
(temp, (pathPtr)
- get_innerjoinpath((NestPath) get_pathptr(upjoin)));
+ get_innerjoinpath((JoinPath) get_pathptr(upjoin)));
}
progress = true;
}
if (!is_clause(temp))
{
if (get_pathptr((Stream) get_downstream(temp))
- == (pathPtr) get_outerjoinpath((NestPath) get_pathptr(temp)))
+ == (pathPtr) get_outerjoinpath((JoinPath) get_pathptr(temp)))
whichchild = OUTER;
else
whichchild = INNER;
set_groupcost(temp,
- xfunc_join_expense((NestPath) get_pathptr(temp),
+ xfunc_join_expense((JoinPath) get_pathptr(temp),
whichchild));
- if (primjoin = xfunc_primary_join((NestPath) get_pathptr(temp)))
+ if (primjoin = xfunc_primary_join((JoinPath) get_pathptr(temp)))
{
set_groupsel(temp,
compute_clause_selec(queryInfo,
}
/* and add in the join clauses */
- if (IsA(get_pathptr(current), NestPath))
+ if (IsA(get_pathptr(current), JoinPath))
{
- primjoin = xfunc_primary_join((NestPath) get_pathptr(current));
- foreach(temp, get_pathrestrictinfo((NestPath) get_pathptr(current)))
+ primjoin = xfunc_primary_join((JoinPath) get_pathptr(current));
+ foreach(temp, get_pathrestrictinfo((JoinPath) get_pathptr(current)))
{
if (!equal(get_clause((RestrictInfo) lfirst(temp)), primjoin))
topnode = xfunc_streaminsert((RestrictInfo) lfirst(temp), topnode,
static int
xfunc_num_relids(Stream node)
{
- if (!node || !IsA(get_pathptr(node), NestPath))
+ if (!node || !IsA(get_pathptr(node), JoinPath))
return 0;
else
return (length
- (get_relids(get_parent((NestPath) get_pathptr(node)))));
+ (get_relids(get_parent((JoinPath) get_pathptr(node)))));
}
/*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.29 1999/02/12 06:43:32 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.30 1999/02/12 17:24:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
List *x = NIL;
RelOptInfo *rel = (RelOptInfo *) NULL;
- NestPath *cheapest;
+ JoinPath *cheapest;
foreach(x, rel_list)
{
rel = (RelOptInfo *) lfirst(x);
- cheapest = (NestPath *) set_cheapest(rel, rel->pathlist);
+ cheapest = (JoinPath *) set_cheapest(rel, rel->pathlist);
if (IsA_JoinPath(cheapest))
rel->size = compute_joinrel_size(cheapest);
else
- elog(ERROR, "non NestPath called");
+ elog(ERROR, "non JoinPath called");
}
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.26 1999/02/12 06:43:32 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.27 1999/02/12 17:24:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
LispValue y; /* list ptr */
RestrictInfo maxcinfo; /* The RestrictInfo to pull up, as
* calculated by xfunc_shouldpull() */
- NestPath curpath; /* current path in list */
+ JoinPath curpath; /* current path in list */
int progress; /* has progress been made this time
* through? */
int clausetype;
progress = false; /* no progress yet in this iteration */
foreach(y, get_pathlist(rel))
{
- curpath = (NestPath) lfirst(y);
+ curpath = (JoinPath) lfirst(y);
/*
* * for each operand, attempt to pullup predicates until
int
xfunc_shouldpull(Query *queryInfo,
Path childpath,
- NestPath parentpath,
+ JoinPath parentpath,
int whichchild,
RestrictInfo * maxcinfopt) /* Out: pointer to clause
* to pullup */
* see if any join clause has even higher rank than the highest *
* local predicate
*/
- if (is_join(childpath) && xfunc_num_join_clauses((NestPath) childpath) > 1)
- for (tmplist = get_pathrestrictinfo((NestPath) childpath);
+ if (is_join(childpath) && xfunc_num_join_clauses((JoinPath) childpath) > 1)
+ for (tmplist = get_pathrestrictinfo((JoinPath) childpath);
tmplist != LispNil;
tmplist = lnext(tmplist))
{
RestrictInfo
xfunc_pullup(Query *queryInfo,
Path childpath,
- NestPath parentpath,
+ JoinPath parentpath,
RestrictInfo cinfo, /* clause to pull up */
int whichchild, /* whether child is INNER or OUTER of join */
int clausetype) /* whether clause to pull is join or local */
else
{
set_pathrestrictinfo
- ((NestPath) newkid,
+ ((JoinPath) newkid,
xfunc_LispRemove((LispValue) cinfo,
- (List) get_pathrestrictinfo((NestPath) newkid)));
+ (List) get_pathrestrictinfo((JoinPath) newkid)));
}
/*
** Find global expense of a join clause
*/
Cost
-xfunc_join_expense(Query *queryInfo, NestPath path, int whichchild)
+xfunc_join_expense(Query *queryInfo, JoinPath path, int whichchild)
{
LispValue primjoinclause = xfunc_primary_join(path);
** min rank pathclause
*/
LispValue
-xfunc_primary_join(NestPath pathnode)
+xfunc_primary_join(JoinPath pathnode)
{
LispValue joinclauselist = get_pathrestrictinfo(pathnode);
RestrictInfo mincinfo;
* * Now add in any node-specific expensive function costs. * Again,
* we must ensure that the clauses are sorted by rank.
*/
- if (IsA(pathnode, NestPath))
+ if (IsA(pathnode, JoinPath))
{
if (XfuncMode != XFUNC_OFF)
- set_pathrestrictinfo((NestPath) pathnode, lisp_qsort
- (get_pathrestrictinfo((NestPath) pathnode),
+ set_pathrestrictinfo((JoinPath) pathnode, lisp_qsort
+ (get_pathrestrictinfo((JoinPath) pathnode),
xfunc_cinfo_compare));
- for (tmplist = get_pathrestrictinfo((NestPath) pathnode), selec = 1.0;
+ for (tmplist = get_pathrestrictinfo((JoinPath) pathnode), selec = 1.0;
tmplist != LispNil;
tmplist = lnext(tmplist))
{
** Recalculate the cost of a path node. This includes the basic cost of the
** node, as well as the cost of its expensive functions.
** We need to do this to the parent after pulling a clause from a child into a
- ** parent. Thus we should only be calling this function on NestPaths.
+ ** parent. Thus we should only be calling this function on JoinPaths.
*/
Cost
-xfunc_total_path_cost(NestPath pathnode)
+xfunc_total_path_cost(JoinPath pathnode)
{
Cost cost = xfunc_get_path_cost((Path) pathnode);
- Assert(IsA(pathnode, NestPath));
+ Assert(IsA(pathnode, JoinPath));
if (IsA(pathnode, MergePath))
{
MergePath mrgnode = (MergePath) pathnode;
*/
Cost
-xfunc_expense_per_tuple(NestPath joinnode, int whichchild)
+xfunc_expense_per_tuple(JoinPath joinnode, int whichchild)
{
RelOptInfo outerrel = get_parent((Path) get_outerjoinpath(joinnode));
RelOptInfo innerrel = get_parent((Path) get_innerjoinpath(joinnode));
else
/* nestloop */
{
- Assert(IsA(joinnode, NestPath));
+ Assert(IsA(joinnode, JoinPath));
return _CPU_PAGE_WEIGHT_;
}
}
** Find the number of join clauses associated with this join path
*/
int
-xfunc_num_join_clauses(NestPath path)
+xfunc_num_join_clauses(JoinPath path)
{
int num = length(get_pathrestrictinfo(path));
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.44 1999/02/12 06:43:33 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.45 1999/02/12 17:24:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static List *switch_outer(List *clauses);
static Scan *create_scan_node(Path *best_path, List *tlist);
-static Join *create_join_node(NestPath *best_path, List *tlist);
+static Join *create_join_node(JoinPath *best_path, List *tlist);
static SeqScan *create_seqscan_node(Path *best_path, List *tlist,
List *scan_clauses);
static IndexScan *create_indexscan_node(IndexPath *best_path, List *tlist,
case T_HashJoin:
case T_MergeJoin:
case T_NestLoop:
- plan_node = (Plan *) create_join_node((NestPath *) best_path, tlist);
+ plan_node = (Plan *) create_join_node((JoinPath *) best_path, tlist);
break;
default:
/* do nothing */
* Returns the join node.
*/
static Join *
-create_join_node(NestPath *best_path, List *tlist)
+create_join_node(JoinPath *best_path, List *tlist)
{
Plan *outer_node;
List *outer_tlist;
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeNestloop.h,v 1.7 1998/09/01 04:36:03 momjian Exp $
+ * $Id: nodeNestloop.h,v 1.8 1999/02/12 17:24:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern bool ExecInitNestLoop(NestLoop *node, EState *estate, Plan *parent);
extern int ExecCountSlotsNestLoop(NestLoop *node);
extern void ExecEndNestLoop(NestLoop *node);
-extern void ExecReScanNestLoop(NestLoop *node, ExprContext *exprCtxt, Plan *parent);
+extern void ExecReScanNestLoop(NestLoop *node, ExprContext *exprCtxt,
+ Plan *parent);
#endif /* NODENESTLOOP_H */
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: relation.h,v 1.21 1999/02/12 06:43:47 momjian Exp $
+ * $Id: relation.h,v 1.22 1999/02/12 17:24:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
Path *innerjoinpath;
} NestPath;
+typedef NestPath JoinPath;
+
typedef struct MergePath
{
- NestPath jpath;
+ JoinPath jpath;
List *path_mergeclauses;
List *outersortkeys;
List *innersortkeys;
typedef struct HashPath
{
- NestPath jpath;
+ JoinPath jpath;
List *path_hashclauses;
List *outerhashkeys;
List *innerhashkeys;
/*
** Stream:
** A stream represents a root-to-leaf path in a plan tree (i.e. a tree of
-** NestPaths and Paths). The stream includes pointers to all Path nodes,
+** JoinPaths and Paths). The stream includes pointers to all Path nodes,
** as well as to any clauses that reside above Path nodes. This structure
** is used to make Path nodes and clauses look similar, so that Predicate
** Migration can run.
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: cost.h,v 1.15 1999/02/12 06:43:52 momjian Exp $
+ * $Id: cost.h,v 1.16 1999/02/12 17:25:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
int outerwidth, int innerwidth);
extern int compute_rel_size(RelOptInfo *rel);
extern int compute_rel_width(RelOptInfo *rel);
-extern int compute_joinrel_size(NestPath *joinpath);
+extern int compute_joinrel_size(JoinPath *joinpath);
extern int page_size(int tuples, int width);
/*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: xfunc.h,v 1.13 1999/02/12 06:43:53 momjian Exp $
+ * $Id: xfunc.h,v 1.14 1999/02/12 17:25:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* function prototypes from planner/path/xfunc.c */
extern void xfunc_trypullup(RelOptInfo *rel);
-extern int xfunc_shouldpull(Path *childpath, NestPath *parentpath,
+extern int xfunc_shouldpull(Path *childpath, JoinPath *parentpath,
int whichchild, RestrictInfo * maxcinfopt);
-extern RestrictInfo *xfunc_pullup(Path *childpath, NestPath *parentpath, RestrictInfo * cinfo,
+extern RestrictInfo *xfunc_pullup(Path *childpath, JoinPath *parentpath, RestrictInfo * cinfo,
int whichchild, int clausetype);
extern Cost xfunc_rank(Expr *clause);
extern Cost xfunc_expense(Query *queryInfo, Expr *clause);
-extern Cost xfunc_join_expense(NestPath *path, int whichchild);
+extern Cost xfunc_join_expense(JoinPath *path, int whichchild);
extern Cost xfunc_local_expense(Expr *clause);
extern Cost xfunc_func_expense(Expr *node, List *args);
extern int xfunc_width(Expr *clause);
/* extern int xfunc_card_unreferenced(Expr *clause, Relid referenced); */
extern int xfunc_card_product(Relid relids);
extern List *xfunc_find_references(List *clause);
-extern List *xfunc_primary_join(NestPath *pathnode);
+extern List *xfunc_primary_join(JoinPath *pathnode);
extern Cost xfunc_get_path_cost(Path *pathnode);
-extern Cost xfunc_total_path_cost(NestPath *pathnode);
-extern Cost xfunc_expense_per_tuple(NestPath *joinnode, int whichchild);
+extern Cost xfunc_total_path_cost(JoinPath *pathnode);
+extern Cost xfunc_expense_per_tuple(JoinPath *joinnode, int whichchild);
extern void xfunc_fixvars(Expr *clause, RelOptInfo *rel, int varno);
extern int xfunc_cinfo_compare(void *arg1, void *arg2);
extern int xfunc_clause_compare(void *arg1, void *arg2);
extern int xfunc_disjunct_compare(void *arg1, void *arg2);
extern int xfunc_func_width(RegProcedure funcid, List *args);
extern int xfunc_tuple_width(Relation rd);
-extern int xfunc_num_join_clauses(NestPath *path);
+extern int xfunc_num_join_clauses(JoinPath *path);
extern List *xfunc_LispRemove(List *foo, List *bar);
extern bool xfunc_copyrel(RelOptInfo *from, RelOptInfo ** to);