PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
var.h File Reference
#include "nodes/relation.h"
Include dependency graph for var.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PVC_INCLUDE_AGGREGATES   0x0001 /* include Aggrefs in output list */
 
#define PVC_RECURSE_AGGREGATES   0x0002 /* recurse into Aggref arguments */
 
#define PVC_INCLUDE_WINDOWFUNCS   0x0004 /* include WindowFuncs in output list */
 
#define PVC_RECURSE_WINDOWFUNCS   0x0008 /* recurse into WindowFunc arguments */
 
#define PVC_INCLUDE_PLACEHOLDERS
 
#define PVC_RECURSE_PLACEHOLDERS
 

Functions

Relids pull_varnos (Node *node)
 
Relids pull_varnos_of_level (Node *node, int levelsup)
 
void pull_varattnos (Node *node, Index varno, Bitmapset **varattnos)
 
Listpull_vars_of_level (Node *node, int levelsup)
 
bool contain_var_clause (Node *node)
 
bool contain_vars_of_level (Node *node, int levelsup)
 
int locate_var_of_level (Node *node, int levelsup)
 
Listpull_var_clause (Node *node, int flags)
 
Nodeflatten_join_alias_vars (PlannerInfo *root, Node *node)
 

Macro Definition Documentation

#define PVC_INCLUDE_AGGREGATES   0x0001 /* include Aggrefs in output list */
#define PVC_INCLUDE_WINDOWFUNCS   0x0004 /* include WindowFuncs in output list */
#define PVC_RECURSE_PLACEHOLDERS
Value:
0x0020 /* recurse into PlaceHolderVar
* arguments */

Definition at line 26 of file var.h.

Referenced by build_tlist_to_deparse(), estimate_num_groups(), pull_var_clause(), and pull_var_clause_walker().

Function Documentation

bool contain_var_clause ( Node node)

Definition at line 331 of file var.c.

References contain_var_clause_walker(), and NULL.

Referenced by contain_leaked_vars_walker(), cookDefault(), domainAddConstraint(), interpret_function_parameter_list(), is_pseudo_constant_clause(), and match_clause_to_ordering_op().

332 {
333  return contain_var_clause_walker(node, NULL);
334 }
static bool contain_var_clause_walker(Node *node, void *context)
Definition: var.c:337
#define NULL
Definition: c.h:229
bool contain_vars_of_level ( Node node,
int  levelsup 
)

Definition at line 369 of file var.c.

References contain_vars_of_level_walker(), and query_or_expression_tree_walker().

Referenced by checkExprIsVarFree(), convert_ANY_sublink_to_join(), convert_EXISTS_sublink_to_join(), convert_EXISTS_to_ANY(), pull_up_simple_values(), pullup_replace_vars_callback(), set_append_rel_size(), transformAExprIn(), transformRangeFunction(), transformRangeTableFunc(), transformSetOperationTree(), and transformValuesClause().

370 {
371  int sublevels_up = levelsup;
372 
375  (void *) &sublevels_up,
376  0);
377 }
bool query_or_expression_tree_walker(Node *node, bool(*walker)(), void *context, int flags)
Definition: nodeFuncs.c:3200
static bool contain_vars_of_level_walker(Node *node, int *sublevels_up)
Definition: var.c:380
Node* flatten_join_alias_vars ( PlannerInfo root,
Node node 
)

Definition at line 670 of file var.c.

References flatten_join_alias_vars_mutator(), Query::hasSubLinks, flatten_join_alias_vars_context::inserted_sublink, PlannerInfo::parse, flatten_join_alias_vars_context::possible_sublink, flatten_join_alias_vars_context::root, and flatten_join_alias_vars_context::sublevels_up.

Referenced by finalize_grouping_exprs_walker(), parseCheckAggregates(), preprocess_expression(), pull_up_simple_subquery(), and subquery_planner().

671 {
673 
674  context.root = root;
675  context.sublevels_up = 0;
676  /* flag whether join aliases could possibly contain SubLinks */
677  context.possible_sublink = root->parse->hasSubLinks;
678  /* if hasSubLinks is already true, no need to work hard */
679  context.inserted_sublink = root->parse->hasSubLinks;
680 
681  return flatten_join_alias_vars_mutator(node, &context);
682 }
Query * parse
Definition: relation.h:155
bool hasSubLinks
Definition: parsenodes.h:126
static Node * flatten_join_alias_vars_mutator(Node *node, flatten_join_alias_vars_context *context)
Definition: var.c:685
PlannerInfo * root
Definition: var.c:63
int locate_var_of_level ( Node node,
int  levelsup 
)

Definition at line 437 of file var.c.

References locate_var_of_level_walker(), query_or_expression_tree_walker(), locate_var_of_level_context::sublevels_up, and locate_var_of_level_context::var_location.

Referenced by check_agg_arguments(), checkExprIsVarFree(), and transformSetOperationTree().

438 {
440 
441  context.var_location = -1; /* in case we find nothing */
442  context.sublevels_up = levelsup;
443 
446  (void *) &context,
447  0);
448 
449  return context.var_location;
450 }
bool query_or_expression_tree_walker(Node *node, bool(*walker)(), void *context, int flags)
Definition: nodeFuncs.c:3200
static bool locate_var_of_level_walker(Node *node, locate_var_of_level_context *context)
Definition: var.c:453
List* pull_var_clause ( Node node,
int  flags 
)

Definition at line 535 of file var.c.

References Assert, pull_var_clause_context::flags, NIL, pull_var_clause_walker(), PVC_INCLUDE_AGGREGATES, PVC_INCLUDE_PLACEHOLDERS, PVC_INCLUDE_WINDOWFUNCS, PVC_RECURSE_AGGREGATES, PVC_RECURSE_PLACEHOLDERS, PVC_RECURSE_WINDOWFUNCS, and pull_var_clause_context::varlist.

Referenced by AddRelationNewConstraints(), build_base_rel_tlists(), build_tlist_to_deparse(), CreateTrigger(), distribute_qual_to_rels(), estimate_num_groups(), find_placeholders_in_expr(), fix_placeholder_input_needed_levels(), foreign_grouping_ok(), generate_base_implied_equalities_no_const(), make_group_input_target(), make_partial_grouping_target(), make_sort_input_target(), make_window_input_target(), prepare_sort_from_pathkeys(), preprocess_targetlist(), qual_is_pushdown_safe(), and StoreRelCheck().

536 {
537  pull_var_clause_context context;
538 
539  /* Assert that caller has not specified inconsistent flags */
546 
547  context.varlist = NIL;
548  context.flags = flags;
549 
550  pull_var_clause_walker(node, &context);
551  return context.varlist;
552 }
#define NIL
Definition: pg_list.h:69
#define PVC_RECURSE_AGGREGATES
Definition: var.h:21
#define PVC_RECURSE_PLACEHOLDERS
Definition: var.h:26
#define PVC_INCLUDE_AGGREGATES
Definition: var.h:20
#define PVC_INCLUDE_PLACEHOLDERS
Definition: var.h:24
#define PVC_RECURSE_WINDOWFUNCS
Definition: var.h:23
#define PVC_INCLUDE_WINDOWFUNCS
Definition: var.h:22
#define Assert(condition)
Definition: c.h:675
static bool pull_var_clause_walker(Node *node, pull_var_clause_context *context)
Definition: var.c:555
void pull_varattnos ( Node node,
Index  varno,
Bitmapset **  varattnos 
)

Definition at line 219 of file var.c.

References pull_varattnos_walker(), pull_varattnos_context::varattnos, and pull_varattnos_context::varno.

Referenced by check_index_only(), check_selective_binary_conversion(), ComputePartitionAttrs(), create_foreignscan_plan(), DefineIndex(), deparseReturningList(), is_partition_attr(), postgresGetForeignRelSize(), RelationGetIndexAttrBitmap(), and remove_unused_subquery_outputs().

220 {
221  pull_varattnos_context context;
222 
223  context.varattnos = *varattnos;
224  context.varno = varno;
225 
226  (void) pull_varattnos_walker(node, &context);
227 
228  *varattnos = context.varattnos;
229 }
Bitmapset * varattnos
Definition: var.c:39
static bool pull_varattnos_walker(Node *node, pull_varattnos_context *context)
Definition: var.c:232
Relids pull_varnos ( Node node)

Definition at line 95 of file var.c.

References NULL, pull_varnos_walker(), query_or_expression_tree_walker(), pull_varnos_context::sublevels_up, and pull_varnos_context::varnos.

Referenced by adjust_rowcompare_for_index(), compute_semijoin_info(), convert_ANY_sublink_to_join(), convert_EXISTS_sublink_to_join(), distribute_qual_to_rels(), examine_variable(), find_placeholder_info(), get_eclass_for_sort_expr(), inheritance_planner(), join_is_removable(), make_outerjoininfo(), make_restrictinfo_internal(), match_clause_to_indexcol(), match_rowcompare_to_indexcol(), NumRelids(), pullup_replace_vars_callback(), and reduce_outer_joins_pass2().

96 {
97  pull_varnos_context context;
98 
99  context.varnos = NULL;
100  context.sublevels_up = 0;
101 
102  /*
103  * Must be prepared to start with a Query or a bare expression tree; if
104  * it's a Query, we don't want to increment sublevels_up.
105  */
108  (void *) &context,
109  0);
110 
111  return context.varnos;
112 }
static bool pull_varnos_walker(Node *node, pull_varnos_context *context)
Definition: var.c:140
int sublevels_up
Definition: var.c:34
Relids varnos
Definition: var.c:33
bool query_or_expression_tree_walker(Node *node, bool(*walker)(), void *context, int flags)
Definition: nodeFuncs.c:3200
#define NULL
Definition: c.h:229
Relids pull_varnos_of_level ( Node node,
int  levelsup 
)

Definition at line 120 of file var.c.

References NULL, pull_varnos_walker(), query_or_expression_tree_walker(), pull_varnos_context::sublevels_up, and pull_varnos_context::varnos.

Referenced by is_simple_subquery(), and jointree_contains_lateral_outer_refs().

121 {
122  pull_varnos_context context;
123 
124  context.varnos = NULL;
125  context.sublevels_up = levelsup;
126 
127  /*
128  * Must be prepared to start with a Query or a bare expression tree; if
129  * it's a Query, we don't want to increment sublevels_up.
130  */
133  (void *) &context,
134  0);
135 
136  return context.varnos;
137 }
static bool pull_varnos_walker(Node *node, pull_varnos_context *context)
Definition: var.c:140
int sublevels_up
Definition: var.c:34
Relids varnos
Definition: var.c:33
bool query_or_expression_tree_walker(Node *node, bool(*walker)(), void *context, int flags)
Definition: nodeFuncs.c:3200
#define NULL
Definition: c.h:229
List* pull_vars_of_level ( Node node,
int  levelsup 
)

Definition at line 263 of file var.c.

References NIL, pull_vars_walker(), query_or_expression_tree_walker(), pull_vars_context::sublevels_up, and pull_vars_context::vars.

Referenced by extract_lateral_references().

264 {
265  pull_vars_context context;
266 
267  context.vars = NIL;
268  context.sublevels_up = levelsup;
269 
270  /*
271  * Must be prepared to start with a Query or a bare expression tree; if
272  * it's a Query, we don't want to increment sublevels_up.
273  */
276  (void *) &context,
277  0);
278 
279  return context.vars;
280 }
int sublevels_up
Definition: var.c:46
#define NIL
Definition: pg_list.h:69
static bool pull_vars_walker(Node *node, pull_vars_context *context)
Definition: var.c:283
List * vars
Definition: var.c:45
bool query_or_expression_tree_walker(Node *node, bool(*walker)(), void *context, int flags)
Definition: nodeFuncs.c:3200