*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.43 1998/07/15 14:54:31 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.44 1998/07/18 04:22:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
** planner/path/xfunc.c accordingly!!!
** -- JMH, 8/2/93
*/
-static Rel *
-_copyRel(Rel *from)
+static RelOptInfo *
+_copyRel(RelOptInfo *from)
{
- Rel *newnode = makeNode(Rel);
+ RelOptInfo *newnode = makeNode(RelOptInfo);
int i,
len;
/*
* RELATION NODES
*/
- case T_Rel:
+ case T_RelOptInfo:
retval = _copyRel(from);
break;
case T_Path:
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.40 1998/07/15 14:54:32 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.41 1998/07/18 04:22:26 momjian Exp $
*
* NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which
* Stuff from relation.h
*/
static void
-_outRel(StringInfo str, Rel *node)
+_outRel(StringInfo str, RelOptInfo *node)
{
char buf[500];
- appendStringInfo(str, " REL ");
+ appendStringInfo(str, " RELOPTINFO ");
appendStringInfo(str, " :relids ");
_outIntList(str, node->relids);
static void
_outTargetEntry(StringInfo str, TargetEntry *node)
{
- appendStringInfo(str, " TLE ");
+ appendStringInfo(str, " TARGETENTRY ");
appendStringInfo(str, " :resdom ");
_outNode(str, node->resdom);
case T_EState:
_outEState(str, obj);
break;
- case T_Rel:
+ case T_RelOptInfo:
_outRel(str, obj);
break;
case T_TargetEntry:
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.32 1998/07/15 14:54:34 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.33 1998/07/18 04:22:26 momjian Exp $
*
* NOTES
* Most of the read functions for plan nodes are tested. (In fact, they
* _readRel
* ----------------
*/
-static Rel *
+static RelOptInfo *
_readRel()
{
- Rel *local_node;
+ RelOptInfo *local_node;
char *token;
int length;
- local_node = makeNode(Rel);
+ local_node = makeNode(RelOptInfo);
token = lsptok(NULL, &length); /* get :relids */
local_node->relids =
return_value = _readParam();
else if (!strncmp(token, "ESTATE", length))
return_value = _readEState();
- else if (!strncmp(token, "REL", length))
+ else if (!strncmp(token, "RELOPTINFO", length))
return_value = _readRel();
- else if (!strncmp(token, "TLE", length))
+ else if (!strncmp(token, "TARGETENTRY", length))
return_value = _readTargetEntry();
else if (!strncmp(token, "RTE", length))
return_value = _readRangeTblEntry();
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: geqo_eval.c,v 1.19 1998/06/15 19:28:35 momjian Exp $
+ * $Id: geqo_eval.c,v 1.20 1998/07/18 04:22:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "optimizer/geqo_paths.h"
-static List *gimme_clause_joins(Query *root, Rel *outer_rel, Rel *inner_rel);
-static Rel *gimme_clauseless_join(Rel *outer_rel, Rel *inner_rel);
-static Rel *init_join_rel(Rel *outer_rel, Rel *inner_rel, JInfo *joininfo);
+static List *gimme_clause_joins(Query *root, RelOptInfo *outer_rel, RelOptInfo *inner_rel);
+static RelOptInfo *gimme_clauseless_join(RelOptInfo *outer_rel, RelOptInfo *inner_rel);
+static RelOptInfo *init_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JInfo *joininfo);
static List *new_join_tlist(List *tlist, List *other_relids, int first_resdomno);
static List *new_joininfo_list(List *joininfo_list, List *join_relids);
-static void geqo_joinrel_size(Rel *joinrel, Rel *outer_rel, Rel *inner_rel);
-static Rel *geqo_nth(int stop, List *rels);
+static void geqo_joinrel_size(RelOptInfo *joinrel, RelOptInfo *outer_rel, RelOptInfo *inner_rel);
+static RelOptInfo *geqo_nth(int stop, List *rels);
/*
* geqo_eval--
Cost
geqo_eval(Query *root, Gene *tour, int num_gene)
{
- Rel *joinrel;
+ RelOptInfo *joinrel;
Cost fitness;
List *temp;
*
* Returns a new join relation incorporating all joins in a left-sided tree.
*/
-Rel *
-gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, Rel *outer_rel)
+RelOptInfo *
+gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *outer_rel)
{
- Rel *inner_rel; /* current relation */
+ RelOptInfo *inner_rel; /* current relation */
int base_rel_index;
List *new_rels = NIL;
- Rel *new_rel = NULL;
+ RelOptInfo *new_rel = NULL;
if (rel_count < num_gene)
{ /* tree not yet finished */
/* tour[0] = 3; tour[1] = 1; tour[2] = 2 */
base_rel_index = (int) tour[rel_count];
- inner_rel = (Rel *) geqo_nth(base_rel_index, root->base_relation_list_);
+ inner_rel = (RelOptInfo *) geqo_nth(base_rel_index, root->base_relation_list_);
if (rel_count == 0)
{ /* processing first join with
}
/* get essential new relation */
- new_rel = (Rel *) lfirst(new_rels);
+ new_rel = (RelOptInfo *) lfirst(new_rels);
rel_count++;
/* process new_rel->cheapestpath, new_rel->unorderedpath */
*/
static List *
-gimme_clause_joins(Query *root, Rel *outer_rel, Rel *inner_rel)
+gimme_clause_joins(Query *root, RelOptInfo *outer_rel, RelOptInfo *inner_rel)
{
List *join_list = NIL;
List *i = NIL;
foreach(i, joininfo_list)
{
JInfo *joininfo = (JInfo *) lfirst(i);
- Rel *rel = NULL;
+ RelOptInfo *rel = NULL;
if (!joininfo->inactive)
{
* Returns a new join relation.
*/
-static Rel *
-gimme_clauseless_join(Rel *outer_rel, Rel *inner_rel)
+static RelOptInfo *
+gimme_clauseless_join(RelOptInfo *outer_rel, RelOptInfo *inner_rel)
{
return (init_join_rel(outer_rel, inner_rel, (JInfo *) NULL));
}
*
* Returns the new join relation node.
*/
-static Rel *
-init_join_rel(Rel *outer_rel, Rel *inner_rel, JInfo *joininfo)
+static RelOptInfo *
+init_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JInfo *joininfo)
{
- Rel *joinrel = makeNode(Rel);
+ RelOptInfo *joinrel = makeNode(RelOptInfo);
List *joinrel_joininfo_list = NIL;
List *new_outer_tlist;
List *new_inner_tlist;
List *xrel = NIL;
List *xjoininfo = NIL;
- Rel *rel;
+ RelOptInfo *rel;
List *relids;
List *super_rels;
foreach(xjoinrel, joinrels)
{
- Rel *joinrel = (Rel *) lfirst(xjoinrel);
+ RelOptInfo *joinrel = (RelOptInfo *) lfirst(xjoinrel);
foreach(xrelid, joinrel->relids)
{
*/
/*
- * ! BUG BUG ! Relid relid = (Relid)lfirst(xrelid); Rel *rel =
+ * ! BUG BUG ! Relid relid = (Relid)lfirst(xrelid); RelOptInfo *rel =
* get_join_rel(root, relid);
*/
}
foreach(xjoinrel, joinrels)
{
- Rel *joinrel = (Rel *) lfirst(xjoinrel);
+ RelOptInfo *joinrel = (RelOptInfo *) lfirst(xjoinrel);
foreach(xjoininfo, joinrel->joininfo)
{
{
/*
- * ! BUG BUG ! Relid relid = (Relid)lfirst(xrelid); Rel
+ * ! BUG BUG ! Relid relid = (Relid)lfirst(xrelid); RelOptInfo
* *rel = get_join_rel(root, relid);
*/
foreach(xsuper_rel, super_rels)
{
- Rel *super_rel = (Rel *) lfirst(xsuper_rel);
+ RelOptInfo *super_rel = (RelOptInfo *) lfirst(xsuper_rel);
if (nonoverlap_rels(super_rel, joinrel))
{
}
foreach(xrel, outerrels)
{
- rel = (Rel *) lfirst(xrel);
+ rel = (RelOptInfo *) lfirst(xrel);
rel->superrels = NIL;
}
}
*/
foreach(xrel, join_rel_list)
{
- Rel *rel = (Rel *) lfirst(xrel);
+ RelOptInfo *rel = (RelOptInfo *) lfirst(xrel);
List *xjoininfo = NIL;
bool final = true;
* Modifies the superrels field of rel
*/
static void
-add_superrels(Rel *rel, Rel *super_rel)
+add_superrels(RelOptInfo *rel, RelOptInfo *super_rel)
{
rel->superrels = lappend(rel->superrels, super_rel);
}
* Returns non-nil if rel1 and rel2 do not overlap.
*/
static bool
-nonoverlap_rels(Rel *rel1, Rel *rel2)
+nonoverlap_rels(RelOptInfo *rel1, RelOptInfo *rel2)
{
return (nonoverlap_sets(rel1->relids, rel2->relids));
}
* long join queries; so get logarithm of size when MAXINT overflow;
*/
static void
-geqo_joinrel_size(Rel *joinrel, Rel *outer_rel, Rel *inner_rel)
+geqo_joinrel_size(RelOptInfo *joinrel, RelOptInfo *outer_rel, RelOptInfo *inner_rel)
{
Cost temp;
int ntuples;
return (log(x) / log(b));
}
-static Rel *
+static RelOptInfo *
geqo_nth(int stop, List *rels)
{
List *r;
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: geqo_main.c,v 1.7 1998/02/26 04:32:22 momjian Exp $
+ * $Id: geqo_main.c,v 1.8 1998/07/18 04:22:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* similar to a constrained Traveling Salesman Problem (TSP)
*/
-Rel *
+RelOptInfo *
geqo(Query *root)
{
int generation;
status_interval;
Gene *best_tour;
- Rel *best_rel;
+ RelOptInfo *best_rel;
/* Plan *best_plan; */
best_tour = (Gene *) pool->data[0].string;
/* root->join_relation_list_ will be modified during this ! */
- best_rel = (Rel *) gimme_tree(root, best_tour, 0, pool->string_length, NULL);
+ best_rel = (RelOptInfo *) gimme_tree(root, best_tour, 0, pool->string_length, NULL);
/* DBG: show the query plan
print_plan(best_plan, root);
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: geqo_misc.c,v 1.8 1998/06/15 19:28:35 momjian Exp $
+ * $Id: geqo_misc.c,v 1.9 1998/07/18 04:22:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
void
-geqo_print_rel(Query *root, Rel *rel)
+geqo_print_rel(Query *root, RelOptInfo *rel)
{
List *l;
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: geqo_paths.c,v 1.9 1998/06/15 19:28:37 momjian Exp $
+ * $Id: geqo_paths.c,v 1.10 1998/07/18 04:22:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "optimizer/geqo_paths.h"
-static List *geqo_prune_rel(Rel *rel, List *other_rels);
-static Path *set_paths(Rel *rel, Path *unorderedpath);
+static List *geqo_prune_rel(RelOptInfo *rel, List *other_rels);
+static Path *set_paths(RelOptInfo *rel, Path *unorderedpath);
/*
* geqo-prune-rels--
if (rel_list != NIL)
{
temp_list = lcons(lfirst(rel_list),
- geqo_prune_rels(geqo_prune_rel((Rel *) lfirst(rel_list),
+ geqo_prune_rels(geqo_prune_rel((RelOptInfo *) lfirst(rel_list),
lnext(rel_list))));
}
return (temp_list);
*
*/
static List *
-geqo_prune_rel(Rel *rel, List *other_rels)
+geqo_prune_rel(RelOptInfo *rel, List *other_rels)
{
List *i = NIL;
List *t_list = NIL;
List *temp_node = NIL;
- Rel *other_rel = (Rel *) NULL;
+ RelOptInfo *other_rel = (RelOptInfo *) NULL;
foreach(i, other_rels)
{
- other_rel = (Rel *) lfirst(i);
+ other_rel = (RelOptInfo *) lfirst(i);
if (same(rel->relids, other_rel->relids))
{
rel->pathlist = add_pathlist(rel,
*
*/
void
-geqo_rel_paths(Rel *rel)
+geqo_rel_paths(RelOptInfo *rel)
{
List *y = NIL;
Path *path = (Path *) NULL;
*
*/
static Path *
-set_paths(Rel *rel, Path *unorderedpath)
+set_paths(RelOptInfo *rel, Path *unorderedpath)
{
Path *cheapest = set_cheapest(rel, rel->pathlist);
*
*
* IDENTIFICATION
-* $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/Attic/minspantree.c,v 1.5 1998/06/15 19:28:38 momjian Exp $
+* $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/Attic/minspantree.c,v 1.6 1998/07/18 04:22:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
void
-minspantree(Query *root, List *join_rels, Rel *garel)
+minspantree(Query *root, List *join_rels, RelOptInfo *garel)
{
int number_of_rels = length(root->base_relation_list_);
int number_of_joins = length(join_rels);
id1,
id2;
List *r = NIL;
- Rel *joinrel = NULL;
- Rel **tmprel_array;
+ RelOptInfo *joinrel = NULL;
+ RelOptInfo **tmprel_array;
/* allocate memory for matrix tmprel_array[x][y] */
- tmprel_array = (Rel **) palloc((number_of_rels + 1) * sizeof(Rel *));
+ tmprel_array = (RelOptInfo **) palloc((number_of_rels + 1) * sizeof(RelOptInfo *));
for (i = 0; i <= number_of_rels; i++)
- (tmprel_array[i] = (Rel *) palloc((number_of_rels + 1) * sizeof(Rel)));
+ (tmprel_array[i] = (RelOptInfo *) palloc((number_of_rels + 1) * sizeof(RelOptInfo)));
/* read relations of join-relations into tmprel_array */
foreach(r, join_rels)
{
- joinrel = (Rel *) lfirst(r);
+ joinrel = (RelOptInfo *) lfirst(r);
id1 = (int) lfirst(joinrel->relids);
id2 = (int) lsecond(joinrel->relids);
if (id1 > id2)
- tmprel_array[id2][id1] = *(Rel *) joinrel;
+ tmprel_array[id2][id1] = *(RelOptInfo *) joinrel;
else
{
- tmprel_array[id1][id2] = *(Rel *) joinrel; /* ever reached? */
+ tmprel_array[id1][id2] = *(RelOptInfo *) joinrel; /* ever reached? */
}
}
i = 1;
foreach(r, join_rels)
{
- garel[i] = *(Rel *) lfirst(r);
+ garel[i] = *(RelOptInfo *) lfirst(r);
i++;
}
}
else if (number_of_joins == 3)
{
- Rel *rel12 = (Rel *) &tmprel_array[1][2];
- Rel *rel13 = (Rel *) &tmprel_array[1][3];
- Rel *rel23 = (Rel *) &tmprel_array[2][3];
+ RelOptInfo *rel12 = (RelOptInfo *) &tmprel_array[1][2];
+ RelOptInfo *rel13 = (RelOptInfo *) &tmprel_array[1][3];
+ RelOptInfo *rel23 = (RelOptInfo *) &tmprel_array[2][3];
if (rel12->cheapestpath->path_cost > rel13->cheapestpath->path_cost)
{
if (connectto[tempn] != 0)
{
if (n > tempn)
- joinrel = (Rel *) &tmprel_array[tempn][n];
+ joinrel = (RelOptInfo *) &tmprel_array[tempn][n];
else
- joinrel = (Rel *) &tmprel_array[n][tempn];
+ joinrel = (RelOptInfo *) &tmprel_array[n][tempn];
dist = joinrel->cheapestpath->path_cost;
if (dist < disttoconnect[tempn])
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.16 1998/06/15 19:28:38 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.17 1998/07/18 04:22:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
find_rel_paths(Query *root, List *rels)
{
List *temp;
- Rel *rel;
+ RelOptInfo *rel;
List *lastpath;
foreach(temp, rels)
List *rel_index_scan_list;
List *or_index_scan_list;
- rel = (Rel *) lfirst(temp);
+ rel = (RelOptInfo *) lfirst(temp);
sequential_scan_list = lcons(create_seqscan_path(rel),
NIL);
{
List *x;
List *new_rels = NIL;
- Rel *rel;
+ RelOptInfo *rel;
/*******************************************
* genetic query optimizer entry point *
*******************************************/
if ((_use_geqo_) && length(root->base_relation_list_) >= _use_geqo_rels_)
- return lcons(geqo(root), NIL); /* returns *one* Rel, so lcons it */
+ return lcons(geqo(root), NIL); /* returns *one* RelOptInfo, so lcons it */
/*******************************************
* rest will be deprecated in case of GEQO *
*/
if (XfuncMode != XFUNC_NOPULL && XfuncMode != XFUNC_OFF)
foreach(x, new_rels)
- xfunc_trypullup((Rel *) lfirst(x));
+ xfunc_trypullup((RelOptInfo *) lfirst(x));
#endif
prune_rel_paths(new_rels);
foreach(x, new_rels)
{
- rel = (Rel *) lfirst(x);
+ rel = (RelOptInfo *) lfirst(x);
if (rel->size <= 0)
rel->size = compute_rel_size(rel);
rel->width = compute_rel_width(rel);
}
static void
-debug_print_rel(Query *root, Rel *rel)
+debug_print_rel(Query *root, RelOptInfo *rel)
{
List *l;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.8 1998/06/15 19:28:39 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.9 1998/07/18 04:22:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
void
set_rest_relselec(Query *root, List *rel_list)
{
- Rel *rel;
+ RelOptInfo *rel;
List *x;
foreach(x, rel_list)
{
- rel = (Rel *) lfirst(x);
+ rel = (RelOptInfo *) lfirst(x);
set_rest_selec(root, rel->clauseinfo);
}
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.21 1998/06/15 19:28:39 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.22 1998/07/18 04:22:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* Returns the size.
*/
int
-compute_rel_size(Rel *rel)
+compute_rel_size(RelOptInfo *rel)
{
Cost temp;
int temp1;
* Returns the width of the tuple as a fixnum.
*/
int
-compute_rel_width(Rel *rel)
+compute_rel_width(RelOptInfo *rel)
{
return (compute_targetlist_width(get_actual_tlist(rel->targetlist)));
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.16 1998/06/15 19:28:40 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.17 1998/07/18 04:22:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static void
-match_index_orclauses(Rel *rel, Rel *index, int indexkey,
+match_index_orclauses(RelOptInfo *rel, RelOptInfo *index, int indexkey,
int xclass, List *clauseinfo_list);
static bool
match_index_to_operand(int indexkey, Expr *operand,
- Rel *rel, Rel *index);
+ RelOptInfo *rel, RelOptInfo *index);
static List *
-match_index_orclause(Rel *rel, Rel *index, int indexkey,
+match_index_orclause(RelOptInfo *rel, RelOptInfo *index, int indexkey,
int xclass, List *or_clauses, List *other_matching_indices);
static List *
-group_clauses_by_indexkey(Rel *rel, Rel *index,
+group_clauses_by_indexkey(RelOptInfo *rel, RelOptInfo *index,
int *indexkeys, Oid *classes, List *clauseinfo_list);
static List *
-group_clauses_by_ikey_for_joins(Rel *rel, Rel *index,
+group_clauses_by_ikey_for_joins(RelOptInfo *rel, RelOptInfo *index,
int *indexkeys, Oid *classes, List *join_cinfo_list, List *restr_cinfo_list);
static CInfo *
-match_clause_to_indexkey(Rel *rel, Rel *index, int indexkey,
+match_clause_to_indexkey(RelOptInfo *rel, RelOptInfo *index, int indexkey,
int xclass, CInfo *clauseInfo, bool join);
static bool
pred_test(List *predicate_list, List *clauseinfo_list,
static bool one_pred_clause_test(Expr *predicate, Node *clause);
static bool clause_pred_clause_test(Expr *predicate, Node *clause);
static List *
-indexable_joinclauses(Rel *rel, Rel *index,
+indexable_joinclauses(RelOptInfo *rel, RelOptInfo *index,
List *joininfo_list, List *clauseinfo_list);
static List *
-index_innerjoin(Query *root, Rel *rel,
- List *clausegroup_list, Rel *index);
+index_innerjoin(Query *root, RelOptInfo *rel,
+ List *clausegroup_list, RelOptInfo *index);
static List *
-create_index_paths(Query *root, Rel *rel, Rel *index,
+create_index_paths(Query *root, RelOptInfo *rel, RelOptInfo *index,
List *clausegroup_list, bool join);
static List *add_index_paths(List *indexpaths, List *new_indexpaths);
-static bool function_index_operand(Expr *funcOpnd, Rel *rel, Rel *index);
-static bool SingleAttributeIndex(Rel *index);
+static bool function_index_operand(Expr *funcOpnd, RelOptInfo *rel, RelOptInfo *index);
+static bool SingleAttributeIndex(RelOptInfo *index);
/* If Spyros can use a constant PRS2_BOOL_TYPEID, I can use this */
#define BOOL_TYPEID ((Oid) 16)
*/
List *
find_index_paths(Query *root,
- Rel *rel,
+ RelOptInfo *rel,
List *indices,
List *clauseinfo_list,
List *joininfo_list)
{
List *scanclausegroups = NIL;
List *scanpaths = NIL;
- Rel *index = (Rel *) NULL;
+ RelOptInfo *index = (RelOptInfo *) NULL;
List *joinclausegroups = NIL;
List *joinpaths = NIL;
List *retval = NIL;
if (indices == NIL)
return (NULL);
- index = (Rel *) lfirst(indices);
+ index = (RelOptInfo *) lfirst(indices);
retval = find_index_paths(root,
rel,
*
*/
static void
-match_index_orclauses(Rel *rel,
- Rel *index,
+match_index_orclauses(RelOptInfo *rel,
+ RelOptInfo *index,
int indexkey,
int xclass,
List *clauseinfo_list)
static bool
match_index_to_operand(int indexkey,
Expr *operand,
- Rel *rel,
- Rel *index)
+ RelOptInfo *rel,
+ RelOptInfo *index)
{
/*
* match the third, g,h match the fourth, etc.
*/
static List *
-match_index_orclause(Rel *rel,
- Rel *index,
+match_index_orclause(RelOptInfo *rel,
+ RelOptInfo *index,
int indexkey,
int xclass,
List *or_clauses,
*
*/
static List *
-group_clauses_by_indexkey(Rel *rel,
- Rel *index,
+group_clauses_by_indexkey(RelOptInfo *rel,
+ RelOptInfo *index,
int *indexkeys,
Oid *classes,
List *clauseinfo_list)
*
*/
static List *
-group_clauses_by_ikey_for_joins(Rel *rel,
- Rel *index,
+group_clauses_by_ikey_for_joins(RelOptInfo *rel,
+ RelOptInfo *index,
int *indexkeys,
Oid *classes,
List *join_cinfo_list,
*
*/
static CInfo *
-match_clause_to_indexkey(Rel *rel,
- Rel *index,
+match_clause_to_indexkey(RelOptInfo *rel,
+ RelOptInfo *index,
int indexkey,
int xclass,
CInfo *clauseInfo,
*
*/
static List *
-indexable_joinclauses(Rel *rel, Rel *index,
+indexable_joinclauses(RelOptInfo *rel, RelOptInfo *index,
List *joininfo_list, List *clauseinfo_list)
{
JInfo *joininfo = (JInfo *) NULL;
*
*/
static List *
-index_innerjoin(Query *root, Rel *rel, List *clausegroup_list, Rel *index)
+index_innerjoin(Query *root, RelOptInfo *rel, List *clausegroup_list, RelOptInfo *index)
{
List *clausegroup = NIL;
List *cg_list = NIL;
*/
static List *
create_index_paths(Query *root,
- Rel *rel,
- Rel *index,
+ RelOptInfo *rel,
+ RelOptInfo *index,
List *clausegroup_list,
bool join)
{
}
static bool
-function_index_operand(Expr *funcOpnd, Rel *rel, Rel *index)
+function_index_operand(Expr *funcOpnd, RelOptInfo *rel, RelOptInfo *index)
{
Oid heapRelid = (Oid) lfirsti(rel->relids);
Func *function;
}
static bool
-SingleAttributeIndex(Rel *index)
+SingleAttributeIndex(RelOptInfo *index)
{
/*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.6 1998/06/15 19:28:40 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.7 1998/07/18 04:22:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static Path *best_innerjoin(List *join_paths, List *outer_relid);
static List *
-sort_inner_and_outer(Rel *joinrel, Rel *outerrel, Rel *innerrel,
+sort_inner_and_outer(RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel,
List *mergeinfo_list);
static List *
-match_unsorted_outer(Rel *joinrel, Rel *outerrel, Rel *innerrel,
+match_unsorted_outer(RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel,
List *outerpath_list, Path *cheapest_inner, Path *best_innerjoin,
List *mergeinfo_list);
static List *
-match_unsorted_inner(Rel *joinrel, Rel *outerrel, Rel *innerrel,
+match_unsorted_inner(RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel,
List *innerpath_list, List *mergeinfo_list);
-static bool EnoughMemoryForHashjoin(Rel *hashrel);
+static bool EnoughMemoryForHashjoin(RelOptInfo *hashrel);
static List *
-hash_inner_and_outer(Rel *joinrel, Rel *outerrel, Rel *innerrel,
+hash_inner_and_outer(RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel,
List *hashinfo_list);
/*
while (joinrels != NIL)
{
- Rel *joinrel = (Rel *) lfirst(joinrels);
+ RelOptInfo *joinrel = (RelOptInfo *) lfirst(joinrels);
List *innerrelids;
List *outerrelids;
- Rel *innerrel;
- Rel *outerrel;
+ RelOptInfo *innerrel;
+ RelOptInfo *outerrel;
Path *bestinnerjoin;
List *pathlist = NIL;
* Returns a list of mergesort paths.
*/
static List *
-sort_inner_and_outer(Rel *joinrel,
- Rel *outerrel,
- Rel *innerrel,
+sort_inner_and_outer(RelOptInfo *joinrel,
+ RelOptInfo *outerrel,
+ RelOptInfo *innerrel,
List *mergeinfo_list)
{
List *ms_list = NIL;
* Returns a list of possible join path nodes.
*/
static List *
-match_unsorted_outer(Rel *joinrel,
- Rel *outerrel,
- Rel *innerrel,
+match_unsorted_outer(RelOptInfo *joinrel,
+ RelOptInfo *outerrel,
+ RelOptInfo *innerrel,
List *outerpath_list,
Path *cheapest_inner,
Path *best_innerjoin,
* Returns a list of possible merge paths.
*/
static List *
-match_unsorted_inner(Rel *joinrel,
- Rel *outerrel,
- Rel *innerrel,
+match_unsorted_inner(RelOptInfo *joinrel,
+ RelOptInfo *outerrel,
+ RelOptInfo *innerrel,
List *innerpath_list,
List *mergeinfo_list)
{
}
static bool
-EnoughMemoryForHashjoin(Rel *hashrel)
+EnoughMemoryForHashjoin(RelOptInfo *hashrel)
{
int ntuples;
int tupsize;
* Returns a list of hashjoin paths.
*/
static List *
-hash_inner_and_outer(Rel *joinrel,
- Rel *outerrel,
- Rel *innerrel,
+hash_inner_and_outer(RelOptInfo *joinrel,
+ RelOptInfo *outerrel,
+ RelOptInfo *innerrel,
List *hashinfo_list)
{
HInfo *xhashinfo = (HInfo *) NULL;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.10 1998/06/15 19:28:40 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.11 1998/07/18 04:22:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#endif
-static List *find_clause_joins(Query *root, Rel *outer_rel, List *joininfo_list);
-static List *find_clauseless_joins(Rel *outer_rel, List *inner_rels);
-static Rel *init_join_rel(Rel *outer_rel, Rel *inner_rel, JInfo *joininfo);
+static List *find_clause_joins(Query *root, RelOptInfo *outer_rel, List *joininfo_list);
+static List *find_clauseless_joins(RelOptInfo *outer_rel, List *inner_rels);
+static RelOptInfo *init_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JInfo *joininfo);
static List *
new_join_tlist(List *tlist, List *other_relids,
int first_resdomno);
static List *new_joininfo_list(List *joininfo_list, List *join_relids);
-static void add_superrels(Rel *rel, Rel *super_rel);
-static bool nonoverlap_rels(Rel *rel1, Rel *rel2);
+static void add_superrels(RelOptInfo *rel, RelOptInfo *super_rel);
+static bool nonoverlap_rels(RelOptInfo *rel1, RelOptInfo *rel2);
static bool nonoverlap_sets(List *s1, List *s2);
static void
-set_joinrel_size(Rel *joinrel, Rel *outer_rel, Rel *inner_rel,
+set_joinrel_size(RelOptInfo *joinrel, RelOptInfo *outer_rel, RelOptInfo *inner_rel,
JInfo *jinfo);
/*
foreach(r, outer_rels)
{
- Rel *outer_rel = (Rel *) lfirst(r);
+ RelOptInfo *outer_rel = (RelOptInfo *) lfirst(r);
if (!(joins = find_clause_joins(root, outer_rel, outer_rel->joininfo)))
{
* Returns a list of new join relations.
*/
static List *
-find_clause_joins(Query *root, Rel *outer_rel, List *joininfo_list)
+find_clause_joins(Query *root, RelOptInfo *outer_rel, List *joininfo_list)
{
List *join_list = NIL;
List *i = NIL;
foreach(i, joininfo_list)
{
JInfo *joininfo = (JInfo *) lfirst(i);
- Rel *rel;
+ RelOptInfo *rel;
if (!joininfo->inactive)
{
* Returns a list of new join relations.
*/
static List *
-find_clauseless_joins(Rel *outer_rel, List *inner_rels)
+find_clauseless_joins(RelOptInfo *outer_rel, List *inner_rels)
{
- Rel *inner_rel;
+ RelOptInfo *inner_rel;
List *t_list = NIL;
List *temp_node = NIL;
List *i = NIL;
foreach(i, inner_rels)
{
- inner_rel = (Rel *) lfirst(i);
+ inner_rel = (RelOptInfo *) lfirst(i);
if (nonoverlap_rels(inner_rel, outer_rel))
{
temp_node = lcons(init_join_rel(outer_rel,
*
* Returns the new join relation node.
*/
-static Rel *
-init_join_rel(Rel *outer_rel, Rel *inner_rel, JInfo *joininfo)
+static RelOptInfo *
+init_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JInfo *joininfo)
{
- Rel *joinrel = makeNode(Rel);
+ RelOptInfo *joinrel = makeNode(RelOptInfo);
List *joinrel_joininfo_list = NIL;
List *new_outer_tlist;
List *new_inner_tlist;
foreach(xjoinrel, joinrels)
{
- Rel *joinrel = (Rel *) lfirst(xjoinrel);
+ RelOptInfo *joinrel = (RelOptInfo *) lfirst(xjoinrel);
foreach(xrelid, joinrel->relids)
{
Relid relid = (Relid) lfirst(xrelid);
- Rel *rel = get_join_rel(root, relid);
+ RelOptInfo *rel = get_join_rel(root, relid);
add_superrels(rel, joinrel);
}
}
foreach(xjoinrel, joinrels)
{
- Rel *joinrel = (Rel *) lfirst(xjoinrel);
+ RelOptInfo *joinrel = (RelOptInfo *) lfirst(xjoinrel);
foreach(xjoininfo, joinrel->joininfo)
{
foreach(xrelid, other_rels)
{
Relid relid = (Relid) lfirst(xrelid);
- Rel *rel = get_join_rel(root, relid);
+ RelOptInfo *rel = get_join_rel(root, relid);
List *super_rels = rel->superrels;
List *xsuper_rel = NIL;
JInfo *new_joininfo = makeNode(JInfo);
foreach(xsuper_rel, super_rels)
{
- Rel *super_rel = (Rel *) lfirst(xsuper_rel);
+ RelOptInfo *super_rel = (RelOptInfo *) lfirst(xsuper_rel);
if (nonoverlap_rels(super_rel, joinrel))
{
}
foreach(xrel, outerrels)
{
- Rel *rel = (Rel *) lfirst(xrel);
+ RelOptInfo *rel = (RelOptInfo *) lfirst(xrel);
rel->superrels = NIL;
}
*/
foreach(xrel, join_rel_list)
{
- Rel *rel = (Rel *) lfirst(xrel);
+ RelOptInfo *rel = (RelOptInfo *) lfirst(xrel);
List *xjoininfo = NIL;
bool final = true;
* Modifies the superrels field of rel
*/
static void
-add_superrels(Rel *rel, Rel *super_rel)
+add_superrels(RelOptInfo *rel, RelOptInfo *super_rel)
{
rel->superrels = lappend(rel->superrels, super_rel);
}
* Returns non-nil if rel1 and rel2 do not overlap.
*/
static bool
-nonoverlap_rels(Rel *rel1, Rel *rel2)
+nonoverlap_rels(RelOptInfo *rel1, RelOptInfo *rel2)
{
return (nonoverlap_sets(rel1->relids, rel2->relids));
}
}
static void
-set_joinrel_size(Rel *joinrel, Rel *outer_rel, Rel *inner_rel, JInfo *jinfo)
+set_joinrel_size(RelOptInfo *joinrel, RelOptInfo *outer_rel, RelOptInfo *inner_rel, JInfo *jinfo)
{
int ntuples;
float selec;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.6 1998/06/15 19:28:41 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.7 1998/07/18 04:22:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static void
-best_or_subclause_indices(Query *root, Rel *rel, List *subclauses,
+best_or_subclause_indices(Query *root, RelOptInfo *rel, List *subclauses,
List *indices, List *examined_indexids, Cost subcost, List *selectivities,
List **indexids, Cost *cost, List **selecs);
static void
-best_or_subclause_index(Query *root, Rel *rel, Expr *subclause,
+best_or_subclause_index(Query *root, RelOptInfo *rel, Expr *subclause,
List *indices, int *indexid, Cost *cost, Cost *selec);
*/
List *
create_or_index_paths(Query *root,
- Rel *rel, List *clauses)
+ RelOptInfo *rel, List *clauses)
{
List *t_list = NIL;
*/
static void
best_or_subclause_indices(Query *root,
- Rel *rel,
+ RelOptInfo *rel,
List *subclauses,
List *indices,
List *examined_indexids,
*/
static void
best_or_subclause_index(Query *root,
- Rel *rel,
+ RelOptInfo *rel,
Expr *subclause,
List *indices,
int *retIndexid, /* return value */
Datum value;
int flag = 0;
Cost subcost;
- Rel *index = (Rel *) lfirst(indices);
+ RelOptInfo *index = (RelOptInfo *) lfirst(indices);
AttrNumber attno = (get_leftop(subclause))->varattno;
Oid opno = ((Oper *) subclause->oper)->opno;
bool constant_on_right = non_null((Expr *) get_rightop(subclause));
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.14 1998/06/15 19:28:41 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.15 1998/07/18 04:22:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "utils/elog.h"
-static List *prune_joinrel(Rel *rel, List *other_rels);
+static List *prune_joinrel(RelOptInfo *rel, List *other_rels);
/*
* prune-joinrels--
* deleted
*/
foreach(i, rel_list)
- lnext(i) = prune_joinrel((Rel *) lfirst(i), lnext(i));
+ lnext(i) = prune_joinrel((RelOptInfo *) lfirst(i), lnext(i));
}
/*
*
*/
static List *
-prune_joinrel(Rel *rel, List *other_rels)
+prune_joinrel(RelOptInfo *rel, List *other_rels)
{
List *i = NIL;
List *result = NIL;
foreach(i, other_rels)
{
- Rel *other_rel = (Rel *) lfirst(i);
+ RelOptInfo *other_rel = (RelOptInfo *) lfirst(i);
if (same(rel->relids, other_rel->relids))
{
List *x = NIL;
List *y = NIL;
Path *path = NULL;
- Rel *rel = (Rel *) NULL;
+ RelOptInfo *rel = (RelOptInfo *) NULL;
JoinPath *cheapest = (JoinPath *) NULL;
foreach(x, rel_list)
{
- rel = (Rel *) lfirst(x);
+ rel = (RelOptInfo *) lfirst(x);
rel->size = 0;
foreach(y, rel->pathlist)
{
*
*/
Path *
-prune_rel_path(Rel *rel, Path *unorderedpath)
+prune_rel_path(RelOptInfo *rel, Path *unorderedpath)
{
Path *cheapest = set_cheapest(rel, rel->pathlist);
foreach(xrel, rel_list1)
{
- Rel *rel = (Rel *) lfirst(xrel);
+ RelOptInfo *rel = (RelOptInfo *) lfirst(xrel);
rel_list2 = prune_joinrel(rel, rel_list2);
}
List *
prune_oldrels(List *old_rels)
{
- Rel *rel;
+ RelOptInfo *rel;
List *joininfo_list,
*xjoininfo,
*i,
foreach(i, old_rels)
{
- rel = (Rel *) lfirst(i);
+ rel = (RelOptInfo *) lfirst(i);
joininfo_list = rel->joininfo;
if (joininfo_list == NIL)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.15 1998/06/15 19:28:42 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.16 1998/07/18 04:22:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
void
-xfunc_trypullup(Rel rel)
+xfunc_trypullup(RelOptInfo rel)
{
LispValue y; /* list ptr */
CInfo maxcinfo; /* The CInfo to pull up, as calculated by
/*
* * we've left an expensive restriction below a join. Since *
* we may pullup this restriction in predmig.c, we'd best *
- * set the Rel of this join to be unpruneable
+ * set the RelOptInfo of this join to be unpruneable
*/
set_pruneable(get_parent(parentpath), false);
/* and fall through */
** xfunc_pullup --
** move clause from child pathnode to parent pathnode. This operation
** makes the child pathnode produce a larger relation than it used to.
- ** This means that we must construct a new Rel just for the childpath,
- ** although this Rel will not be added to the list of Rels to be joined up
+ ** This means that we must construct a new RelOptInfo just for the childpath,
+ ** although this RelOptInfo will not be added to the list of Rels to be joined up
** in the query; it's merely a parent for the new childpath.
** We also have to fix up the path costs of the child and parent.
**
int clausetype) /* whether clause to pull is join or local */
{
Path newkid;
- Rel newrel;
+ RelOptInfo newrel;
Cost pulled_selec;
Cost cost;
CInfo newinfo;
}
/*
- * * give the new child path its own Rel node that reflects the * lack
+ * * give the new child path its own RelOptInfo node that reflects the * lack
* of the pulled-up predicate
*/
pulled_selec = compute_clause_selec(queryInfo,
/*
* * the second argument to xfunc_card_unreferenced reflects all the *
* relations involved in the join clause, i.e. all the relids in the
- * Rel * of the join clause
+ * RelOptInfo * of the join clause
*/
Count card = 0;
Cost cost = xfunc_expense_per_tuple(path, whichchild);
/* find all relids of base relations referenced in query */
foreach(temp, queryInfo->base_relation_list_)
{
- Assert(lnext(get_relids((Rel) lfirst(temp))) == LispNil);
+ Assert(lnext(get_relids((RelOptInfo) lfirst(temp))) == LispNil);
allrelids = lappend(allrelids,
- lfirst(get_relids((Rel) lfirst(temp))));
+ lfirst(get_relids((RelOptInfo) lfirst(temp))));
}
/* find all relids referenced in query but not in clause */
{
LispValue cinfonode;
LispValue temp;
- Rel currel;
+ RelOptInfo currel;
Cost tuples;
Count retval = 0;
Cost
xfunc_expense_per_tuple(JoinPath joinnode, int whichchild)
{
- Rel outerrel = get_parent((Path) get_outerjoinpath(joinnode));
- Rel innerrel = get_parent((Path) get_innerjoinpath(joinnode));
+ RelOptInfo outerrel = get_parent((Path) get_outerjoinpath(joinnode));
+ RelOptInfo innerrel = get_parent((Path) get_innerjoinpath(joinnode));
Count outerwidth = get_width(outerrel);
Count outers_per_page = ceil(BLCKSZ / (outerwidth + sizeof(HeapTupleData)));
** nodes to point to the correct varno (either INNER or OUTER, depending
** on which child the clause was pulled from), and the right varattno in the
** target list of the child's former relation. If the target list of the
- ** child Rel does not contain the attribute we need, we add it.
+ ** child RelOptInfo does not contain the attribute we need, we add it.
*/
void
xfunc_fixvars(LispValue clause, /* clause being pulled up */
- Rel rel, /* rel it's being pulled from */
+ RelOptInfo rel, /* rel it's being pulled from */
int varno) /* whether rel is INNER or OUTER of join */
{
LispValue tmpclause; /* temporary variable */
** Just like _copyRel, but doesn't copy the paths
*/
bool
-xfunc_copyrel(Rel from, Rel *to)
+xfunc_copyrel(RelOptInfo from, RelOptInfo *to)
{
- Rel newnode;
+ RelOptInfo newnode;
Pointer (*alloc) () = palloc;
}
/* COPY_NEW(c) */
- newnode = (Rel) (*alloc) (classSize(Rel));
+ newnode = (RelOptInfo) (*alloc) (classSize(RelOptInfo));
if (newnode == NULL)
return false;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.28 1998/06/15 19:28:42 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.29 1998/07/18 04:22:36 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
List *tlist;
Plan *plan_node = (Plan *) NULL;
- Rel *parent_rel;
+ RelOptInfo *parent_rel;
int size;
int width;
int pages;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.12 1998/06/15 19:28:43 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.13 1998/07/18 04:22:37 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
Var *var;
Index varno;
- Rel *result;
+ RelOptInfo *result;
var = (Var *) lfirst(tvar);
varno = var->varno;
{
RangeTblEntry *rte = (RangeTblEntry *) lfirst(l);
List *relids;
- Rel *result;
+ RelOptInfo *result;
Var *var;
relids = lconsi(varno, NIL);
if (length(relids) == 1)
{
- Rel *rel = get_base_rel(root, lfirsti(relids));
+ RelOptInfo *rel = get_base_rel(root, lfirsti(relids));
/*
* There is only one relation participating in 'clause', so
{
Var *var;
List *temp = NIL;
- Rel *rel = (Rel *) NULL;
+ RelOptInfo *rel = (RelOptInfo *) NULL;
TargetEntry *tlistentry;
foreach(temp, vars)
List *x,
*y,
*z;
- Rel *rel;
+ RelOptInfo *rel;
JInfo *joininfo;
CInfo *clauseinfo;
Expr *clause;
foreach(x, rel_list)
{
- rel = (Rel *) lfirst(x);
+ rel = (RelOptInfo *) lfirst(x);
foreach(y, rel->joininfo)
{
joininfo = (JInfo *) lfirst(y);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.22 1998/06/15 19:28:44 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.23 1998/07/18 04:22:37 momjian Exp $
*
*-------------------------------------------------------------------------
*/
List *flat_tlist,
List *qual)
{
- Rel *final_relation;
+ RelOptInfo *final_relation;
List *final_relation_list;
/*
root->base_relation_list_);
if (final_relation_list)
- final_relation = (Rel *) lfirst(final_relation_list);
+ final_relation = (RelOptInfo *) lfirst(final_relation_list);
else
- final_relation = (Rel *) NIL;
+ final_relation = (RelOptInfo *) NIL;
#if 0 /* fix xfunc */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/indexnode.c,v 1.7 1998/06/15 19:28:48 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/indexnode.c,v 1.8 1998/07/18 04:22:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*
*/
List *
-find_relation_indices(Query *root, Rel *rel)
+find_relation_indices(Query *root, RelOptInfo *rel)
{
if (rel->indexed)
return (find_secondary_index(root, lfirsti(rel->relids)));
while (index_info(root, first, relid, &indexinfo))
{
- Rel *indexnode = makeNode(Rel);
+ RelOptInfo *indexnode = makeNode(RelOptInfo);
indexnode->relids = lconsi(indexinfo.relid, NIL);
indexnode->relam = indexinfo.relam;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.7 1998/06/15 19:28:48 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.8 1998/07/18 04:22:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*
*/
JInfo *
-find_joininfo_node(Rel *this_rel, List *join_relids)
+find_joininfo_node(RelOptInfo *this_rel, List *join_relids)
{
JInfo *joininfo = joininfo_member(join_relids,
this_rel->joininfo);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/keys.c,v 1.6 1998/02/26 04:33:19 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/keys.c,v 1.7 1998/07/18 04:22:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*
*/
bool
-match_indexkey_operand(int indexkey, Var *operand, Rel *rel)
+match_indexkey_operand(int indexkey, Var *operand, RelOptInfo *rel)
{
if (IsA(operand, Var) &&
(lfirsti(rel->relids) == operand->varno) &&
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.8 1998/06/15 19:28:49 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.9 1998/07/18 04:22:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*
*/
Path *
-set_cheapest(Rel *parent_rel, List *pathlist)
+set_cheapest(RelOptInfo *parent_rel, List *pathlist)
{
List *p;
Path *cheapest_so_far;
Assert(pathlist != NIL);
- Assert(IsA(parent_rel, Rel));
+ Assert(IsA(parent_rel, RelOptInfo));
cheapest_so_far = (Path *) lfirst(pathlist);
*
*/
List *
-add_pathlist(Rel *parent_rel, List *unique_paths, List *new_paths)
+add_pathlist(RelOptInfo *parent_rel, List *unique_paths, List *new_paths)
{
List *x;
Path *new_path;
*
*/
Path *
-create_seqscan_path(Rel *rel)
+create_seqscan_path(RelOptInfo *rel)
{
int relid = 0;
*/
IndexPath *
create_index_path(Query *root,
- Rel *rel,
- Rel *index,
+ RelOptInfo *rel,
+ RelOptInfo *index,
List *restriction_clauses,
bool is_join_scan)
{
*
*/
JoinPath *
-create_nestloop_path(Rel *joinrel,
- Rel *outer_rel,
+create_nestloop_path(RelOptInfo *joinrel,
+ RelOptInfo *outer_rel,
Path *outer_path,
Path *inner_path,
List *keys)
*
*/
MergePath *
-create_mergesort_path(Rel *joinrel,
+create_mergesort_path(RelOptInfo *joinrel,
int outersize,
int innersize,
int outerwidth,
*
*/
HashPath *
-create_hashjoin_path(Rel *joinrel,
+create_hashjoin_path(RelOptInfo *joinrel,
int outersize,
int innersize,
int outerwidth,
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.5 1998/02/26 04:33:21 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.6 1998/07/18 04:22:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* necessary. This is for base relations.
*
*/
-Rel *
+RelOptInfo *
get_base_rel(Query *root, int relid)
{
List *relids;
- Rel *rel;
+ RelOptInfo *rel;
relids = lconsi(relid, NIL);
rel = rel_member(relids, root->base_relation_list_);
if (rel == NULL)
{
- rel = makeNode(Rel);
+ rel = makeNode(RelOptInfo);
rel->relids = relids;
rel->indexed = false;
rel->pages = 0;
* creating a new one if necessary. This is for join relations.
*
*/
-Rel *
+RelOptInfo *
get_join_rel(Query *root, List *relid)
{
return rel_member(relid, root->join_relation_list_);
* Returns the corresponding entry in 'rels' if it is there.
*
*/
-Rel *
+RelOptInfo *
rel_member(List *relid, List *rels)
{
List *temp = NIL;
{
foreach(temp, rels)
{
- temprelid = ((Rel *) lfirst(temp))->relids;
+ temprelid = ((RelOptInfo *) lfirst(temp))->relids;
if (same(temprelid, relid))
- return ((Rel *) (lfirst(temp)));
+ return ((RelOptInfo *) (lfirst(temp)));
}
}
return (NULL);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.13 1998/06/15 19:28:49 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.14 1998/07/18 04:22:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* CREATES: new var-node iff no matching var-node exists in targetlist
*/
void
-add_tl_element(Rel *rel, Var *var)
+add_tl_element(RelOptInfo *rel, Var *var)
{
Expr *oldvar = (Expr *) NULL;
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodes.h,v 1.24 1998/02/13 03:45:23 vadim Exp $
+ * $Id: nodes.h,v 1.25 1998/07/18 04:22:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* TAGS FOR INNER PLAN NODES (relation.h)
*---------------------
*/
- T_Rel = 200,
+ T_RelOptInfo = 200,
T_Path,
T_IndexPath,
T_JoinPath,
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: relation.h,v 1.7 1997/09/08 21:53:01 momjian Exp $
+ * $Id: relation.h,v 1.8 1998/07/18 04:22:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
typedef List *Relid;
/*
- * Rel
+ * RelOptInfo
* Per-base-relation information
*
* Parts of this data structure are specific to various scan and join
* leaves the tuples unordered)
* cheapestpath - least expensive Path (regardless of final order)
* pruneable - flag to let the planner know whether it can prune the plan
- * space of this Rel or not. -- JMH, 11/11/92
+ * space of this RelOptInfo or not. -- JMH, 11/11/92
*
* * If the relation is a (secondary) index it will have the following
* three fields:
* is always 0. 2/95 - ay
*/
-typedef struct Rel
+typedef struct RelOptInfo
{
NodeTag type;
List *joininfo; /* join clauses */
List *innerjoin;
List *superrels;
-} Rel;
+} RelOptInfo;
extern Var *get_expr(TargetEntry *foo);
{
NodeTag type;
- Rel *parent;
+ RelOptInfo *parent;
Cost path_cost;
NodeTag pathtype;
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: cost.h,v 1.8 1998/02/26 04:42:14 momjian Exp $
+ * $Id: cost.h,v 1.9 1998/07/18 04:22:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
cost_hashjoin(Cost outercost, Cost innercost, List *outerkeys,
List *innerkeys, int outersize, int innersize,
int outerwidth, int innerwidth);
-extern int compute_rel_size(Rel *rel);
-extern int compute_rel_width(Rel *rel);
+extern int compute_rel_size(RelOptInfo *rel);
+extern int compute_rel_width(RelOptInfo *rel);
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: geqo.h,v 1.7 1997/11/26 01:13:23 momjian Exp $
+ * $Id: geqo.h,v 1.8 1998/07/18 04:22:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* ^^^ */
/* geqo prototypes */
-extern Rel *geqo(Query *root);
+extern RelOptInfo *geqo(Query *root);
extern void geqo_params(int string_length);
extern Cost geqo_eval(Query *root, Gene *tour, int num_gene);
double geqo_log(double x, double b);
-extern Rel *gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, Rel *outer_rel);
+extern RelOptInfo *gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *outer_rel);
#endif /* GEQO_H */
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: geqo_misc.h,v 1.5 1997/11/26 01:13:28 momjian Exp $
+ * $Id: geqo_misc.h,v 1.6 1998/07/18 04:22:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void print_gen(FILE *fp, Pool *pool, int generation);
extern void print_edge_table(FILE *fp, Edge *edge_table, int num_gene);
-extern void geqo_print_rel(Query *root, Rel *rel);
+extern void geqo_print_rel(Query *root, RelOptInfo *rel);
extern void geqo_print_path(Query *root, Path *path, int indent);
extern void geqo_print_joinclauses(Query *root, List *clauses);
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: geqo_paths.h,v 1.4 1997/09/08 21:53:14 momjian Exp $
+ * $Id: geqo_paths.h,v 1.5 1998/07/18 04:22:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern List *geqo_prune_rels(List *rel_list);
-extern void geqo_rel_paths(Rel *rel);
+extern void geqo_rel_paths(RelOptInfo *rel);
#endif /* GEQO_PATHS_H */
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: joininfo.h,v 1.5 1997/11/26 01:13:39 momjian Exp $
+ * $Id: joininfo.h,v 1.6 1998/07/18 04:22:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "nodes/primnodes.h"
extern JInfo *joininfo_member(List *join_relids, List *joininfo_list);
-extern JInfo *find_joininfo_node(Rel *this_rel, List *join_relids);
+extern JInfo *find_joininfo_node(RelOptInfo *this_rel, List *join_relids);
extern Var *other_join_clause_var(Var *var, Expr *clause);
#endif /* JOININFO_H */
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: keys.h,v 1.6 1997/11/26 01:13:41 momjian Exp $
+ * $Id: keys.h,v 1.7 1998/07/18 04:22:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "nodes/nodes.h"
#include "nodes/relation.h"
-extern bool match_indexkey_operand(int indexkey, Var *operand, Rel *rel);
+extern bool match_indexkey_operand(int indexkey, Var *operand, RelOptInfo *rel);
extern Var *extract_subkey(JoinKey *jk, int which_subkey);
extern bool samekeys(List *keys1, List *keys2);
extern List *collect_index_pathkeys(int *index_keys, List *tlist);
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: pathnode.h,v 1.7 1998/02/26 04:42:16 momjian Exp $
+ * $Id: pathnode.h,v 1.8 1998/07/18 04:22:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* prototypes for pathnode.c
*/
extern bool path_is_cheaper(Path *path1, Path *path2);
-extern Path *set_cheapest(Rel *parent_rel, List *pathlist);
+extern Path *set_cheapest(RelOptInfo *parent_rel, List *pathlist);
extern List *
-add_pathlist(Rel *parent_rel, List *unique_paths,
+add_pathlist(RelOptInfo *parent_rel, List *unique_paths,
List *new_paths);
-extern Path *create_seqscan_path(Rel *rel);
+extern Path *create_seqscan_path(RelOptInfo *rel);
extern IndexPath *
-create_index_path(Query *root, Rel *rel, Rel *index,
+create_index_path(Query *root, RelOptInfo *rel, RelOptInfo *index,
List *restriction_clauses, bool is_join_scan);
extern JoinPath *
-create_nestloop_path(Rel *joinrel, Rel *outer_rel,
+create_nestloop_path(RelOptInfo *joinrel, RelOptInfo *outer_rel,
Path *outer_path, Path *inner_path, List *keys);
extern MergePath *
-create_mergesort_path(Rel *joinrel, int outersize,
+create_mergesort_path(RelOptInfo *joinrel, int outersize,
int innersize, int outerwidth, int innerwidth, Path *outer_path,
Path *inner_path, List *keys, MergeOrder *order,
List *mergeclauses, List *outersortkeys, List *innersortkeys);
extern HashPath *
-create_hashjoin_path(Rel *joinrel, int outersize,
+create_hashjoin_path(RelOptInfo *joinrel, int outersize,
int innersize, int outerwidth, int innerwidth, Path *outer_path,
Path *inner_path, List *keys, Oid operator, List *hashclauses,
List *outerkeys, List *innerkeys);
/*
* prototypes for rel.c
*/
-extern Rel *rel_member(List *relid, List *rels);
-extern Rel *get_base_rel(Query *root, int relid);
-extern Rel *get_join_rel(Query *root, List *relid);
+extern RelOptInfo *rel_member(List *relid, List *rels);
+extern RelOptInfo *get_base_rel(Query *root, int relid);
+extern RelOptInfo *get_join_rel(Query *root, List *relid);
/*
* prototypes for indexnode.h
*/
-extern List *find_relation_indices(Query *root, Rel *rel);
+extern List *find_relation_indices(Query *root, RelOptInfo *rel);
#endif /* PATHNODE_H */
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: paths.h,v 1.8 1998/02/26 04:42:17 momjian Exp $
+ * $Id: paths.h,v 1.9 1998/07/18 04:22:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* routines to generate index paths
*/
extern List *
-find_index_paths(Query *root, Rel *rel, List *indices,
+find_index_paths(Query *root, RelOptInfo *rel, List *indices,
List *clauseinfo_list,
List *joininfo_list);
/*
* orindxpath.h
*/
-extern List *create_or_index_paths(Query *root, Rel *rel, List *clauses);
+extern List *create_or_index_paths(Query *root, RelOptInfo *rel, List *clauses);
/*
* hashutils.h
*/
extern void prune_joinrels(List *rel_list);
extern void prune_rel_paths(List *rel_list);
-extern Path *prune_rel_path(Rel *rel, Path *unorderedpath);
+extern Path *prune_rel_path(RelOptInfo *rel, Path *unorderedpath);
extern List *merge_joinrels(List *rel_list1, List *rel_list2);
extern List *prune_oldrels(List *old_rels);
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: tlist.h,v 1.8 1998/02/26 04:42:31 momjian Exp $
+ * $Id: tlist.h,v 1.9 1998/07/18 04:22:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern int exec_tlist_length(List *targelist);
extern TargetEntry *tlistentry_member(Var *var, List *targetlist);
extern Expr *matching_tlvar(Var *var, List *targetlist);
-extern void add_tl_element(Rel *rel, Var *var);
+extern void add_tl_element(RelOptInfo *rel, Var *var);
extern TargetEntry *create_tl_element(Var *var, int resdomno);
extern List *get_actual_tlist(List *tlist);
extern Resdom *tlist_member(Var *var, List *tlist);
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: xfunc.h,v 1.7 1998/02/26 04:42:33 momjian Exp $
+ * $Id: xfunc.h,v 1.8 1998/07/18 04:22:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define is_join(pathnode) (length(get_relids(get_parent(pathnode))) > 1 ? 1 : 0)
/* function prototypes from planner/path/xfunc.c */
-extern void xfunc_trypullup(Rel *rel);
+extern void xfunc_trypullup(RelOptInfo *rel);
extern int
xfunc_shouldpull(Path *childpath, JoinPath *parentpath,
int whichchild, CInfo *maxcinfopt);
extern Cost xfunc_get_path_cost(Path *pathnode);
extern Cost xfunc_total_path_cost(JoinPath *pathnode);
extern Cost xfunc_expense_per_tuple(JoinPath *joinnode, int whichchild);
-extern void xfunc_fixvars(Expr *clause, Rel *rel, int varno);
+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 void xfunc_disjunct_sort(List *clause_list);
extern int xfunc_tuple_width(Relation rd);
extern int xfunc_num_join_clauses(JoinPath *path);
extern List *xfunc_LispRemove(List *foo, List *bar);
-extern bool xfunc_copyrel(Rel *from, Rel **to);
+extern bool xfunc_copyrel(RelOptInfo *from, RelOptInfo **to);
/*
* function prototypes for path/predmig.c