diff options
Diffstat (limited to 'src/backend/optimizer/prep')
-rw-r--r-- | src/backend/optimizer/prep/prepqual.c | 101 | ||||
-rw-r--r-- | src/backend/optimizer/prep/preptlist.c | 6 | ||||
-rw-r--r-- | src/backend/optimizer/prep/prepunion.c | 16 |
3 files changed, 58 insertions, 65 deletions
diff --git a/src/backend/optimizer/prep/prepqual.c b/src/backend/optimizer/prep/prepqual.c index bb00555f69d..4016ba476de 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.33 2002/09/02 02:47:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepqual.c,v 1.34 2002/12/12 15:49:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -294,7 +294,7 @@ flatten_andors(Expr *qual) List *out_list = NIL; List *arg; - foreach(arg, qual->args) + foreach(arg, ((BoolExpr *) qual)->args) { Expr *subexpr = flatten_andors((Expr *) lfirst(arg)); @@ -305,7 +305,7 @@ flatten_andors(Expr *qual) * with any other expr. Otherwise we'd need a listCopy here. */ if (and_clause((Node *) subexpr)) - out_list = nconc(out_list, subexpr->args); + out_list = nconc(out_list, ((BoolExpr *) subexpr)->args); else out_list = lappend(out_list, subexpr); } @@ -316,7 +316,7 @@ flatten_andors(Expr *qual) List *out_list = NIL; List *arg; - foreach(arg, qual->args) + foreach(arg, ((BoolExpr *) qual)->args) { Expr *subexpr = flatten_andors((Expr *) lfirst(arg)); @@ -327,7 +327,7 @@ flatten_andors(Expr *qual) * with any other expr. Otherwise we'd need a listCopy here. */ if (or_clause((Node *) subexpr)) - out_list = nconc(out_list, subexpr->args); + out_list = nconc(out_list, ((BoolExpr *) subexpr)->args); else out_list = lappend(out_list, subexpr); } @@ -335,20 +335,17 @@ flatten_andors(Expr *qual) } else if (not_clause((Node *) qual)) return make_notclause(flatten_andors(get_notclausearg(qual))); - else if (is_opclause((Node *) qual)) + else if (is_opclause(qual)) { + OpExpr *opexpr = (OpExpr *) qual; Expr *left = (Expr *) get_leftop(qual); Expr *right = (Expr *) get_rightop(qual); - if (right) - return make_clause(qual->opType, qual->oper, - lcons(flatten_andors(left), - lcons(flatten_andors(right), - NIL))); - else - return make_clause(qual->opType, qual->oper, - lcons(flatten_andors(left), - NIL)); + return make_opclause(opexpr->opno, + opexpr->opresulttype, + opexpr->opretset, + flatten_andors(left), + flatten_andors(right)); } else return qual; @@ -379,7 +376,8 @@ pull_ors(List *orlist) * we'd need a listCopy here. */ if (or_clause((Node *) subexpr)) - out_list = nconc(out_list, pull_ors(subexpr->args)); + out_list = nconc(out_list, + pull_ors(((BoolExpr *) subexpr)->args)); else out_list = lappend(out_list, subexpr); } @@ -410,7 +408,8 @@ pull_ands(List *andlist) * we'd need a listCopy here. */ if (and_clause((Node *) subexpr)) - out_list = nconc(out_list, pull_ands(subexpr->args)); + out_list = nconc(out_list, + pull_ands(((BoolExpr *) subexpr)->args)); else out_list = lappend(out_list, subexpr); } @@ -433,20 +432,17 @@ find_nots(Expr *qual) #ifdef NOT_USED /* recursing into operator expressions is probably not worth it. */ - if (is_opclause((Node *) qual)) + if (is_opclause(qual)) { + OpExpr *opexpr = (OpExpr *) qual; Expr *left = (Expr *) get_leftop(qual); Expr *right = (Expr *) get_rightop(qual); - if (right) - return make_clause(qual->opType, qual->oper, - lcons(find_nots(left), - lcons(find_nots(right), - NIL))); - else - return make_clause(qual->opType, qual->oper, - lcons(find_nots(left), - NIL)); + return make_opclause(opexpr->opno, + opexpr->opresulttype, + opexpr->opretset, + find_nots(left), + find_nots(right)); } #endif if (and_clause((Node *) qual)) @@ -454,7 +450,7 @@ find_nots(Expr *qual) List *t_list = NIL; List *temp; - foreach(temp, qual->args) + foreach(temp, ((BoolExpr *) qual)->args) t_list = lappend(t_list, find_nots(lfirst(temp))); return make_andclause(pull_ands(t_list)); } @@ -463,7 +459,7 @@ find_nots(Expr *qual) List *t_list = NIL; List *temp; - foreach(temp, qual->args) + foreach(temp, ((BoolExpr *) qual)->args) t_list = lappend(t_list, find_nots(lfirst(temp))); return make_orclause(pull_ors(t_list)); } @@ -492,20 +488,17 @@ push_nots(Expr *qual) * Otherwise, retain the clause as it is (the 'not' can't be pushed * down any farther). */ - if (is_opclause((Node *) qual)) + if (is_opclause(qual)) { - Oper *oper = (Oper *) ((Expr *) qual)->oper; - Oid negator = get_negator(oper->opno); + OpExpr *opexpr = (OpExpr *) qual; + Oid negator = get_negator(opexpr->opno); if (negator) - { - Oper *op = (Oper *) makeOper(negator, - InvalidOid, - oper->opresulttype, - oper->opretset); - - return make_opclause(op, get_leftop(qual), get_rightop(qual)); - } + return make_opclause(negator, + opexpr->opresulttype, + opexpr->opretset, + (Expr *) get_leftop(qual), + (Expr *) get_rightop(qual)); else return make_notclause(qual); } @@ -521,7 +514,7 @@ push_nots(Expr *qual) List *t_list = NIL; List *temp; - foreach(temp, qual->args) + foreach(temp, ((BoolExpr *) qual)->args) t_list = lappend(t_list, push_nots(lfirst(temp))); return make_orclause(pull_ors(t_list)); } @@ -530,7 +523,7 @@ push_nots(Expr *qual) List *t_list = NIL; List *temp; - foreach(temp, qual->args) + foreach(temp, ((BoolExpr *) qual)->args) t_list = lappend(t_list, push_nots(lfirst(temp))); return make_andclause(pull_ands(t_list)); } @@ -576,7 +569,7 @@ find_ors(Expr *qual) List *andlist = NIL; List *temp; - foreach(temp, qual->args) + foreach(temp, ((BoolExpr *) qual)->args) andlist = lappend(andlist, find_ors(lfirst(temp))); return make_andclause(pull_ands(andlist)); } @@ -585,7 +578,7 @@ find_ors(Expr *qual) List *orlist = NIL; List *temp; - foreach(temp, qual->args) + foreach(temp, ((BoolExpr *) qual)->args) orlist = lappend(orlist, find_ors(lfirst(temp))); return or_normalize(pull_ors(orlist)); } @@ -629,7 +622,7 @@ or_normalize(List *orlist) if (and_clause((Node *) clause)) { - int nclauses = length(clause->args); + int nclauses = length(((BoolExpr *) clause)->args); if (nclauses > num_subclauses) { @@ -650,7 +643,7 @@ or_normalize(List *orlist) */ orlist = lremove(distributable, orlist); - foreach(temp, distributable->args) + foreach(temp, ((BoolExpr *) distributable)->args) { Expr *andclause = lfirst(temp); List *neworlist; @@ -703,7 +696,7 @@ find_ands(Expr *qual) List *orlist = NIL; List *temp; - foreach(temp, qual->args) + foreach(temp, ((BoolExpr *) qual)->args) orlist = lappend(orlist, find_ands(lfirst(temp))); return make_orclause(pull_ors(orlist)); } @@ -712,7 +705,7 @@ find_ands(Expr *qual) List *andlist = NIL; List *temp; - foreach(temp, qual->args) + foreach(temp, ((BoolExpr *) qual)->args) andlist = lappend(andlist, find_ands(lfirst(temp))); return and_normalize(pull_ands(andlist)); } @@ -757,7 +750,7 @@ and_normalize(List *andlist) if (or_clause((Node *) clause)) { - int nclauses = length(clause->args); + int nclauses = length(((BoolExpr *) clause)->args); if (nclauses > num_subclauses) { @@ -778,7 +771,7 @@ and_normalize(List *andlist) */ andlist = lremove(distributable, andlist); - foreach(temp, distributable->args) + foreach(temp, ((BoolExpr *) distributable)->args) { Expr *orclause = lfirst(temp); List *newandlist; @@ -829,7 +822,7 @@ qual_cleanup(Expr *qual) List *andlist = NIL; List *temp; - foreach(temp, qual->args) + foreach(temp, ((BoolExpr *) qual)->args) andlist = lappend(andlist, qual_cleanup(lfirst(temp))); andlist = remove_duplicates(pull_ands(andlist)); @@ -844,7 +837,7 @@ qual_cleanup(Expr *qual) List *orlist = NIL; List *temp; - foreach(temp, qual->args) + foreach(temp, ((BoolExpr *) qual)->args) orlist = lappend(orlist, qual_cleanup(lfirst(temp))); orlist = remove_duplicates(pull_ors(orlist)); @@ -910,7 +903,7 @@ count_bool_nodes(Expr *qual, *nodes = *cnfnodes = 0.0; *dnfnodes = 1.0; /* DNF nodes will be product of sub-counts */ - foreach(temp, qual->args) + foreach(temp, ((BoolExpr *) qual)->args) { count_bool_nodes(lfirst(temp), &subnodes, &subcnfnodes, &subdnfnodes); @@ -931,7 +924,7 @@ count_bool_nodes(Expr *qual, *nodes = *dnfnodes = 0.0; *cnfnodes = 1.0; /* CNF nodes will be product of sub-counts */ - foreach(temp, qual->args) + foreach(temp, ((BoolExpr *) qual)->args) { count_bool_nodes(lfirst(temp), &subnodes, &subcnfnodes, &subdnfnodes); diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c index 68895143061..87d3c983a70 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.58 2002/11/25 21:29:40 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.59 2002/12/12 15:49:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -96,7 +96,7 @@ preprocess_targetlist(List *tlist, if (command_type == CMD_DELETE) tlist = listCopy(tlist); - tlist = lappend(tlist, makeTargetEntry(resdom, (Node *) var)); + tlist = lappend(tlist, makeTargetEntry(resdom, (Expr *) var)); } return tlist; @@ -215,7 +215,7 @@ expand_targetlist(List *tlist, int command_type, atttypmod, pstrdup(NameStr(att_tup->attname)), false), - new_expr); + (Expr *) new_expr); } new_tlist = lappend(new_tlist, new_tle); diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c index 79063c02806..a55af2e2d06 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.81 2002/11/25 21:29:40 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.82 2002/12/12 15:49:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -406,7 +406,7 @@ generate_setop_tlist(List *colTypes, int flag, * the output tlists of upper-level nodes! */ if (hack_constants && inputtle->expr && IsA(inputtle->expr, Const)) - expr = inputtle->expr; + expr = (Node *) inputtle->expr; else expr = (Node *) makeVar(0, inputtle->resdom->resno, @@ -430,7 +430,7 @@ generate_setop_tlist(List *colTypes, int flag, colTypmod, pstrdup(reftle->resdom->resname), false); - tlist = lappend(tlist, makeTargetEntry(resdom, expr)); + tlist = lappend(tlist, makeTargetEntry(resdom, (Expr *) expr)); input_tlist = lnext(input_tlist); refnames_tlist = lnext(refnames_tlist); } @@ -449,7 +449,7 @@ generate_setop_tlist(List *colTypes, int flag, Int32GetDatum(flag), false, true); - tlist = lappend(tlist, makeTargetEntry(resdom, expr)); + tlist = lappend(tlist, makeTargetEntry(resdom, (Expr *) expr)); } return tlist; @@ -543,7 +543,7 @@ generate_append_tlist(List *colTypes, bool flag, colTypmod, pstrdup(reftle->resdom->resname), false); - tlist = lappend(tlist, makeTargetEntry(resdom, expr)); + tlist = lappend(tlist, makeTargetEntry(resdom, (Expr *) expr)); refnames_tlist = lnext(refnames_tlist); } @@ -561,7 +561,7 @@ generate_append_tlist(List *colTypes, bool flag, INT4OID, -1, 0); - tlist = lappend(tlist, makeTargetEntry(resdom, expr)); + tlist = lappend(tlist, makeTargetEntry(resdom, (Expr *) expr)); } pfree(colTypmods); @@ -872,13 +872,13 @@ adjust_inherited_attrs_mutator(Node *node, */ if (is_subplan(node)) { - SubPlan *subplan; + SubPlanExpr *subplan; /* Copy the node and process subplan args */ node = expression_tree_mutator(node, adjust_inherited_attrs_mutator, (void *) context); /* Make sure we have separate copies of subplan and its rtable */ - subplan = (SubPlan *) ((Expr *) node)->oper; + subplan = (SubPlanExpr *) node; subplan->plan = copyObject(subplan->plan); subplan->rtable = copyObject(subplan->rtable); return node; |