PostgreSQL Source Code  git master
paramassign.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * paramassign.c
4  * Functions for assigning PARAM_EXEC slots during planning.
5  *
6  * This module is responsible for managing three planner data structures:
7  *
8  * root->glob->paramExecTypes: records actual assignments of PARAM_EXEC slots.
9  * The i'th list element holds the data type OID of the i'th parameter slot.
10  * (Elements can be InvalidOid if they represent slots that are needed for
11  * chgParam signaling, but will never hold a value at runtime.) This list is
12  * global to the whole plan since the executor has only one PARAM_EXEC array.
13  * Assignments are permanent for the plan: we never remove entries once added.
14  *
15  * root->plan_params: a list of PlannerParamItem nodes, recording Vars and
16  * PlaceHolderVars that the root's query level needs to supply to lower-level
17  * subqueries, along with the PARAM_EXEC number to use for each such value.
18  * Elements are added to this list while planning a subquery, and the list
19  * is reset to empty after completion of each subquery.
20  *
21  * root->curOuterParams: a list of NestLoopParam nodes, recording Vars and
22  * PlaceHolderVars that some outer level of nestloop needs to pass down to
23  * a lower-level plan node in its righthand side. Elements are added to this
24  * list as createplan.c creates lower Plan nodes that need such Params, and
25  * are removed when it creates a NestLoop Plan node that will supply those
26  * values.
27  *
28  * The latter two data structures are used to prevent creating multiple
29  * PARAM_EXEC slots (each requiring work to fill) when the same upper
30  * SubPlan or NestLoop supplies a value that is referenced in more than
31  * one place in its child plan nodes. However, when the same Var has to
32  * be supplied to different subplan trees by different SubPlan or NestLoop
33  * parent nodes, we don't recognize any commonality; a fresh plan_params or
34  * curOuterParams entry will be made (since the old one has been removed
35  * when we finished processing the earlier SubPlan or NestLoop) and a fresh
36  * PARAM_EXEC number will be assigned. At one time we tried to avoid
37  * allocating duplicate PARAM_EXEC numbers in such cases, but it's harder
38  * than it seems to avoid bugs due to overlapping Param lifetimes, so we
39  * don't risk that anymore. Minimizing the number of PARAM_EXEC slots
40  * doesn't really save much executor work anyway.
41  *
42  *
43  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
44  * Portions Copyright (c) 1994, Regents of the University of California
45  *
46  * IDENTIFICATION
47  * src/backend/optimizer/util/paramassign.c
48  *
49  *-------------------------------------------------------------------------
50  */
51 #include "postgres.h"
52 
53 #include "nodes/nodeFuncs.h"
54 #include "nodes/plannodes.h"
55 #include "optimizer/paramassign.h"
56 #include "optimizer/placeholder.h"
57 #include "rewrite/rewriteManip.h"
58 
59 
60 /*
61  * Select a PARAM_EXEC number to identify the given Var as a parameter for
62  * the current subquery. (It might already have one.)
63  * Record the need for the Var in the proper upper-level root->plan_params.
64  */
65 static int
67 {
68  ListCell *ppl;
69  PlannerParamItem *pitem;
70  Index levelsup;
71 
72  /* Find the query level the Var belongs to */
73  for (levelsup = var->varlevelsup; levelsup > 0; levelsup--)
74  root = root->parent_root;
75 
76  /* If there's already a matching PlannerParamItem there, just use it */
77  foreach(ppl, root->plan_params)
78  {
79  pitem = (PlannerParamItem *) lfirst(ppl);
80  if (IsA(pitem->item, Var))
81  {
82  Var *pvar = (Var *) pitem->item;
83 
84  /*
85  * This comparison must match _equalVar(), except for ignoring
86  * varlevelsup. Note that _equalVar() ignores varnosyn,
87  * varattnosyn, and location, so this does too.
88  */
89  if (pvar->varno == var->varno &&
90  pvar->varattno == var->varattno &&
91  pvar->vartype == var->vartype &&
92  pvar->vartypmod == var->vartypmod &&
93  pvar->varcollid == var->varcollid &&
94  bms_equal(pvar->varnullingrels, var->varnullingrels))
95  return pitem->paramId;
96  }
97  }
98 
99  /* Nope, so make a new one */
100  var = copyObject(var);
101  var->varlevelsup = 0;
102 
103  pitem = makeNode(PlannerParamItem);
104  pitem->item = (Node *) var;
105  pitem->paramId = list_length(root->glob->paramExecTypes);
106  root->glob->paramExecTypes = lappend_oid(root->glob->paramExecTypes,
107  var->vartype);
108 
109  root->plan_params = lappend(root->plan_params, pitem);
110 
111  return pitem->paramId;
112 }
113 
114 /*
115  * Generate a Param node to replace the given Var,
116  * which is expected to have varlevelsup > 0 (ie, it is not local).
117  * Record the need for the Var in the proper upper-level root->plan_params.
118  */
119 Param *
121 {
122  Param *retval;
123  int i;
124 
125  Assert(var->varlevelsup > 0 && var->varlevelsup < root->query_level);
126 
127  /* Find the Var in the appropriate plan_params, or add it if not present */
128  i = assign_param_for_var(root, var);
129 
130  retval = makeNode(Param);
131  retval->paramkind = PARAM_EXEC;
132  retval->paramid = i;
133  retval->paramtype = var->vartype;
134  retval->paramtypmod = var->vartypmod;
135  retval->paramcollid = var->varcollid;
136  retval->location = var->location;
137 
138  return retval;
139 }
140 
141 /*
142  * Select a PARAM_EXEC number to identify the given PlaceHolderVar as a
143  * parameter for the current subquery. (It might already have one.)
144  * Record the need for the PHV in the proper upper-level root->plan_params.
145  *
146  * This is just like assign_param_for_var, except for PlaceHolderVars.
147  */
148 static int
150 {
151  ListCell *ppl;
152  PlannerParamItem *pitem;
153  Index levelsup;
154 
155  /* Find the query level the PHV belongs to */
156  for (levelsup = phv->phlevelsup; levelsup > 0; levelsup--)
157  root = root->parent_root;
158 
159  /* If there's already a matching PlannerParamItem there, just use it */
160  foreach(ppl, root->plan_params)
161  {
162  pitem = (PlannerParamItem *) lfirst(ppl);
163  if (IsA(pitem->item, PlaceHolderVar))
164  {
165  PlaceHolderVar *pphv = (PlaceHolderVar *) pitem->item;
166 
167  /* We assume comparing the PHIDs is sufficient */
168  if (pphv->phid == phv->phid)
169  return pitem->paramId;
170  }
171  }
172 
173  /* Nope, so make a new one */
174  phv = copyObject(phv);
175  IncrementVarSublevelsUp((Node *) phv, -((int) phv->phlevelsup), 0);
176  Assert(phv->phlevelsup == 0);
177 
178  pitem = makeNode(PlannerParamItem);
179  pitem->item = (Node *) phv;
180  pitem->paramId = list_length(root->glob->paramExecTypes);
181  root->glob->paramExecTypes = lappend_oid(root->glob->paramExecTypes,
182  exprType((Node *) phv->phexpr));
183 
184  root->plan_params = lappend(root->plan_params, pitem);
185 
186  return pitem->paramId;
187 }
188 
189 /*
190  * Generate a Param node to replace the given PlaceHolderVar,
191  * which is expected to have phlevelsup > 0 (ie, it is not local).
192  * Record the need for the PHV in the proper upper-level root->plan_params.
193  *
194  * This is just like replace_outer_var, except for PlaceHolderVars.
195  */
196 Param *
198 {
199  Param *retval;
200  int i;
201 
202  Assert(phv->phlevelsup > 0 && phv->phlevelsup < root->query_level);
203 
204  /* Find the PHV in the appropriate plan_params, or add it if not present */
206 
207  retval = makeNode(Param);
208  retval->paramkind = PARAM_EXEC;
209  retval->paramid = i;
210  retval->paramtype = exprType((Node *) phv->phexpr);
211  retval->paramtypmod = exprTypmod((Node *) phv->phexpr);
212  retval->paramcollid = exprCollation((Node *) phv->phexpr);
213  retval->location = -1;
214 
215  return retval;
216 }
217 
218 /*
219  * Generate a Param node to replace the given Aggref
220  * which is expected to have agglevelsup > 0 (ie, it is not local).
221  * Record the need for the Aggref in the proper upper-level root->plan_params.
222  */
223 Param *
225 {
226  Param *retval;
227  PlannerParamItem *pitem;
228  Index levelsup;
229 
230  Assert(agg->agglevelsup > 0 && agg->agglevelsup < root->query_level);
231 
232  /* Find the query level the Aggref belongs to */
233  for (levelsup = agg->agglevelsup; levelsup > 0; levelsup--)
234  root = root->parent_root;
235 
236  /*
237  * It does not seem worthwhile to try to de-duplicate references to outer
238  * aggs. Just make a new slot every time.
239  */
240  agg = copyObject(agg);
241  IncrementVarSublevelsUp((Node *) agg, -((int) agg->agglevelsup), 0);
242  Assert(agg->agglevelsup == 0);
243 
244  pitem = makeNode(PlannerParamItem);
245  pitem->item = (Node *) agg;
246  pitem->paramId = list_length(root->glob->paramExecTypes);
247  root->glob->paramExecTypes = lappend_oid(root->glob->paramExecTypes,
248  agg->aggtype);
249 
250  root->plan_params = lappend(root->plan_params, pitem);
251 
252  retval = makeNode(Param);
253  retval->paramkind = PARAM_EXEC;
254  retval->paramid = pitem->paramId;
255  retval->paramtype = agg->aggtype;
256  retval->paramtypmod = -1;
257  retval->paramcollid = agg->aggcollid;
258  retval->location = agg->location;
259 
260  return retval;
261 }
262 
263 /*
264  * Generate a Param node to replace the given GroupingFunc expression which is
265  * expected to have agglevelsup > 0 (ie, it is not local).
266  * Record the need for the GroupingFunc in the proper upper-level
267  * root->plan_params.
268  */
269 Param *
271 {
272  Param *retval;
273  PlannerParamItem *pitem;
274  Index levelsup;
275  Oid ptype = exprType((Node *) grp);
276 
277  Assert(grp->agglevelsup > 0 && grp->agglevelsup < root->query_level);
278 
279  /* Find the query level the GroupingFunc belongs to */
280  for (levelsup = grp->agglevelsup; levelsup > 0; levelsup--)
281  root = root->parent_root;
282 
283  /*
284  * It does not seem worthwhile to try to de-duplicate references to outer
285  * aggs. Just make a new slot every time.
286  */
287  grp = copyObject(grp);
288  IncrementVarSublevelsUp((Node *) grp, -((int) grp->agglevelsup), 0);
289  Assert(grp->agglevelsup == 0);
290 
291  pitem = makeNode(PlannerParamItem);
292  pitem->item = (Node *) grp;
293  pitem->paramId = list_length(root->glob->paramExecTypes);
294  root->glob->paramExecTypes = lappend_oid(root->glob->paramExecTypes,
295  ptype);
296 
297  root->plan_params = lappend(root->plan_params, pitem);
298 
299  retval = makeNode(Param);
300  retval->paramkind = PARAM_EXEC;
301  retval->paramid = pitem->paramId;
302  retval->paramtype = ptype;
303  retval->paramtypmod = -1;
304  retval->paramcollid = InvalidOid;
305  retval->location = grp->location;
306 
307  return retval;
308 }
309 
310 /*
311  * Generate a Param node to replace the given MergeSupportFunc expression
312  * which is expected to be in the RETURNING list of an upper-level MERGE
313  * query. Record the need for the MergeSupportFunc in the proper upper-level
314  * root->plan_params.
315  */
316 Param *
318 {
319  Param *retval;
320  PlannerParamItem *pitem;
321  Oid ptype = exprType((Node *) msf);
322 
323  Assert(root->parse->commandType != CMD_MERGE);
324 
325  /*
326  * The parser should have ensured that the MergeSupportFunc is in the
327  * RETURNING list of an upper-level MERGE query, so find that query.
328  */
329  do
330  {
331  root = root->parent_root;
332  if (root == NULL)
333  elog(ERROR, "MergeSupportFunc found outside MERGE");
334  } while (root->parse->commandType != CMD_MERGE);
335 
336  /*
337  * It does not seem worthwhile to try to de-duplicate references to outer
338  * MergeSupportFunc expressions. Just make a new slot every time.
339  */
340  msf = copyObject(msf);
341 
342  pitem = makeNode(PlannerParamItem);
343  pitem->item = (Node *) msf;
344  pitem->paramId = list_length(root->glob->paramExecTypes);
345  root->glob->paramExecTypes = lappend_oid(root->glob->paramExecTypes,
346  ptype);
347 
348  root->plan_params = lappend(root->plan_params, pitem);
349 
350  retval = makeNode(Param);
351  retval->paramkind = PARAM_EXEC;
352  retval->paramid = pitem->paramId;
353  retval->paramtype = ptype;
354  retval->paramtypmod = -1;
355  retval->paramcollid = InvalidOid;
356  retval->location = msf->location;
357 
358  return retval;
359 }
360 
361 /*
362  * Generate a Param node to replace the given Var,
363  * which is expected to come from some upper NestLoop plan node.
364  * Record the need for the Var in root->curOuterParams.
365  */
366 Param *
368 {
369  Param *param;
370  NestLoopParam *nlp;
371  ListCell *lc;
372 
373  /* Is this Var already listed in root->curOuterParams? */
374  foreach(lc, root->curOuterParams)
375  {
376  nlp = (NestLoopParam *) lfirst(lc);
377  if (equal(var, nlp->paramval))
378  {
379  /* Yes, so just make a Param referencing this NLP's slot */
380  param = makeNode(Param);
381  param->paramkind = PARAM_EXEC;
382  param->paramid = nlp->paramno;
383  param->paramtype = var->vartype;
384  param->paramtypmod = var->vartypmod;
385  param->paramcollid = var->varcollid;
386  param->location = var->location;
387  return param;
388  }
389  }
390 
391  /* No, so assign a PARAM_EXEC slot for a new NLP */
393  var->vartype,
394  var->vartypmod,
395  var->varcollid);
396  param->location = var->location;
397 
398  /* Add it to the list of required NLPs */
399  nlp = makeNode(NestLoopParam);
400  nlp->paramno = param->paramid;
401  nlp->paramval = copyObject(var);
402  root->curOuterParams = lappend(root->curOuterParams, nlp);
403 
404  /* And return the replacement Param */
405  return param;
406 }
407 
408 /*
409  * Generate a Param node to replace the given PlaceHolderVar,
410  * which is expected to come from some upper NestLoop plan node.
411  * Record the need for the PHV in root->curOuterParams.
412  *
413  * This is just like replace_nestloop_param_var, except for PlaceHolderVars.
414  */
415 Param *
417 {
418  Param *param;
419  NestLoopParam *nlp;
420  ListCell *lc;
421 
422  /* Is this PHV already listed in root->curOuterParams? */
423  foreach(lc, root->curOuterParams)
424  {
425  nlp = (NestLoopParam *) lfirst(lc);
426  if (equal(phv, nlp->paramval))
427  {
428  /* Yes, so just make a Param referencing this NLP's slot */
429  param = makeNode(Param);
430  param->paramkind = PARAM_EXEC;
431  param->paramid = nlp->paramno;
432  param->paramtype = exprType((Node *) phv->phexpr);
433  param->paramtypmod = exprTypmod((Node *) phv->phexpr);
434  param->paramcollid = exprCollation((Node *) phv->phexpr);
435  param->location = -1;
436  return param;
437  }
438  }
439 
440  /* No, so assign a PARAM_EXEC slot for a new NLP */
442  exprType((Node *) phv->phexpr),
443  exprTypmod((Node *) phv->phexpr),
444  exprCollation((Node *) phv->phexpr));
445 
446  /* Add it to the list of required NLPs */
447  nlp = makeNode(NestLoopParam);
448  nlp->paramno = param->paramid;
449  nlp->paramval = (Var *) copyObject(phv);
450  root->curOuterParams = lappend(root->curOuterParams, nlp);
451 
452  /* And return the replacement Param */
453  return param;
454 }
455 
456 /*
457  * process_subquery_nestloop_params
458  * Handle params of a parameterized subquery that need to be fed
459  * from an outer nestloop.
460  *
461  * Currently, that would be *all* params that a subquery in FROM has demanded
462  * from the current query level, since they must be LATERAL references.
463  *
464  * subplan_params is a list of PlannerParamItems that we intend to pass to
465  * a subquery-in-FROM. (This was constructed in root->plan_params while
466  * planning the subquery, but isn't there anymore when this is called.)
467  *
468  * The subplan's references to the outer variables are already represented
469  * as PARAM_EXEC Params, since that conversion was done by the routines above
470  * while planning the subquery. So we need not modify the subplan or the
471  * PlannerParamItems here. What we do need to do is add entries to
472  * root->curOuterParams to signal the parent nestloop plan node that it must
473  * provide these values. This differs from replace_nestloop_param_var in
474  * that the PARAM_EXEC slots to use have already been determined.
475  *
476  * Note that we also use root->curOuterRels as an implicit parameter for
477  * sanity checks.
478  */
479 void
481 {
482  ListCell *lc;
483 
484  foreach(lc, subplan_params)
485  {
487 
488  if (IsA(pitem->item, Var))
489  {
490  Var *var = (Var *) pitem->item;
491  NestLoopParam *nlp;
492  ListCell *lc2;
493 
494  /* If not from a nestloop outer rel, complain */
495  if (!bms_is_member(var->varno, root->curOuterRels))
496  elog(ERROR, "non-LATERAL parameter required by subquery");
497 
498  /* Is this param already listed in root->curOuterParams? */
499  foreach(lc2, root->curOuterParams)
500  {
501  nlp = (NestLoopParam *) lfirst(lc2);
502  if (nlp->paramno == pitem->paramId)
503  {
504  Assert(equal(var, nlp->paramval));
505  /* Present, so nothing to do */
506  break;
507  }
508  }
509  if (lc2 == NULL)
510  {
511  /* No, so add it */
512  nlp = makeNode(NestLoopParam);
513  nlp->paramno = pitem->paramId;
514  nlp->paramval = copyObject(var);
515  root->curOuterParams = lappend(root->curOuterParams, nlp);
516  }
517  }
518  else if (IsA(pitem->item, PlaceHolderVar))
519  {
520  PlaceHolderVar *phv = (PlaceHolderVar *) pitem->item;
521  NestLoopParam *nlp;
522  ListCell *lc2;
523 
524  /* If not from a nestloop outer rel, complain */
525  if (!bms_is_subset(find_placeholder_info(root, phv)->ph_eval_at,
526  root->curOuterRels))
527  elog(ERROR, "non-LATERAL parameter required by subquery");
528 
529  /* Is this param already listed in root->curOuterParams? */
530  foreach(lc2, root->curOuterParams)
531  {
532  nlp = (NestLoopParam *) lfirst(lc2);
533  if (nlp->paramno == pitem->paramId)
534  {
535  Assert(equal(phv, nlp->paramval));
536  /* Present, so nothing to do */
537  break;
538  }
539  }
540  if (lc2 == NULL)
541  {
542  /* No, so add it */
543  nlp = makeNode(NestLoopParam);
544  nlp->paramno = pitem->paramId;
545  nlp->paramval = (Var *) copyObject(phv);
546  root->curOuterParams = lappend(root->curOuterParams, nlp);
547  }
548  }
549  else
550  elog(ERROR, "unexpected type of subquery parameter");
551  }
552 }
553 
554 /*
555  * Identify any NestLoopParams that should be supplied by a NestLoop plan
556  * node with the specified lefthand rels. Remove them from the active
557  * root->curOuterParams list and return them as the result list.
558  *
559  * XXX Here we also hack up the returned Vars and PHVs so that they do not
560  * contain nullingrel sets exceeding what is available from the outer side.
561  * This is needed if we have applied outer join identity 3,
562  * (A leftjoin B on (Pab)) leftjoin C on (Pb*c)
563  * = A leftjoin (B leftjoin C on (Pbc)) on (Pab)
564  * and C contains lateral references to B. It's still safe to apply the
565  * identity, but the parser will have created those references in the form
566  * "b*" (i.e., with varnullingrels listing the A/B join), while what we will
567  * have available from the nestloop's outer side is just "b". We deal with
568  * that here by stripping the nullingrels down to what is available from the
569  * outer side according to leftrelids.
570  *
571  * That fixes matters for the case of forward application of identity 3.
572  * If the identity was applied in the reverse direction, we will have
573  * parameter Vars containing too few nullingrel bits rather than too many.
574  * Currently, that causes no problems because setrefs.c applies only a
575  * subset check to nullingrels in NestLoopParams, but we'd have to work
576  * harder if we ever want to tighten that check. This is all pretty annoying
577  * because it greatly weakens setrefs.c's cross-check, but the alternative
578  * seems to be to generate multiple versions of each laterally-parameterized
579  * subquery, which'd be unduly expensive.
580  */
581 List *
583 {
584  List *result;
585  ListCell *cell;
586 
587  result = NIL;
588  foreach(cell, root->curOuterParams)
589  {
590  NestLoopParam *nlp = (NestLoopParam *) lfirst(cell);
591 
592  /*
593  * We are looking for Vars and PHVs that can be supplied by the
594  * lefthand rels. When we find one, it's okay to modify it in-place
595  * because all the routines above make a fresh copy to put into
596  * curOuterParams.
597  */
598  if (IsA(nlp->paramval, Var) &&
599  bms_is_member(nlp->paramval->varno, leftrelids))
600  {
601  Var *var = (Var *) nlp->paramval;
602 
603  root->curOuterParams = foreach_delete_current(root->curOuterParams,
604  cell);
605  var->varnullingrels = bms_intersect(var->varnullingrels,
606  leftrelids);
607  result = lappend(result, nlp);
608  }
609  else if (IsA(nlp->paramval, PlaceHolderVar) &&
612  leftrelids))
613  {
614  PlaceHolderVar *phv = (PlaceHolderVar *) nlp->paramval;
615 
616  root->curOuterParams = foreach_delete_current(root->curOuterParams,
617  cell);
619  leftrelids);
620  result = lappend(result, nlp);
621  }
622  }
623  return result;
624 }
625 
626 /*
627  * Generate a new Param node that will not conflict with any other.
628  *
629  * This is used to create Params representing subplan outputs or
630  * NestLoop parameters.
631  *
632  * We don't need to build a PlannerParamItem for such a Param, but we do
633  * need to make sure we record the type in paramExecTypes (otherwise,
634  * there won't be a slot allocated for it).
635  */
636 Param *
638  Oid paramcollation)
639 {
640  Param *retval;
641 
642  retval = makeNode(Param);
643  retval->paramkind = PARAM_EXEC;
644  retval->paramid = list_length(root->glob->paramExecTypes);
645  root->glob->paramExecTypes = lappend_oid(root->glob->paramExecTypes,
646  paramtype);
647  retval->paramtype = paramtype;
648  retval->paramtypmod = paramtypmod;
649  retval->paramcollid = paramcollation;
650  retval->location = -1;
651 
652  return retval;
653 }
654 
655 /*
656  * Assign a (nonnegative) PARAM_EXEC ID for a special parameter (one that
657  * is not actually used to carry a value at runtime). Such parameters are
658  * used for special runtime signaling purposes, such as connecting a
659  * recursive union node to its worktable scan node or forcing plan
660  * re-evaluation within the EvalPlanQual mechanism. No actual Param node
661  * exists with this ID, however.
662  */
663 int
665 {
666  int paramId = list_length(root->glob->paramExecTypes);
667 
668  root->glob->paramExecTypes = lappend_oid(root->glob->paramExecTypes,
669  InvalidOid);
670  return paramId;
671 }
bool bms_equal(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:142
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:412
bool bms_is_member(int x, const Bitmapset *a)
Definition: bitmapset.c:510
Bitmapset * bms_intersect(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:292
signed int int32
Definition: c.h:494
#define Assert(condition)
Definition: c.h:858
unsigned int Index
Definition: c.h:614
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:224
bool equal(const void *a, const void *b)
Definition: equalfuncs.c:223
int i
Definition: isn.c:73
if(TABLE==NULL||TABLE_index==NULL)
Definition: isn.c:77
List * lappend(List *list, void *datum)
Definition: list.c:339
List * lappend_oid(List *list, Oid datum)
Definition: list.c:375
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:42
int32 exprTypmod(const Node *expr)
Definition: nodeFuncs.c:298
Oid exprCollation(const Node *expr)
Definition: nodeFuncs.c:816
#define IsA(nodeptr, _type_)
Definition: nodes.h:158
#define copyObject(obj)
Definition: nodes.h:224
@ CMD_MERGE
Definition: nodes.h:269
#define makeNode(_type_)
Definition: nodes.h:155
static int assign_param_for_var(PlannerInfo *root, Var *var)
Definition: paramassign.c:66
static int assign_param_for_placeholdervar(PlannerInfo *root, PlaceHolderVar *phv)
Definition: paramassign.c:149
Param * generate_new_exec_param(PlannerInfo *root, Oid paramtype, int32 paramtypmod, Oid paramcollation)
Definition: paramassign.c:637
Param * replace_outer_var(PlannerInfo *root, Var *var)
Definition: paramassign.c:120
void process_subquery_nestloop_params(PlannerInfo *root, List *subplan_params)
Definition: paramassign.c:480
Param * replace_outer_grouping(PlannerInfo *root, GroupingFunc *grp)
Definition: paramassign.c:270
Param * replace_nestloop_param_var(PlannerInfo *root, Var *var)
Definition: paramassign.c:367
List * identify_current_nestloop_params(PlannerInfo *root, Relids leftrelids)
Definition: paramassign.c:582
Param * replace_outer_placeholdervar(PlannerInfo *root, PlaceHolderVar *phv)
Definition: paramassign.c:197
Param * replace_outer_merge_support(PlannerInfo *root, MergeSupportFunc *msf)
Definition: paramassign.c:317
Param * replace_outer_agg(PlannerInfo *root, Aggref *agg)
Definition: paramassign.c:224
Param * replace_nestloop_param_placeholdervar(PlannerInfo *root, PlaceHolderVar *phv)
Definition: paramassign.c:416
int assign_special_exec_param(PlannerInfo *root)
Definition: paramassign.c:664
#define lfirst(lc)
Definition: pg_list.h:172
#define lfirst_node(type, lc)
Definition: pg_list.h:176
static int list_length(const List *l)
Definition: pg_list.h:152
#define NIL
Definition: pg_list.h:68
#define foreach_delete_current(lst, var_or_cell)
Definition: pg_list.h:391
PlaceHolderInfo * find_placeholder_info(PlannerInfo *root, PlaceHolderVar *phv)
Definition: placeholder.c:83
#define InvalidOid
Definition: postgres_ext.h:36
unsigned int Oid
Definition: postgres_ext.h:31
@ PARAM_EXEC
Definition: primnodes.h:368
tree ctl root
Definition: radixtree.h:1884
void IncrementVarSublevelsUp(Node *node, int delta_sublevels_up, int min_sublevels_up)
Definition: rewriteManip.c:849
ParseLoc location
Definition: primnodes.h:507
Index agglevelsup
Definition: primnodes.h:551
ParseLoc location
Definition: primnodes.h:554
Definition: pg_list.h:54
ParseLoc location
Definition: primnodes.h:606
Var * paramval
Definition: plannodes.h:819
Definition: nodes.h:129
ParseLoc location
Definition: primnodes.h:384
int paramid
Definition: primnodes.h:377
Oid paramtype
Definition: primnodes.h:378
ParamKind paramkind
Definition: primnodes.h:376
Relids ph_eval_at
Definition: pathnodes.h:3076
Relids phnullingrels
Definition: pathnodes.h:2779
Index phlevelsup
Definition: pathnodes.h:2785
Definition: primnodes.h:248
ParseLoc location
Definition: primnodes.h:293
AttrNumber varattno
Definition: primnodes.h:260
int varno
Definition: primnodes.h:255
Index varlevelsup
Definition: primnodes.h:280