diff options
Diffstat (limited to 'src/backend/optimizer/prep')
-rw-r--r-- | src/backend/optimizer/prep/prepjointree.c | 107 | ||||
-rw-r--r-- | src/backend/optimizer/prep/prepqual.c | 18 | ||||
-rw-r--r-- | src/backend/optimizer/prep/preptlist.c | 24 | ||||
-rw-r--r-- | src/backend/optimizer/prep/prepunion.c | 20 |
4 files changed, 86 insertions, 83 deletions
diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c index 6bddf04206f..25617206d4f 100644 --- a/src/backend/optimizer/prep/prepjointree.c +++ b/src/backend/optimizer/prep/prepjointree.c @@ -16,7 +16,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.8 2003/07/25 00:01:08 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.9 2003/08/04 00:43:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,28 +32,28 @@ /* These parameters are set by GUC */ -int from_collapse_limit; -int join_collapse_limit; +int from_collapse_limit; +int join_collapse_limit; typedef struct reduce_outer_joins_state { Relids relids; /* base relids within this subtree */ - bool contains_outer; /* does subtree contain outer join(s)? */ + bool contains_outer; /* does subtree contain outer join(s)? */ List *sub_states; /* List of states for subtree components */ -} reduce_outer_joins_state; +} reduce_outer_joins_state; static bool is_simple_subquery(Query *subquery); static bool has_nullable_targetlist(Query *subquery); static void resolvenew_in_jointree(Node *jtnode, int varno, List *subtlist); static reduce_outer_joins_state *reduce_outer_joins_pass1(Node *jtnode); static void reduce_outer_joins_pass2(Node *jtnode, - reduce_outer_joins_state *state, - Query *parse, - Relids nonnullable_rels); + reduce_outer_joins_state * state, + Query *parse, + Relids nonnullable_rels); static Relids find_nonnullable_rels(Node *node, bool top_level); static void fix_in_clause_relids(List *in_info_list, int varno, - Relids subrelids); + Relids subrelids); static Node *find_jointree_node_for_rel(Node *jtnode, int relid); @@ -84,7 +84,7 @@ pull_up_IN_clauses(Query *parse, Node *node) return NULL; if (IsA(node, SubLink)) { - SubLink *sublink = (SubLink *) node; + SubLink *sublink = (SubLink *) node; Node *subst; /* Is it a convertible IN clause? If not, return it as-is */ @@ -95,12 +95,12 @@ pull_up_IN_clauses(Query *parse, Node *node) } if (and_clause(node)) { - List *newclauses = NIL; - List *oldclauses; + List *newclauses = NIL; + List *oldclauses; foreach(oldclauses, ((BoolExpr *) node)->args) { - Node *oldclause = lfirst(oldclauses); + Node *oldclause = lfirst(oldclauses); newclauses = lappend(newclauses, pull_up_IN_clauses(parse, @@ -172,22 +172,22 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join) */ if (subquery->hasSubLinks) subquery->jointree->quals = pull_up_IN_clauses(subquery, - subquery->jointree->quals); + subquery->jointree->quals); /* - * Now, recursively pull up the subquery's subqueries, so - * that this routine's processing is complete for its jointree - * and rangetable. NB: if the same subquery is referenced - * from multiple jointree items (which can't happen normally, - * but might after rule rewriting), then we will invoke this + * Now, recursively pull up the subquery's subqueries, so that + * this routine's processing is complete for its jointree and + * rangetable. NB: if the same subquery is referenced from + * multiple jointree items (which can't happen normally, but + * might after rule rewriting), then we will invoke this * processing multiple times on that subquery. OK because * nothing will happen after the first time. We do have to be * careful to copy everything we pull up, however, or risk * having chunks of structure multiply linked. * * Note: 'false' is correct here even if we are within an outer - * join in the upper query; the lower query starts with a clean - * slate for outer-join semantics. + * join in the upper query; the lower query starts with a + * clean slate for outer-join semantics. */ subquery->jointree = (FromExpr *) pull_up_subqueries(subquery, (Node *) subquery->jointree, @@ -207,8 +207,8 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join) OffsetVarNodes((Node *) subquery, rtoffset, 0); /* - * Upper-level vars in subquery are now one level closer to their - * parent than before. + * Upper-level vars in subquery are now one level closer to + * their parent than before. */ IncrementVarSublevelsUp((Node *) subquery, -1, 1); @@ -257,13 +257,14 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join) parse->rowMarks = nconc(parse->rowMarks, subquery->rowMarks); /* - * We also have to fix the relid sets of any parent InClauseInfo - * nodes. (This could perhaps be done by ResolveNew, but it - * would clutter that routine's API unreasonably.) + * We also have to fix the relid sets of any parent + * InClauseInfo nodes. (This could perhaps be done by + * ResolveNew, but it would clutter that routine's API + * unreasonably.) */ if (parse->in_info_list) { - Relids subrelids; + Relids subrelids; subrelids = get_relids_in_jointree((Node *) subquery->jointree); fix_in_clause_relids(parse->in_info_list, varno, subrelids); @@ -513,14 +514,14 @@ reduce_outer_joins(Query *parse) reduce_outer_joins_state *state; /* - * To avoid doing strictness checks on more quals than necessary, - * we want to stop descending the jointree as soon as there are no - * outer joins below our current point. This consideration forces - * a two-pass process. The first pass gathers information about which + * To avoid doing strictness checks on more quals than necessary, we + * want to stop descending the jointree as soon as there are no outer + * joins below our current point. This consideration forces a + * two-pass process. The first pass gathers information about which * base rels appear below each side of each join clause, and about - * whether there are outer join(s) below each side of each join clause. - * The second pass examines qual clauses and changes join types as - * it descends the tree. + * whether there are outer join(s) below each side of each join + * clause. The second pass examines qual clauses and changes join + * types as it descends the tree. */ state = reduce_outer_joins_pass1((Node *) parse->jointree); @@ -608,7 +609,7 @@ reduce_outer_joins_pass1(Node *jtnode) */ static void reduce_outer_joins_pass2(Node *jtnode, - reduce_outer_joins_state *state, + reduce_outer_joins_state * state, Query *parse, Relids nonnullable_rels) { @@ -619,9 +620,7 @@ reduce_outer_joins_pass2(Node *jtnode, if (jtnode == NULL) elog(ERROR, "reached empty jointree"); if (IsA(jtnode, RangeTblRef)) - { elog(ERROR, "reached base rel"); - } else if (IsA(jtnode, FromExpr)) { FromExpr *f = (FromExpr *) jtnode; @@ -701,10 +700,11 @@ reduce_outer_joins_pass2(Node *jtnode, /* * If this join is (now) inner, we can add any nonnullability * constraints its quals provide to those we got from above. - * But if it is outer, we can only pass down the local constraints - * into the nullable side, because an outer join never eliminates - * any rows from its non-nullable side. If it's a FULL join then - * it doesn't eliminate anything from either side. + * But if it is outer, we can only pass down the local + * constraints into the nullable side, because an outer join + * never eliminates any rows from its non-nullable side. If + * it's a FULL join then it doesn't eliminate anything from + * either side. */ if (jointype != JOIN_FULL) { @@ -713,7 +713,8 @@ reduce_outer_joins_pass2(Node *jtnode, nonnullable_rels); } else - local_nonnullable = NULL; /* no use in calculating it */ + local_nonnullable = NULL; /* no use in calculating + * it */ if (left_state->contains_outer) { @@ -747,7 +748,7 @@ reduce_outer_joins_pass2(Node *jtnode, * * We don't use expression_tree_walker here because we don't want to * descend through very many kinds of nodes; only the ones we can be sure - * are strict. We can descend through the top level of implicit AND'ing, + * are strict. We can descend through the top level of implicit AND'ing, * but not through any explicit ANDs (or ORs) below that, since those are not * strict constructs. The List case handles the top-level implicit AND list * as well as lists of arguments to strict operators/functions. @@ -785,7 +786,7 @@ find_nonnullable_rels(Node *node, bool top_level) } else if (IsA(node, OpExpr)) { - OpExpr *expr = (OpExpr *) node; + OpExpr *expr = (OpExpr *) node; if (op_strict(expr->opno)) result = find_nonnullable_rels((Node *) expr->args, false); @@ -800,7 +801,7 @@ find_nonnullable_rels(Node *node, bool top_level) } else if (IsA(node, RelabelType)) { - RelabelType *expr = (RelabelType *) node; + RelabelType *expr = (RelabelType *) node; result = find_nonnullable_rels((Node *) expr->arg, top_level); } @@ -817,7 +818,7 @@ find_nonnullable_rels(Node *node, bool top_level) } else if (IsA(node, BooleanTest)) { - BooleanTest *expr = (BooleanTest *) node; + BooleanTest *expr = (BooleanTest *) node; /* * Appropriate boolean tests are strict at top level. @@ -894,10 +895,11 @@ simplify_jointree(Query *parse, Node *jtnode) (childlen + myothers) <= from_collapse_limit) { newlist = nconc(newlist, subf->fromlist); + /* - * By now, the quals have been converted to implicit-AND - * lists, so we just need to join the lists. NOTE: we - * put the pulled-up quals first. + * By now, the quals have been converted to + * implicit-AND lists, so we just need to join the + * lists. NOTE: we put the pulled-up quals first. */ f->quals = (Node *) nconc((List *) subf->quals, (List *) f->quals); @@ -917,16 +919,17 @@ simplify_jointree(Query *parse, Node *jtnode) /* Recursively simplify the children... */ j->larg = simplify_jointree(parse, j->larg); j->rarg = simplify_jointree(parse, j->rarg); + /* - * If it is an outer join, we must not flatten it. An inner join + * If it is an outer join, we must not flatten it. An inner join * is semantically equivalent to a FromExpr; we convert it to one, * allowing it to be flattened into its parent, if the resulting * FromExpr would have no more than join_collapse_limit members. */ if (j->jointype == JOIN_INNER && join_collapse_limit > 1) { - int leftlen, - rightlen; + int leftlen, + rightlen; if (j->larg && IsA(j->larg, FromExpr)) leftlen = length(((FromExpr *) j->larg)->fromlist); diff --git a/src/backend/optimizer/prep/prepqual.c b/src/backend/optimizer/prep/prepqual.c index 24ea1316e11..cbe822448e4 100644 --- a/src/backend/optimizer/prep/prepqual.c +++ b/src/backend/optimizer/prep/prepqual.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepqual.c,v 1.35 2003/05/28 22:32:49 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepqual.c,v 1.36 2003/08/04 00:43:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,12 +21,12 @@ #include "utils/lsyscache.h" static Expr *flatten_andors(Expr *qual); -static void flatten_andors_and_walker(FastList *out_list, List *andlist); -static void flatten_andors_or_walker(FastList *out_list, List *orlist); +static void flatten_andors_and_walker(FastList * out_list, List *andlist); +static void flatten_andors_or_walker(FastList * out_list, List *orlist); static List *pull_ands(List *andlist); -static void pull_ands_walker(FastList *out_list, List *andlist); +static void pull_ands_walker(FastList * out_list, List *andlist); static List *pull_ors(List *orlist); -static void pull_ors_walker(FastList *out_list, List *orlist); +static void pull_ors_walker(FastList * out_list, List *orlist); static Expr *find_nots(Expr *qual); static Expr *push_nots(Expr *qual); static Expr *find_ors(Expr *qual); @@ -328,7 +328,7 @@ flatten_andors(Expr *qual) } static void -flatten_andors_and_walker(FastList *out_list, List *andlist) +flatten_andors_and_walker(FastList * out_list, List *andlist) { List *arg; @@ -344,7 +344,7 @@ flatten_andors_and_walker(FastList *out_list, List *andlist) } static void -flatten_andors_or_walker(FastList *out_list, List *orlist) +flatten_andors_or_walker(FastList * out_list, List *orlist) { List *arg; @@ -377,7 +377,7 @@ pull_ands(List *andlist) } static void -pull_ands_walker(FastList *out_list, List *andlist) +pull_ands_walker(FastList * out_list, List *andlist) { List *arg; @@ -410,7 +410,7 @@ pull_ors(List *orlist) } static void -pull_ors_walker(FastList *out_list, List *orlist) +pull_ors_walker(FastList * out_list, List *orlist) { List *arg; diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c index 9c937f17602..d33ff7417d4 100644 --- a/src/backend/optimizer/prep/preptlist.c +++ b/src/backend/optimizer/prep/preptlist.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.62 2003/07/25 00:01:08 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.63 2003/08/04 00:43:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -174,12 +174,12 @@ expand_targetlist(List *tlist, int command_type, * * When generating a NULL constant for a dropped column, we label * it INT4 (any other guaranteed-to-exist datatype would do as - * well). We can't label it with the dropped column's datatype - * since that might not exist anymore. It does not really - * matter what we claim the type is, since NULL is NULL --- its - * representation is datatype-independent. This could perhaps - * confuse code comparing the finished plan to the target - * relation, however. + * well). We can't label it with the dropped column's + * datatype since that might not exist anymore. It does not + * really matter what we claim the type is, since NULL is NULL + * --- its representation is datatype-independent. This could + * perhaps confuse code comparing the finished plan to the + * target relation, however. */ Oid atttype = att_tup->atttypid; int32 atttypmod = att_tup->atttypmod; @@ -193,7 +193,7 @@ expand_targetlist(List *tlist, int command_type, new_expr = (Node *) makeConst(atttype, att_tup->attlen, (Datum) 0, - true, /* isnull */ + true, /* isnull */ att_tup->attbyval); new_expr = coerce_to_domain(new_expr, InvalidOid, @@ -206,8 +206,8 @@ expand_targetlist(List *tlist, int command_type, new_expr = (Node *) makeConst(INT4OID, sizeof(int32), (Datum) 0, - true, /* isnull */ - true /* byval */); + true, /* isnull */ + true /* byval */ ); /* label resdom with INT4, too */ atttype = INT4OID; atttypmod = -1; @@ -228,8 +228,8 @@ expand_targetlist(List *tlist, int command_type, new_expr = (Node *) makeConst(INT4OID, sizeof(int32), (Datum) 0, - true, /* isnull */ - true /* byval */); + true, /* isnull */ + true /* byval */ ); /* label resdom with INT4, too */ atttype = INT4OID; atttypmod = -1; diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c index 5422d591728..49ebc822087 100644 --- a/src/backend/optimizer/prep/prepunion.c +++ b/src/backend/optimizer/prep/prepunion.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.101 2003/07/28 00:09:15 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.102 2003/08/04 00:43:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -427,7 +427,7 @@ generate_setop_tlist(List *colTypes, int flag, } else { - expr = coerce_to_common_type(NULL, /* no UNKNOWNs here */ + expr = coerce_to_common_type(NULL, /* no UNKNOWNs here */ expr, colType, "UNION/INTERSECT/EXCEPT"); @@ -849,11 +849,11 @@ adjust_inherited_attrs_mutator(Node *node, if (IsA(node, InClauseInfo)) { /* Copy the InClauseInfo node with correct mutation of subnodes */ - InClauseInfo *ininfo; + InClauseInfo *ininfo; ininfo = (InClauseInfo *) expression_tree_mutator(node, adjust_inherited_attrs_mutator, - (void *) context); + (void *) context); /* now fix InClauseInfo's relid sets */ ininfo->lefthand = adjust_relid_set(ininfo->lefthand, context->old_rt_index, @@ -880,9 +880,9 @@ adjust_inherited_attrs_mutator(Node *node, adjust_inherited_attrs_mutator((Node *) oldinfo->clause, context); /* - * We do NOT want to copy the original subclauseindices list, since - * the new rel will have different indices. The list will be rebuilt - * when needed during later planning. + * We do NOT want to copy the original subclauseindices list, + * since the new rel will have different indices. The list will + * be rebuilt when needed during later planning. */ newinfo->subclauseindices = NIL; @@ -896,7 +896,7 @@ adjust_inherited_attrs_mutator(Node *node, context->old_rt_index, context->new_rt_index); - newinfo->eval_cost.startup = -1; /* reset these too */ + newinfo->eval_cost.startup = -1; /* reset these too */ newinfo->this_selec = -1; newinfo->left_pathkey = NIL; /* and these */ newinfo->right_pathkey = NIL; @@ -925,7 +925,7 @@ adjust_inherited_attrs_mutator(Node *node, */ if (is_subplan(node)) { - SubPlan *subplan; + SubPlan *subplan; /* Copy the node and process subplan args */ node = expression_tree_mutator(node, adjust_inherited_attrs_mutator, @@ -963,7 +963,7 @@ adjust_relid_set(Relids relids, Index oldrelid, Index newrelid) * * The expressions have already been fixed, but we have to make sure that * the target resnos match the child table (they may not, in the case of - * a column that was added after-the-fact by ALTER TABLE). In some cases + * a column that was added after-the-fact by ALTER TABLE). In some cases * this can force us to re-order the tlist to preserve resno ordering. * (We do all this work in special cases so that preptlist.c is fast for * the typical case.) |