aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/path
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/optimizer/path')
-rw-r--r--src/backend/optimizer/path/allpaths.c55
-rw-r--r--src/backend/optimizer/path/clausesel.c13
-rw-r--r--src/backend/optimizer/path/hashutils.c4
-rw-r--r--src/backend/optimizer/path/indxpath.c4
-rw-r--r--src/backend/optimizer/path/joinrels.c6
-rw-r--r--src/backend/optimizer/path/joinutils.c10
-rw-r--r--src/backend/optimizer/path/mergeutils.c6
-rw-r--r--src/backend/optimizer/path/orindxpath.c4
-rw-r--r--src/backend/optimizer/path/predmig.c8
-rw-r--r--src/backend/optimizer/path/prune.c32
-rw-r--r--src/backend/optimizer/path/xfunc.c6
11 files changed, 78 insertions, 70 deletions
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index e691e8cfc5b..8548dcf5426 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.14 1997/12/21 05:18:18 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.15 1998/02/26 04:32:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,7 +53,7 @@ static List *find_join_paths(Query *root, List *outer_rels, int levels_needed);
*
* 'rels' is the list of single relation entries appearing in the query
*/
-List *
+List *
find_paths(Query *root, List *rels)
{
int levels_needed;
@@ -189,66 +189,69 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed)
* rest will be deprecated in case of GEQO *
*******************************************/
- while (--levels_needed)
- {
+ while (--levels_needed)
+ {
+
/*
* Determine all possible pairs of relations to be joined at this
- * level. Determine paths for joining these relation pairs and modify
- * 'new-rels' accordingly, then eliminate redundant join relations.
+ * level. Determine paths for joining these relation pairs and
+ * modify 'new-rels' accordingly, then eliminate redundant join
+ * relations.
*/
new_rels = find_join_rels(root, outer_rels);
-
+
find_all_join_paths(root, new_rels);
-
+
prune_joinrels(new_rels);
-
+
#if 0
-
+
/*
- * * for each expensive predicate in each path in each distinct rel, *
- * consider doing pullup -- JMH
+ * * for each expensive predicate in each path in each distinct
+ * rel, * consider doing pullup -- JMH
*/
if (XfuncMode != XFUNC_NOPULL && XfuncMode != XFUNC_OFF)
foreach(x, new_rels)
xfunc_trypullup((Rel *) lfirst(x));
#endif
-
+
prune_rel_paths(new_rels);
-
+
if (BushyPlanFlag)
{
-
+
/*
- * In case of bushy trees if there is still a join between a join
- * relation and another relation, add a new joininfo that involves
- * the join relation to the joininfo list of the other relation
+ * In case of bushy trees if there is still a join between a
+ * join relation and another relation, add a new joininfo that
+ * involves the join relation to the joininfo list of the
+ * other relation
*/
add_new_joininfos(root, new_rels, outer_rels);
}
-
+
foreach(x, new_rels)
{
rel = (Rel *) lfirst(x);
if (rel->size <= 0)
rel->size = compute_rel_size(rel);
rel->width = compute_rel_width(rel);
-
- /*#define OPTIMIZER_DEBUG*/
+
+ /* #define OPTIMIZER_DEBUG */
#ifdef OPTIMIZER_DEBUG
printf("levels left: %d\n", levels_left);
debug_print_rel(root, rel);
#endif
}
-
+
if (BushyPlanFlag)
{
-
+
/*
- * prune rels that have been completely incorporated into new join
- * rels
+ * prune rels that have been completely incorporated into new
+ * join rels
*/
outer_rels = prune_oldrels(outer_rels);
-
+
/*
* merge join rels if then contain the same list of base rels
*/
diff --git a/src/backend/optimizer/path/clausesel.c b/src/backend/optimizer/path/clausesel.c
index 54c2c9b831d..2911f19f4c2 100644
--- a/src/backend/optimizer/path/clausesel.c
+++ b/src/backend/optimizer/path/clausesel.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.5 1998/02/13 03:29:36 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.6 1998/02/26 04:32:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -273,16 +273,17 @@ compute_selec(Query *root, List *clauses, List *or_selectivities)
/* this isn't an Oper, it's a Func!! */
/*
- * This is not an operator, so we guess at the selectivity.
- * THIS IS A HACK TO GET V4 OUT THE DOOR. FUNCS SHOULD BE ABLE
- * TO HAVE SELECTIVITIES THEMSELVES. -- JMH 7/9/92
+ * This is not an operator, so we guess at the selectivity. THIS
+ * IS A HACK TO GET V4 OUT THE DOOR. FUNCS SHOULD BE ABLE TO HAVE
+ * SELECTIVITIES THEMSELVES. -- JMH 7/9/92
*/
s1 = 0.1;
}
- else if (is_subplan ((Node *) clause))
+ else if (is_subplan((Node *) clause))
{
+
/*
- * Just for the moment! FIX ME! - vadim 02/04/98
+ * Just for the moment! FIX ME! - vadim 02/04/98
*/
s1 = 1.0;
}
diff --git a/src/backend/optimizer/path/hashutils.c b/src/backend/optimizer/path/hashutils.c
index ffc332e8b26..88206ea6b09 100644
--- a/src/backend/optimizer/path/hashutils.c
+++ b/src/backend/optimizer/path/hashutils.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/hashutils.c,v 1.4 1997/09/08 21:44:51 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/hashutils.c,v 1.5 1998/02/26 04:32:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -34,7 +34,7 @@ static HInfo *match_hashop_hashinfo(Oid hashop, List *hashinfo_list);
* Returns the new list of hashinfo nodes.
*
*/
-List *
+List *
group_clauses_by_hashop(List *clauseinfo_list,
int inner_relid)
{
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c
index 50d8fb934eb..849b9f9406a 100644
--- a/src/backend/optimizer/path/indxpath.c
+++ b/src/backend/optimizer/path/indxpath.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.13 1998/02/13 03:29:39 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.14 1998/02/26 04:32:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -113,7 +113,7 @@ static bool SingleAttributeIndex(Rel *index);
* Returns a list of index nodes.
*
*/
-List *
+List *
find_index_paths(Query *root,
Rel *rel,
List *indices,
diff --git a/src/backend/optimizer/path/joinrels.c b/src/backend/optimizer/path/joinrels.c
index 7e28ee5cc67..7917baed097 100644
--- a/src/backend/optimizer/path/joinrels.c
+++ b/src/backend/optimizer/path/joinrels.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.7 1997/09/08 21:45:00 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.8 1998/02/26 04:32:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -58,7 +58,7 @@ set_joinrel_size(Rel *joinrel, Rel *outer_rel, Rel *inner_rel,
*
* Returns a list of rel nodes corresponding to the new join relations.
*/
-List *
+List *
find_join_rels(Query *root, List *outer_rels)
{
List *joins = NIL;
@@ -486,7 +486,7 @@ add_new_joininfos(Query *root, List *joinrels, List *outerrels)
*
* Returns the list of final join relations.
*/
-List *
+List *
final_join_rels(List *join_rel_list)
{
List *xrel = NIL;
diff --git a/src/backend/optimizer/path/joinutils.c b/src/backend/optimizer/path/joinutils.c
index 2c08c77b091..2dfad7ec594 100644
--- a/src/backend/optimizer/path/joinutils.c
+++ b/src/backend/optimizer/path/joinutils.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/joinutils.c,v 1.4 1997/09/08 21:45:01 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/joinutils.c,v 1.5 1998/02/26 04:32:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -73,7 +73,7 @@ new_matching_subkeys(Var *subkey, List *considered_subkeys,
* Returns a list of matched join keys and a list of matched join clauses
* in matchedJoinClausesPtr. - ay 11/94
*/
-List *
+List *
match_pathkeys_joinkeys(List *pathkeys,
List *joinkeys,
List *joinclauses,
@@ -211,7 +211,7 @@ every_func(List *joinkeys, List *pathkey, int which_subkey)
* match_paths_joinkeys -
* find the cheapest path that matches the join keys
*/
-Path *
+Path *
match_paths_joinkeys(List *joinkeys,
PathOrder *ordering,
List *paths,
@@ -263,7 +263,7 @@ match_paths_joinkeys(List *joinkeys,
* Returns a list of pathkeys: ((tlvar1)(tlvar2)...(tlvarN)).
* [I've no idea why they have to be list of lists. Should be fixed. -ay 12/94]
*/
-List *
+List *
extract_path_keys(List *joinkeys,
List *tlist,
int which_subkey)
@@ -325,7 +325,7 @@ extract_path_keys(List *joinkeys,
* Returns the list of new path keys.
*
*/
-List *
+List *
new_join_pathkeys(List *outer_pathkeys,
List *join_rel_tlist,
List *joinclauses)
diff --git a/src/backend/optimizer/path/mergeutils.c b/src/backend/optimizer/path/mergeutils.c
index 92103268772..938fb13864d 100644
--- a/src/backend/optimizer/path/mergeutils.c
+++ b/src/backend/optimizer/path/mergeutils.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.4 1997/09/08 21:45:02 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.5 1998/02/26 04:32:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -33,7 +33,7 @@
* Returns the new list of mergeinfo nodes.
*
*/
-List *
+List *
group_clauses_by_order(List *clauseinfo_list,
int inner_relid)
{
@@ -105,7 +105,7 @@ group_clauses_by_order(List *clauseinfo_list,
* Returns the node if it exists.
*
*/
-MInfo *
+MInfo *
match_order_mergeinfo(PathOrder *ordering, List *mergeinfo_list)
{
MergeOrder *xmergeorder;
diff --git a/src/backend/optimizer/path/orindxpath.c b/src/backend/optimizer/path/orindxpath.c
index 60d36ae3490..073aa18eb9a 100644
--- a/src/backend/optimizer/path/orindxpath.c
+++ b/src/backend/optimizer/path/orindxpath.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.4 1997/09/08 21:45:04 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.5 1998/02/26 04:32:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -50,7 +50,7 @@ best_or_subclause_index(Query *root, Rel *rel, Expr *subclause,
* Returns a list of these index path nodes.
*
*/
-List *
+List *
create_or_index_paths(Query *root,
Rel *rel, List *clauses)
{
diff --git a/src/backend/optimizer/path/predmig.c b/src/backend/optimizer/path/predmig.c
index 807a297f0cc..544a3c1c8e7 100644
--- a/src/backend/optimizer/path/predmig.c
+++ b/src/backend/optimizer/path/predmig.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/predmig.c,v 1.8 1998/01/07 21:03:51 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/predmig.c,v 1.9 1998/02/26 04:32:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -78,7 +78,7 @@ static int xfunc_stream_compare(void *arg1, void *arg2);
static bool xfunc_check_stream(Stream node);
static bool xfunc_in_stream(Stream node, Stream stream);
-/* ----------------- MAIN FUNCTIONS ------------------------ */
+/* ----------------- MAIN FUNCTIONS ------------------------ */
/*
** xfunc_do_predmig
** wrapper for Predicate Migration. It calls xfunc_predmig until no
@@ -495,7 +495,7 @@ xfunc_form_groups(Query *queryInfo, Stream root, Stream bottom)
}
-/* ------------------- UTILITY FUNCTIONS ------------------------- */
+/* ------------------- UTILITY FUNCTIONS ------------------------- */
/*
** xfunc_free_stream --
@@ -765,7 +765,7 @@ xfunc_stream_compare(void *arg1, void *arg2)
}
}
-/* ------------------ DEBUGGING ROUTINES ---------------------------- */
+/* ------------------ DEBUGGING ROUTINES ---------------------------- */
/*
** Make sure all pointers in stream make sense. Make sure no joins are
diff --git a/src/backend/optimizer/path/prune.c b/src/backend/optimizer/path/prune.c
index e6b83a643dd..014c72e9060 100644
--- a/src/backend/optimizer/path/prune.c
+++ b/src/backend/optimizer/path/prune.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.11 1998/01/07 21:03:53 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.12 1998/02/26 04:32:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -40,7 +40,8 @@ prune_joinrels(List *rel_list)
List *i;
/*
- * rel_list can shorten while running as duplicate relations are deleted
+ * rel_list can shorten while running as duplicate relations are
+ * deleted
*/
foreach(i, rel_list)
lnext(i) = prune_joinrel((Rel *) lfirst(i), lnext(i));
@@ -60,13 +61,13 @@ prune_joinrels(List *rel_list)
static List *
prune_joinrel(Rel *rel, List *other_rels)
{
- List *cur = NIL;
- List *return_list = NIL;
+ List *cur = NIL;
+ List *return_list = NIL;
/* find first relation that doesn't match */
foreach(cur, other_rels)
{
- Rel *other_rel = (Rel *) lfirst(cur);
+ Rel *other_rel = (Rel *) lfirst(cur);
if (!same(rel->relids, other_rel->relids))
break;
@@ -74,18 +75,21 @@ prune_joinrel(Rel *rel, List *other_rels)
/* we now know cur doesn't match, or is NIL */
return_list = cur;
-
- /* remove relations that do match, we use lnext so we can remove easily */
+
+ /*
+ * remove relations that do match, we use lnext so we can remove
+ * easily
+ */
while (cur != NIL && lnext(cur) != NIL)
{
- Rel *other_rel = (Rel *) lfirst(lnext(cur));
+ Rel *other_rel = (Rel *) lfirst(lnext(cur));
if (same(rel->relids, other_rel->relids))
{
rel->pathlist = add_pathlist(rel,
rel->pathlist,
other_rel->pathlist);
- lnext(cur) = lnext(lnext(cur)); /* delete it */
+ lnext(cur) = lnext(lnext(cur)); /* delete it */
}
cur = lnext(cur);
}
@@ -145,7 +149,7 @@ prune_rel_paths(List *rel_list)
* Returns the cheapest path.
*
*/
-Path *
+Path *
prune_rel_path(Rel *rel, Path *unorderedpath)
{
Path *cheapest = set_cheapest(rel, rel->pathlist);
@@ -176,7 +180,7 @@ prune_rel_path(Rel *rel, Path *unorderedpath)
*
* Returns one pruned rel node list
*/
-List *
+List *
merge_joinrels(List *rel_list1, List *rel_list2)
{
List *xrel = NIL;
@@ -202,7 +206,7 @@ merge_joinrels(List *rel_list1, List *rel_list2)
*
* Returns a new list of rel nodes
*/
-List *
+List *
prune_oldrels(List *old_rels)
{
Rel *rel;
@@ -223,7 +227,7 @@ prune_oldrels(List *old_rels)
foreach(xjoininfo, joininfo_list)
{
JInfo *joininfo = (JInfo *) lfirst(xjoininfo);
-
+
if (!joininfo->inactive)
{
temp_list = lcons(rel, temp_list);
@@ -232,5 +236,5 @@ prune_oldrels(List *old_rels)
}
}
}
- return temp_list;
+ return temp_list;
}
diff --git a/src/backend/optimizer/path/xfunc.c b/src/backend/optimizer/path/xfunc.c
index cf23b225103..3b77217481a 100644
--- a/src/backend/optimizer/path/xfunc.c
+++ b/src/backend/optimizer/path/xfunc.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.12 1998/01/13 04:04:07 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.13 1998/02/26 04:32:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -34,7 +34,7 @@
#include "optimizer/internal.h"
#include "optimizer/keys.h"
#include "optimizer/pathnode.h"
-#include "optimizer/tlist.h" /* for get_expr */
+#include "optimizer/tlist.h" /* for get_expr */
#include "optimizer/xfunc.h"
#include "storage/buf_internals.h" /* for NBuffers */
#include "tcop/dest.h"
@@ -532,7 +532,7 @@ xfunc_func_expense(LispValue node, LispValue args)
if (nargs > 0)
argOidVect = proc->proargtypes;
planlist = (List) pg_parse_and_plan(pq_src, argOidVect, nargs,
- &parseTree_list, None);
+ &parseTree_list, None);
if (IsA(node, Func))
set_func_planlist((Func) node, planlist);