diff options
Diffstat (limited to 'src/backend/optimizer/prep')
-rw-r--r-- | src/backend/optimizer/prep/prepjointree.c | 38 | ||||
-rw-r--r-- | src/backend/optimizer/prep/prepqual.c | 65 | ||||
-rw-r--r-- | src/backend/optimizer/prep/prepunion.c | 25 |
3 files changed, 67 insertions, 61 deletions
diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c index 32853f78bc2..af53c4592cc 100644 --- a/src/backend/optimizer/prep/prepjointree.c +++ b/src/backend/optimizer/prep/prepjointree.c @@ -16,7 +16,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.22 2004/08/29 04:12:34 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.23 2004/08/29 05:06:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,7 +46,7 @@ typedef struct 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 *rtable, List *subtlist); + List *rtable, 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, @@ -151,8 +151,8 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join) * entries for upper Var references would do the wrong thing (the * results wouldn't become NULL when they're supposed to). * - * XXX This could be improved by generating pseudo-variables for - * such expressions; we'd have to figure out how to get the pseudo- + * XXX This could be improved by generating pseudo-variables for such + * expressions; we'd have to figure out how to get the pseudo- * variables evaluated at the right place in the modified plan * tree. Fix it someday. */ @@ -167,23 +167,23 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join) /* * Need a modifiable copy of the subquery to hack on. Even if * we didn't sometimes choose not to pull up below, we must do - * this to avoid problems if the same subquery is referenced from - * multiple jointree items (which can't happen normally, but might - * after rule rewriting). + * this to avoid problems if the same subquery is referenced + * from multiple jointree items (which can't happen normally, + * but might after rule rewriting). */ subquery = copyObject(subquery); /* - * Pull up any IN clauses within the subquery's WHERE, - * so that we don't leave unoptimized INs behind. + * Pull up any IN clauses within the subquery's WHERE, so that + * we don't leave unoptimized INs behind. */ if (subquery->hasSubLinks) subquery->jointree->quals = pull_up_IN_clauses(subquery, subquery->jointree->quals); /* - * Recursively pull up the subquery's subqueries, so that - * this routine's processing is complete for its jointree and + * Recursively pull up the subquery's subqueries, so that this + * routine's processing is complete for its jointree and * rangetable. * * Note: 'false' is correct here even if we are within an outer @@ -213,9 +213,9 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join) * Give up, return unmodified RangeTblRef. * * Note: The work we just did will be redone when the - * subquery gets planned on its own. Perhaps we could avoid - * that by storing the modified subquery back into the - * rangetable, but I'm not gonna risk it now. + * subquery gets planned on its own. Perhaps we could + * avoid that by storing the modified subquery back into + * the rangetable, but I'm not gonna risk it now. */ return jtnode; } @@ -277,8 +277,8 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join) /* * Pull up any FOR UPDATE markers, too. (OffsetVarNodes - * already adjusted the marker values, so just list_concat - * the list.) + * already adjusted the marker values, so just list_concat the + * list.) */ parse->rowMarks = list_concat(parse->rowMarks, subquery->rowMarks); @@ -939,7 +939,7 @@ simplify_jointree(Query *parse, Node *jtnode) * lists. NOTE: we put the pulled-up quals first. */ f->quals = (Node *) list_concat((List *) subf->quals, - (List *) f->quals); + (List *) f->quals); } else newlist = lappend(newlist, child); @@ -1000,14 +1000,14 @@ simplify_jointree(Query *parse, Node *jtnode) f->fromlist = list_concat(f->fromlist, subf->fromlist); f->quals = (Node *) list_concat((List *) f->quals, - (List *) subf->quals); + (List *) subf->quals); } else f->fromlist = lappend(f->fromlist, j->rarg); /* pulled-up quals first */ f->quals = (Node *) list_concat((List *) f->quals, - (List *) j->quals); + (List *) j->quals); return (Node *) f; } diff --git a/src/backend/optimizer/prep/prepqual.c b/src/backend/optimizer/prep/prepqual.c index d0693770834..9a04477006e 100644 --- a/src/backend/optimizer/prep/prepqual.c +++ b/src/backend/optimizer/prep/prepqual.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepqual.c,v 1.45 2004/08/29 04:12:34 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepqual.c,v 1.46 2004/08/29 05:06:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -58,8 +58,8 @@ canonicalize_qual(Expr *qual) /* * Push down NOTs. We do this only in the top-level boolean - * expression, without examining arguments of operators/functions. - * The main reason for doing this is to expose as much top-level AND/OR + * expression, without examining arguments of operators/functions. The + * main reason for doing this is to expose as much top-level AND/OR * structure as we can, so there's no point in descending further. */ newqual = find_nots(newqual); @@ -129,7 +129,8 @@ flatten_andors_mutator(Node *node, void *context) * Note: we can destructively concat the subexpression's * arglist because we know the recursive invocation of * flatten_andors will have built a new arglist not shared - * with any other expr. Otherwise we'd need a list_copy here. + * with any other expr. Otherwise we'd need a list_copy + * here. */ if (and_clause(subexpr)) out_list = list_concat(out_list, @@ -152,7 +153,8 @@ flatten_andors_mutator(Node *node, void *context) * Note: we can destructively concat the subexpression's * arglist because we know the recursive invocation of * flatten_andors will have built a new arglist not shared - * with any other expr. Otherwise we'd need a list_copy here. + * with any other expr. Otherwise we'd need a list_copy + * here. */ if (or_clause(subexpr)) out_list = list_concat(out_list, @@ -192,7 +194,7 @@ pull_ands(List *andlist) */ if (and_clause(subexpr)) out_list = list_concat(out_list, - pull_ands(((BoolExpr *) subexpr)->args)); + pull_ands(((BoolExpr *) subexpr)->args)); else out_list = lappend(out_list, subexpr); } @@ -224,7 +226,7 @@ pull_ors(List *orlist) */ if (or_clause(subexpr)) out_list = list_concat(out_list, - pull_ors(((BoolExpr *) subexpr)->args)); + pull_ors(((BoolExpr *) subexpr)->args)); else out_list = lappend(out_list, subexpr); } @@ -236,7 +238,7 @@ pull_ors(List *orlist) * find_nots * Traverse the qualification, looking for NOTs to take care of. * For NOT clauses, apply push_nots() to try to push down the NOT. - * For AND and OR clause types, simply recurse. Otherwise stop + * For AND and OR clause types, simply recurse. Otherwise stop * recursing (we do not worry about structure below the top AND/OR tree). * * Returns the modified qualification. AND/OR flatness is preserved. @@ -287,8 +289,8 @@ push_nots(Expr *qual) /* * Negate an operator clause if possible: (NOT (< A B)) => (> A B) - * Otherwise, retain the clause as it is (the NOT can't be pushed - * down any farther). + * Otherwise, retain the clause as it is (the NOT can't be pushed down + * any farther). */ if (is_opclause(qual)) { @@ -332,16 +334,16 @@ push_nots(Expr *qual) else if (not_clause((Node *) qual)) { /* - * Another NOT cancels this NOT, so eliminate the NOT and - * stop negating this branch. + * Another NOT cancels this NOT, so eliminate the NOT and stop + * negating this branch. */ return get_notclausearg(qual); } else { /* - * We don't know how to negate anything else, place a NOT at - * this level. + * We don't know how to negate anything else, place a NOT at this + * level. */ return make_notclause(qual); } @@ -356,7 +358,7 @@ push_nots(Expr *qual) * * This may seem like a fairly useless activity, but it turns out to be * applicable to many machine-generated queries, and there are also queries - * in some of the TPC benchmarks that need it. This was in fact almost the + * in some of the TPC benchmarks that need it. This was in fact almost the * sole useful side-effect of the old prepqual code that tried to force * the query into canonical AND-of-ORs form: the canonical equivalent of * ((A AND B) OR (A AND C)) @@ -375,7 +377,7 @@ push_nots(Expr *qual) * OR clauses to which the inverse OR distributive law might apply. * Only the top-level AND/OR structure is searched. * - * Returns the modified qualification. AND/OR flatness is preserved. + * Returns the modified qualification. AND/OR flatness is preserved. */ static Expr * find_duplicate_ors(Expr *qual) @@ -391,6 +393,7 @@ find_duplicate_ors(Expr *qual) /* Recurse */ foreach(temp, ((BoolExpr *) qual)->args) orlist = lappend(orlist, find_duplicate_ors(lfirst(temp))); + /* * Don't need pull_ors() since this routine will never introduce * an OR where there wasn't one before. @@ -433,14 +436,15 @@ process_duplicate_ors(List *orlist) if (orlist == NIL) return NULL; /* probably can't happen */ - if (list_length(orlist) == 1) /* single-expression OR (can this happen?) */ + if (list_length(orlist) == 1) /* single-expression OR (can this + * happen?) */ return linitial(orlist); /* * Choose the shortest AND clause as the reference list --- obviously, - * any subclause not in this clause isn't in all the clauses. - * If we find a clause that's not an AND, we can treat it as a - * one-element AND clause, which necessarily wins as shortest. + * any subclause not in this clause isn't in all the clauses. If we + * find a clause that's not an AND, we can treat it as a one-element + * AND clause, which necessarily wins as shortest. */ foreach(temp, orlist) { @@ -471,7 +475,7 @@ process_duplicate_ors(List *orlist) /* * Check each element of the reference list to see if it's in all the - * OR clauses. Build a new list of winning clauses. + * OR clauses. Build a new list of winning clauses. */ winners = NIL; foreach(temp, reference) @@ -515,12 +519,13 @@ process_duplicate_ors(List *orlist) /* * Generate new OR list consisting of the remaining sub-clauses. * - * If any clause degenerates to empty, then we have a situation like - * (A AND B) OR (A), which can be reduced to just A --- that is, the + * If any clause degenerates to empty, then we have a situation like (A + * AND B) OR (A), which can be reduced to just A --- that is, the * additional conditions in other arms of the OR are irrelevant. * * Note that because we use list_difference, any multiple occurrences of - * a winning clause in an AND sub-clause will be removed automatically. + * a winning clause in an AND sub-clause will be removed + * automatically. */ neworlist = NIL; foreach(temp, orlist) @@ -541,7 +546,7 @@ process_duplicate_ors(List *orlist) } else { - neworlist = NIL; /* degenerate case, see above */ + neworlist = NIL; /* degenerate case, see above */ break; } } @@ -551,17 +556,17 @@ process_duplicate_ors(List *orlist) neworlist = lappend(neworlist, clause); else { - neworlist = NIL; /* degenerate case, see above */ + neworlist = NIL; /* degenerate case, see above */ break; } } } /* - * Append reduced OR to the winners list, if it's not degenerate, handling - * the special case of one element correctly (can that really happen?). - * Also be careful to maintain AND/OR flatness in case we pulled up a - * sub-sub-OR-clause. + * Append reduced OR to the winners list, if it's not degenerate, + * handling the special case of one element correctly (can that really + * happen?). Also be careful to maintain AND/OR flatness in case we + * pulled up a sub-sub-OR-clause. */ if (neworlist != NIL) { diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c index 85b4f1f8eb3..12d492f8038 100644 --- a/src/backend/optimizer/prep/prepunion.c +++ b/src/backend/optimizer/prep/prepunion.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.115 2004/08/29 04:12:34 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.116 2004/08/29 05:06:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -69,7 +69,7 @@ static Node *adjust_inherited_attrs_mutator(Node *node, adjust_inherited_attrs_context *context); static Relids adjust_relid_set(Relids relids, Index oldrelid, Index newrelid); static List *adjust_inherited_tlist(List *tlist, - adjust_inherited_attrs_context *context); + adjust_inherited_attrs_context *context); /* @@ -371,7 +371,7 @@ recurse_union_children(Node *setOp, Query *parse, SetOperationStmt *top_union, List *refnames_tlist) { - List *child_sortclauses; + List *child_sortclauses; if (IsA(setOp, SetOperationStmt)) { @@ -754,7 +754,7 @@ expand_inherited_rtentry(Query *parse, Index rti, bool dup_parent) if (dup_parent) inhRTIs = NIL; else - inhRTIs = list_make1_int(rti); /* include original RTE in result */ + inhRTIs = list_make1_int(rti); /* include original RTE in result */ foreach(l, inhOIDs) { @@ -811,8 +811,9 @@ adjust_inherited_attrs(Node *node, } /* - * We assume that by now the planner has acquired at least AccessShareLock - * on both rels, and so we need no additional lock now. + * We assume that by now the planner has acquired at least + * AccessShareLock on both rels, and so we need no additional lock + * now. */ oldrelation = heap_open(old_relid, NoLock); newrelation = heap_open(new_relid, NoLock); @@ -913,21 +914,21 @@ static Node * generate_whole_row(Var *var, adjust_inherited_attrs_context *context) { - RowExpr *rowexpr; - List *fields = NIL; + RowExpr *rowexpr; + List *fields = NIL; int oldnatts = context->old_tupdesc->natts; int i; for (i = 0; i < oldnatts; i++) { Form_pg_attribute att = context->old_tupdesc->attrs[i]; - Var *newvar; + Var *newvar; if (att->attisdropped) { /* - * can't use atttypid here, but it doesn't really matter - * what type the Const claims to be. + * can't use atttypid here, but it doesn't really matter what + * type the Const claims to be. */ newvar = (Var *) makeNullConst(INT4OID); } @@ -941,7 +942,7 @@ generate_whole_row(Var *var, } rowexpr = makeNode(RowExpr); rowexpr->args = fields; - rowexpr->row_typeid = var->vartype; /* report parent's rowtype */ + rowexpr->row_typeid = var->vartype; /* report parent's rowtype */ rowexpr->row_format = COERCE_IMPLICIT_CAST; return (Node *) rowexpr; |