PostgreSQL Source Code  git master
paramassign.h File Reference
#include "nodes/pathnodes.h"
Include dependency graph for paramassign.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

Paramreplace_outer_var (PlannerInfo *root, Var *var)
 
Paramreplace_outer_placeholdervar (PlannerInfo *root, PlaceHolderVar *phv)
 
Paramreplace_outer_agg (PlannerInfo *root, Aggref *agg)
 
Paramreplace_outer_grouping (PlannerInfo *root, GroupingFunc *grp)
 
Paramreplace_nestloop_param_var (PlannerInfo *root, Var *var)
 
Paramreplace_nestloop_param_placeholdervar (PlannerInfo *root, PlaceHolderVar *phv)
 
void process_subquery_nestloop_params (PlannerInfo *root, List *subplan_params)
 
Listidentify_current_nestloop_params (PlannerInfo *root, Relids leftrelids)
 
Paramgenerate_new_exec_param (PlannerInfo *root, Oid paramtype, int32 paramtypmod, Oid paramcollation)
 
int assign_special_exec_param (PlannerInfo *root)
 

Function Documentation

◆ assign_special_exec_param()

int assign_special_exec_param ( PlannerInfo root)

Definition at line 585 of file paramassign.c.

References PlannerInfo::glob, InvalidOid, lappend_oid(), list_length(), and PlannerGlobal::paramExecTypes.

Referenced by create_gather_merge_plan(), create_gather_plan(), grouping_planner(), inheritance_planner(), SS_process_ctes(), and subquery_planner().

586 {
587  int paramId = list_length(root->glob->paramExecTypes);
588 
590  InvalidOid);
591  return paramId;
592 }
List * lappend_oid(List *list, Oid datum)
Definition: list.c:358
List * paramExecTypes
Definition: pathnodes.h:129
PlannerGlobal * glob
Definition: pathnodes.h:179
#define InvalidOid
Definition: postgres_ext.h:36
static int list_length(const List *l)
Definition: pg_list.h:169

◆ generate_new_exec_param()

Param* generate_new_exec_param ( PlannerInfo root,
Oid  paramtype,
int32  paramtypmod,
Oid  paramcollation 
)

Definition at line 558 of file paramassign.c.

References PlannerInfo::glob, lappend_oid(), list_length(), Param::location, makeNode, PARAM_EXEC, Param::paramcollid, PlannerGlobal::paramExecTypes, Param::paramid, Param::paramkind, Param::paramtype, and Param::paramtypmod.

Referenced by build_subplan(), convert_EXISTS_to_ANY(), generate_subquery_params(), replace_nestloop_param_placeholdervar(), replace_nestloop_param_var(), and SS_make_initplan_output_param().

560 {
561  Param *retval;
562 
563  retval = makeNode(Param);
564  retval->paramkind = PARAM_EXEC;
565  retval->paramid = list_length(root->glob->paramExecTypes);
567  paramtype);
568  retval->paramtype = paramtype;
569  retval->paramtypmod = paramtypmod;
570  retval->paramcollid = paramcollation;
571  retval->location = -1;
572 
573  return retval;
574 }
ParamKind paramkind
Definition: primnodes.h:248
List * lappend_oid(List *list, Oid datum)
Definition: list.c:358
List * paramExecTypes
Definition: pathnodes.h:129
Oid paramcollid
Definition: primnodes.h:252
int location
Definition: primnodes.h:253
PlannerGlobal * glob
Definition: pathnodes.h:179
int32 paramtypmod
Definition: primnodes.h:251
#define makeNode(_type_)
Definition: nodes.h:573
int paramid
Definition: primnodes.h:249
static int list_length(const List *l)
Definition: pg_list.h:169
Oid paramtype
Definition: primnodes.h:250

◆ identify_current_nestloop_params()

List* identify_current_nestloop_params ( PlannerInfo root,
Relids  leftrelids 
)

Definition at line 509 of file paramassign.c.

References bms_is_member(), bms_is_subset(), bms_overlap(), PlannerInfo::curOuterParams, find_placeholder_info(), foreach_delete_current, IsA, lappend(), lfirst, NIL, NestLoopParam::paramval, PlaceHolderInfo::ph_eval_at, and Var::varno.

Referenced by create_nestloop_plan().

510 {
511  List *result;
512  ListCell *cell;
513 
514  result = NIL;
515  foreach(cell, root->curOuterParams)
516  {
517  NestLoopParam *nlp = (NestLoopParam *) lfirst(cell);
518 
519  /*
520  * We are looking for Vars and PHVs that can be supplied by the
521  * lefthand rels. The "bms_overlap" test is just an optimization to
522  * allow skipping find_placeholder_info() if the PHV couldn't match.
523  */
524  if (IsA(nlp->paramval, Var) &&
525  bms_is_member(nlp->paramval->varno, leftrelids))
526  {
528  cell);
529  result = lappend(result, nlp);
530  }
531  else if (IsA(nlp->paramval, PlaceHolderVar) &&
532  bms_overlap(((PlaceHolderVar *) nlp->paramval)->phrels,
533  leftrelids) &&
535  (PlaceHolderVar *) nlp->paramval,
536  false)->ph_eval_at,
537  leftrelids))
538  {
540  cell);
541  result = lappend(result, nlp);
542  }
543  }
544  return result;
545 }
#define NIL
Definition: pg_list.h:65
#define IsA(nodeptr, _type_)
Definition: nodes.h:576
Relids ph_eval_at
Definition: pathnodes.h:2261
Definition: primnodes.h:167
#define foreach_delete_current(lst, cell)
Definition: pg_list.h:368
Var * paramval
Definition: plannodes.h:706
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:315
List * curOuterParams
Definition: pathnodes.h:356
PlaceHolderInfo * find_placeholder_info(PlannerInfo *root, PlaceHolderVar *phv, bool create_new_ph)
Definition: placeholder.c:69
List * lappend(List *list, void *datum)
Definition: list.c:322
Index varno
Definition: primnodes.h:170
#define lfirst(lc)
Definition: pg_list.h:190
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:494
Definition: pg_list.h:50
bool bms_is_member(int x, const Bitmapset *a)
Definition: bitmapset.c:427

◆ process_subquery_nestloop_params()

void process_subquery_nestloop_params ( PlannerInfo root,
List subplan_params 
)

Definition at line 429 of file paramassign.c.

References Assert, bms_is_member(), bms_is_subset(), castNode, copyObject, PlannerInfo::curOuterParams, PlannerInfo::curOuterRels, elog, equal(), ERROR, find_placeholder_info(), IsA, PlannerParamItem::item, lappend(), lfirst, makeNode, PlannerParamItem::paramId, and Var::varno.

Referenced by create_subqueryscan_plan().

430 {
431  ListCell *lc;
432 
433  foreach(lc, subplan_params)
434  {
436 
437  if (IsA(pitem->item, Var))
438  {
439  Var *var = (Var *) pitem->item;
440  NestLoopParam *nlp;
441  ListCell *lc;
442 
443  /* If not from a nestloop outer rel, complain */
444  if (!bms_is_member(var->varno, root->curOuterRels))
445  elog(ERROR, "non-LATERAL parameter required by subquery");
446 
447  /* Is this param already listed in root->curOuterParams? */
448  foreach(lc, root->curOuterParams)
449  {
450  nlp = (NestLoopParam *) lfirst(lc);
451  if (nlp->paramno == pitem->paramId)
452  {
453  Assert(equal(var, nlp->paramval));
454  /* Present, so nothing to do */
455  break;
456  }
457  }
458  if (lc == NULL)
459  {
460  /* No, so add it */
461  nlp = makeNode(NestLoopParam);
462  nlp->paramno = pitem->paramId;
463  nlp->paramval = copyObject(var);
464  root->curOuterParams = lappend(root->curOuterParams, nlp);
465  }
466  }
467  else if (IsA(pitem->item, PlaceHolderVar))
468  {
469  PlaceHolderVar *phv = (PlaceHolderVar *) pitem->item;
470  NestLoopParam *nlp;
471  ListCell *lc;
472 
473  /* If not from a nestloop outer rel, complain */
474  if (!bms_is_subset(find_placeholder_info(root, phv, false)->ph_eval_at,
475  root->curOuterRels))
476  elog(ERROR, "non-LATERAL parameter required by subquery");
477 
478  /* Is this param already listed in root->curOuterParams? */
479  foreach(lc, root->curOuterParams)
480  {
481  nlp = (NestLoopParam *) lfirst(lc);
482  if (nlp->paramno == pitem->paramId)
483  {
484  Assert(equal(phv, nlp->paramval));
485  /* Present, so nothing to do */
486  break;
487  }
488  }
489  if (lc == NULL)
490  {
491  /* No, so add it */
492  nlp = makeNode(NestLoopParam);
493  nlp->paramno = pitem->paramId;
494  nlp->paramval = (Var *) copyObject(phv);
495  root->curOuterParams = lappend(root->curOuterParams, nlp);
496  }
497  }
498  else
499  elog(ERROR, "unexpected type of subquery parameter");
500  }
501 }
#define IsA(nodeptr, _type_)
Definition: nodes.h:576
Relids curOuterRels
Definition: pathnodes.h:355
bool equal(const void *a, const void *b)
Definition: equalfuncs.c:3008
#define castNode(_type_, nodeptr)
Definition: nodes.h:594
Definition: primnodes.h:167
#define ERROR
Definition: elog.h:43
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:315
List * curOuterParams
Definition: pathnodes.h:356
PlaceHolderInfo * find_placeholder_info(PlannerInfo *root, PlaceHolderVar *phv, bool create_new_ph)
Definition: placeholder.c:69
List * lappend(List *list, void *datum)
Definition: list.c:322
Index varno
Definition: primnodes.h:170
#define makeNode(_type_)
Definition: nodes.h:573
#define Assert(condition)
Definition: c.h:732
#define lfirst(lc)
Definition: pg_list.h:190
#define elog(elevel,...)
Definition: elog.h:226
#define copyObject(obj)
Definition: nodes.h:641
bool bms_is_member(int x, const Bitmapset *a)
Definition: bitmapset.c:427

◆ replace_nestloop_param_placeholdervar()

Param* replace_nestloop_param_placeholdervar ( PlannerInfo root,
PlaceHolderVar phv 
)

Definition at line 365 of file paramassign.c.

References copyObject, PlannerInfo::curOuterParams, equal(), exprCollation(), exprType(), exprTypmod(), generate_new_exec_param(), lappend(), lfirst, Param::location, makeNode, PARAM_EXEC, Param::paramcollid, Param::paramid, Param::paramkind, NestLoopParam::paramno, Param::paramtype, Param::paramtypmod, NestLoopParam::paramval, and PlaceHolderVar::phexpr.

Referenced by replace_nestloop_params_mutator().

366 {
367  Param *param;
368  NestLoopParam *nlp;
369  ListCell *lc;
370 
371  /* Is this PHV already listed in root->curOuterParams? */
372  foreach(lc, root->curOuterParams)
373  {
374  nlp = (NestLoopParam *) lfirst(lc);
375  if (equal(phv, nlp->paramval))
376  {
377  /* Yes, so just make a Param referencing this NLP's slot */
378  param = makeNode(Param);
379  param->paramkind = PARAM_EXEC;
380  param->paramid = nlp->paramno;
381  param->paramtype = exprType((Node *) phv->phexpr);
382  param->paramtypmod = exprTypmod((Node *) phv->phexpr);
383  param->paramcollid = exprCollation((Node *) phv->phexpr);
384  param->location = -1;
385  return param;
386  }
387  }
388 
389  /* No, so assign a PARAM_EXEC slot for a new NLP */
390  param = generate_new_exec_param(root,
391  exprType((Node *) phv->phexpr),
392  exprTypmod((Node *) phv->phexpr),
393  exprCollation((Node *) phv->phexpr));
394 
395  /* Add it to the list of required NLPs */
396  nlp = makeNode(NestLoopParam);
397  nlp->paramno = param->paramid;
398  nlp->paramval = (Var *) copyObject(phv);
399  root->curOuterParams = lappend(root->curOuterParams, nlp);
400 
401  /* And return the replacement Param */
402  return param;
403 }
Param * generate_new_exec_param(PlannerInfo *root, Oid paramtype, int32 paramtypmod, Oid paramcollation)
Definition: paramassign.c:558
bool equal(const void *a, const void *b)
Definition: equalfuncs.c:3008
int32 exprTypmod(const Node *expr)
Definition: nodeFuncs.c:276
ParamKind paramkind
Definition: primnodes.h:248
Definition: nodes.h:525
Definition: primnodes.h:167
Var * paramval
Definition: plannodes.h:706
Oid paramcollid
Definition: primnodes.h:252
int location
Definition: primnodes.h:253
List * curOuterParams
Definition: pathnodes.h:356
List * lappend(List *list, void *datum)
Definition: list.c:322
int32 paramtypmod
Definition: primnodes.h:251
#define makeNode(_type_)
Definition: nodes.h:573
#define lfirst(lc)
Definition: pg_list.h:190
int paramid
Definition: primnodes.h:249
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:42
Oid exprCollation(const Node *expr)
Definition: nodeFuncs.c:720
#define copyObject(obj)
Definition: nodes.h:641
Oid paramtype
Definition: primnodes.h:250

◆ replace_nestloop_param_var()

Param* replace_nestloop_param_var ( PlannerInfo root,
Var var 
)

Definition at line 316 of file paramassign.c.

References copyObject, PlannerInfo::curOuterParams, equal(), generate_new_exec_param(), lappend(), lfirst, Var::location, Param::location, makeNode, PARAM_EXEC, Param::paramcollid, Param::paramid, Param::paramkind, NestLoopParam::paramno, Param::paramtype, Param::paramtypmod, NestLoopParam::paramval, Var::varcollid, Var::vartype, and Var::vartypmod.

Referenced by replace_nestloop_params_mutator().

317 {
318  Param *param;
319  NestLoopParam *nlp;
320  ListCell *lc;
321 
322  /* Is this Var already listed in root->curOuterParams? */
323  foreach(lc, root->curOuterParams)
324  {
325  nlp = (NestLoopParam *) lfirst(lc);
326  if (equal(var, nlp->paramval))
327  {
328  /* Yes, so just make a Param referencing this NLP's slot */
329  param = makeNode(Param);
330  param->paramkind = PARAM_EXEC;
331  param->paramid = nlp->paramno;
332  param->paramtype = var->vartype;
333  param->paramtypmod = var->vartypmod;
334  param->paramcollid = var->varcollid;
335  param->location = var->location;
336  return param;
337  }
338  }
339 
340  /* No, so assign a PARAM_EXEC slot for a new NLP */
341  param = generate_new_exec_param(root,
342  var->vartype,
343  var->vartypmod,
344  var->varcollid);
345  param->location = var->location;
346 
347  /* Add it to the list of required NLPs */
348  nlp = makeNode(NestLoopParam);
349  nlp->paramno = param->paramid;
350  nlp->paramval = copyObject(var);
351  root->curOuterParams = lappend(root->curOuterParams, nlp);
352 
353  /* And return the replacement Param */
354  return param;
355 }
Param * generate_new_exec_param(PlannerInfo *root, Oid paramtype, int32 paramtypmod, Oid paramcollation)
Definition: paramassign.c:558
bool equal(const void *a, const void *b)
Definition: equalfuncs.c:3008
ParamKind paramkind
Definition: primnodes.h:248
Var * paramval
Definition: plannodes.h:706
Oid paramcollid
Definition: primnodes.h:252
int location
Definition: primnodes.h:253
Oid vartype
Definition: primnodes.h:174
int location
Definition: primnodes.h:182
List * curOuterParams
Definition: pathnodes.h:356
List * lappend(List *list, void *datum)
Definition: list.c:322
int32 paramtypmod
Definition: primnodes.h:251
#define makeNode(_type_)
Definition: nodes.h:573
#define lfirst(lc)
Definition: pg_list.h:190
int paramid
Definition: primnodes.h:249
Oid varcollid
Definition: primnodes.h:176
#define copyObject(obj)
Definition: nodes.h:641
Oid paramtype
Definition: primnodes.h:250
int32 vartypmod
Definition: primnodes.h:175

◆ replace_outer_agg()

Param* replace_outer_agg ( PlannerInfo root,
Aggref agg 
)

Definition at line 224 of file paramassign.c.

References Aggref::agglevelsup, Assert, copyObject, PlannerInfo::glob, IncrementVarSublevelsUp(), PlannerParamItem::item, lappend(), lappend_oid(), list_length(), Param::location, makeNode, PARAM_EXEC, Param::paramcollid, PlannerGlobal::paramExecTypes, Param::paramid, PlannerParamItem::paramId, Param::paramkind, Param::paramtype, Param::paramtypmod, PlannerInfo::parent_root, PlannerInfo::plan_params, and PlannerInfo::query_level.

Referenced by replace_correlation_vars_mutator().

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);
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 }
List * plan_params
Definition: pathnodes.h:191
void IncrementVarSublevelsUp(Node *node, int delta_sublevels_up, int min_sublevels_up)
Definition: rewriteManip.c:773
PlannerInfo * parent_root
Definition: pathnodes.h:183
ParamKind paramkind
Definition: primnodes.h:248
Definition: nodes.h:525
List * lappend_oid(List *list, Oid datum)
Definition: list.c:358
List * paramExecTypes
Definition: pathnodes.h:129
Oid paramcollid
Definition: primnodes.h:252
int location
Definition: primnodes.h:253
PlannerGlobal * glob
Definition: pathnodes.h:179
Index agglevelsup
Definition: primnodes.h:313
List * lappend(List *list, void *datum)
Definition: list.c:322
unsigned int Index
Definition: c.h:475
int32 paramtypmod
Definition: primnodes.h:251
#define makeNode(_type_)
Definition: nodes.h:573
#define Assert(condition)
Definition: c.h:732
int paramid
Definition: primnodes.h:249
static int list_length(const List *l)
Definition: pg_list.h:169
Index query_level
Definition: pathnodes.h:181
#define copyObject(obj)
Definition: nodes.h:641
Oid paramtype
Definition: primnodes.h:250

◆ replace_outer_grouping()

Param* replace_outer_grouping ( PlannerInfo root,
GroupingFunc grp 
)

Definition at line 270 of file paramassign.c.

References Assert, copyObject, exprType(), PlannerInfo::glob, IncrementVarSublevelsUp(), InvalidOid, PlannerParamItem::item, lappend(), lappend_oid(), list_length(), Param::location, makeNode, PARAM_EXEC, Param::paramcollid, PlannerGlobal::paramExecTypes, Param::paramid, PlannerParamItem::paramId, Param::paramkind, Param::paramtype, Param::paramtypmod, PlannerInfo::parent_root, PlannerInfo::plan_params, and PlannerInfo::query_level.

Referenced by replace_correlation_vars_mutator().

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);
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 }
List * plan_params
Definition: pathnodes.h:191
void IncrementVarSublevelsUp(Node *node, int delta_sublevels_up, int min_sublevels_up)
Definition: rewriteManip.c:773
PlannerInfo * parent_root
Definition: pathnodes.h:183
ParamKind paramkind
Definition: primnodes.h:248
Definition: nodes.h:525
unsigned int Oid
Definition: postgres_ext.h:31
List * lappend_oid(List *list, Oid datum)
Definition: list.c:358
List * paramExecTypes
Definition: pathnodes.h:129
Oid paramcollid
Definition: primnodes.h:252
int location
Definition: primnodes.h:253
PlannerGlobal * glob
Definition: pathnodes.h:179
List * lappend(List *list, void *datum)
Definition: list.c:322
Index agglevelsup
Definition: primnodes.h:349
unsigned int Index
Definition: c.h:475
#define InvalidOid
Definition: postgres_ext.h:36
int32 paramtypmod
Definition: primnodes.h:251
#define makeNode(_type_)
Definition: nodes.h:573
#define Assert(condition)
Definition: c.h:732
int paramid
Definition: primnodes.h:249
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:42
static int list_length(const List *l)
Definition: pg_list.h:169
Index query_level
Definition: pathnodes.h:181
#define copyObject(obj)
Definition: nodes.h:641
Oid paramtype
Definition: primnodes.h:250

◆ replace_outer_placeholdervar()

Param* replace_outer_placeholdervar ( PlannerInfo root,
PlaceHolderVar phv 
)

Definition at line 197 of file paramassign.c.

References Assert, assign_param_for_placeholdervar(), exprCollation(), exprType(), exprTypmod(), i, Param::location, makeNode, PARAM_EXEC, Param::paramcollid, Param::paramid, Param::paramkind, Param::paramtype, Param::paramtypmod, PlaceHolderVar::phexpr, PlaceHolderVar::phlevelsup, and PlannerInfo::query_level.

Referenced by replace_correlation_vars_mutator().

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 */
205  i = assign_param_for_placeholdervar(root, phv);
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 }
int32 exprTypmod(const Node *expr)
Definition: nodeFuncs.c:276
ParamKind paramkind
Definition: primnodes.h:248
Definition: nodes.h:525
Oid paramcollid
Definition: primnodes.h:252
int location
Definition: primnodes.h:253
int32 paramtypmod
Definition: primnodes.h:251
#define makeNode(_type_)
Definition: nodes.h:573
#define Assert(condition)
Definition: c.h:732
int paramid
Definition: primnodes.h:249
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:42
Oid exprCollation(const Node *expr)
Definition: nodeFuncs.c:720
Index query_level
Definition: pathnodes.h:181
static int assign_param_for_placeholdervar(PlannerInfo *root, PlaceHolderVar *phv)
Definition: paramassign.c:149
Index phlevelsup
Definition: pathnodes.h:2065
int i
Oid paramtype
Definition: primnodes.h:250

◆ replace_outer_var()

Param* replace_outer_var ( PlannerInfo root,
Var var 
)

Definition at line 120 of file paramassign.c.

References Assert, assign_param_for_var(), i, Var::location, Param::location, makeNode, PARAM_EXEC, Param::paramcollid, Param::paramid, Param::paramkind, Param::paramtype, Param::paramtypmod, PlannerInfo::query_level, Var::varcollid, Var::varlevelsup, Var::vartype, and Var::vartypmod.

Referenced by replace_correlation_vars_mutator().

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 }
Index varlevelsup
Definition: primnodes.h:177
ParamKind paramkind
Definition: primnodes.h:248
static int assign_param_for_var(PlannerInfo *root, Var *var)
Definition: paramassign.c:66
Oid paramcollid
Definition: primnodes.h:252
int location
Definition: primnodes.h:253
Oid vartype
Definition: primnodes.h:174
int location
Definition: primnodes.h:182
int32 paramtypmod
Definition: primnodes.h:251
#define makeNode(_type_)
Definition: nodes.h:573
#define Assert(condition)
Definition: c.h:732
int paramid
Definition: primnodes.h:249
Index query_level
Definition: pathnodes.h:181
int i
Oid varcollid
Definition: primnodes.h:176
Oid paramtype
Definition: primnodes.h:250
int32 vartypmod
Definition: primnodes.h:175