X-Git-Url: https://granicus.if.org/sourcecode?a=blobdiff_plain;f=src%2Fbackend%2Foptimizer%2Futil%2Fplaceholder.c;h=b24478ec6f2c2685e104e5c999d5468469c0b37b;hb=a1b8c41e990ec0f083e9b684700a07640d5a356a;hp=4af06ab73e5a43af0d91e6b979b82c68a86029cc;hpb=19a541143a09c067ec8cac77ec6a64eb5b1b662b;p=postgresql diff --git a/src/backend/optimizer/util/placeholder.c b/src/backend/optimizer/util/placeholder.c index 4af06ab73e..b24478ec6f 100644 --- a/src/backend/optimizer/util/placeholder.c +++ b/src/backend/optimizer/util/placeholder.c @@ -4,7 +4,7 @@ * PlaceHolderVar and PlaceHolderInfo manipulation routines * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * @@ -62,7 +62,7 @@ make_placeholder_expr(PlannerInfo *root, Expr *expr, Relids phrels) * simplified query passed to query_planner(). * * Note: this should only be called after query_planner() has started. Also, - * create_new_ph must not be TRUE after deconstruct_jointree begins, because + * create_new_ph must not be true after deconstruct_jointree begins, because * make_outerjoininfo assumes that we already know about all placeholders. */ PlaceHolderInfo * @@ -101,7 +101,7 @@ find_placeholder_info(PlannerInfo *root, PlaceHolderVar *phv, rels_used = pull_varnos((Node *) phv->phexpr); phinfo->ph_lateral = bms_difference(rels_used, phv->phrels); if (bms_is_empty(phinfo->ph_lateral)) - phinfo->ph_lateral = NULL; /* make it exactly NULL if empty */ + phinfo->ph_lateral = NULL; /* make it exactly NULL if empty */ phinfo->ph_eval_at = bms_int_members(rels_used, phv->phrels); /* If no contained vars, force evaluation at syntactic location */ if (bms_is_empty(phinfo->ph_eval_at)) @@ -220,7 +220,8 @@ find_placeholders_in_expr(PlannerInfo *root, Node *expr) * convenient to use. */ vars = pull_var_clause(expr, - PVC_RECURSE_AGGREGATES, + PVC_RECURSE_AGGREGATES | + PVC_RECURSE_WINDOWFUNCS | PVC_INCLUDE_PLACEHOLDERS); foreach(vl, vars) { @@ -354,7 +355,8 @@ fix_placeholder_input_needed_levels(PlannerInfo *root) { PlaceHolderInfo *phinfo = (PlaceHolderInfo *) lfirst(lc); List *vars = pull_var_clause((Node *) phinfo->ph_var->phexpr, - PVC_RECURSE_AGGREGATES, + PVC_RECURSE_AGGREGATES | + PVC_RECURSE_WINDOWFUNCS | PVC_INCLUDE_PLACEHOLDERS); add_vars_to_targetlist(root, vars, phinfo->ph_eval_at, false); @@ -389,8 +391,8 @@ add_placeholders_to_base_rels(PlannerInfo *root) { RelOptInfo *rel = find_base_rel(root, varno); - rel->reltarget.exprs = lappend(rel->reltarget.exprs, - copyObject(phinfo->ph_var)); + rel->reltarget->exprs = lappend(rel->reltarget->exprs, + copyObject(phinfo->ph_var)); /* reltarget's cost and width fields will be updated later */ } } @@ -423,9 +425,9 @@ add_placeholders_to_joinrel(PlannerInfo *root, RelOptInfo *joinrel, if (bms_is_subset(phinfo->ph_eval_at, relids)) { /* Yup, add it to the output */ - joinrel->reltarget.exprs = lappend(joinrel->reltarget.exprs, - phinfo->ph_var); - joinrel->reltarget.width += phinfo->ph_width; + joinrel->reltarget->exprs = lappend(joinrel->reltarget->exprs, + phinfo->ph_var); + joinrel->reltarget->width += phinfo->ph_width; /* * Charge the cost of evaluating the contained expression if @@ -445,8 +447,8 @@ add_placeholders_to_joinrel(PlannerInfo *root, RelOptInfo *joinrel, cost_qual_eval_node(&cost, (Node *) phinfo->ph_var->phexpr, root); - joinrel->reltarget.cost.startup += cost.startup; - joinrel->reltarget.cost.per_tuple += cost.per_tuple; + joinrel->reltarget->cost.startup += cost.startup; + joinrel->reltarget->cost.per_tuple += cost.per_tuple; } /* Adjust joinrel's direct_lateral_relids as needed */