PostgreSQL Source Code  git master
rewriteManip.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * rewriteManip.h
4  * Querytree manipulation subroutines for query rewriter.
5  *
6  *
7  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/rewrite/rewriteManip.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef REWRITEMANIP_H
15 #define REWRITEMANIP_H
16 
17 #include "nodes/parsenodes.h"
18 
19 struct AttrMap; /* avoid including attmap.h here */
20 
21 
23 
24 typedef Node *(*replace_rte_variables_callback) (Var *var,
26 
28 {
29  replace_rte_variables_callback callback; /* callback function */
30  void *callback_arg; /* context data for callback function */
31  int target_varno; /* RTE index to search for */
32  int sublevels_up; /* (current) nesting depth */
33  bool inserted_sublink; /* have we inserted a SubLink? */
34 };
35 
37 {
38  REPLACEVARS_REPORT_ERROR, /* throw error if no match */
39  REPLACEVARS_CHANGE_VARNO, /* change the Var's varno, nothing else */
40  REPLACEVARS_SUBSTITUTE_NULL /* replace with a NULL Const */
42 
43 
44 extern void OffsetVarNodes(Node *node, int offset, int sublevels_up);
45 extern void ChangeVarNodes(Node *node, int old_varno, int new_varno,
46  int sublevels_up);
47 extern void IncrementVarSublevelsUp(Node *node, int delta_sublevels_up,
48  int min_sublevels_up);
49 extern void IncrementVarSublevelsUp_rtable(List *rtable,
50  int delta_sublevels_up, int min_sublevels_up);
51 
52 extern bool rangeTableEntry_used(Node *node, int rt_index,
53  int sublevels_up);
54 
55 extern Query *getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr);
56 
57 extern void AddQual(Query *parsetree, Node *qual);
58 extern void AddInvertedQual(Query *parsetree, Node *qual);
59 
60 extern bool contain_aggs_of_level(Node *node, int levelsup);
61 extern int locate_agg_of_level(Node *node, int levelsup);
62 extern bool contain_windowfuncs(Node *node);
63 extern int locate_windowfunc(Node *node);
64 extern bool checkExprHasSubLink(Node *node);
65 
66 extern Node *replace_rte_variables(Node *node,
67  int target_varno, int sublevels_up,
69  void *callback_arg,
70  bool *outer_hasSubLinks);
73 
74 extern Node *map_variable_attnos(Node *node,
75  int target_varno, int sublevels_up,
76  const struct AttrMap *attno_map,
77  Oid to_rowtype, bool *found_whole_row);
78 
79 extern Node *ReplaceVarsFromTargetList(Node *node,
80  int target_varno, int sublevels_up,
81  RangeTblEntry *target_rte,
82  List *targetlist,
83  ReplaceVarsNoMatchOption nomatch_option,
84  int nomatch_varno,
85  bool *outer_hasSubLinks);
86 
87 #endif /* REWRITEMANIP_H */
void AddInvertedQual(Query *parsetree, Node *qual)
void OffsetVarNodes(Node *node, int offset, int sublevels_up)
Definition: rewriteManip.c:425
Node * map_variable_attnos(Node *node, int target_varno, int sublevels_up, const struct AttrMap *attno_map, Oid to_rowtype, bool *found_whole_row)
void IncrementVarSublevelsUp_rtable(List *rtable, int delta_sublevels_up, int min_sublevels_up)
Definition: rewriteManip.c:799
Definition: nodes.h:525
ReplaceVarsNoMatchOption
Definition: rewriteManip.h:36
replace_rte_variables_callback callback
Definition: rewriteManip.h:29
void ChangeVarNodes(Node *node, int old_varno, int new_varno, int sublevels_up)
Definition: rewriteManip.c:610
unsigned int Oid
Definition: postgres_ext.h:31
Definition: primnodes.h:181
int locate_windowfunc(Node *node)
Definition: rewriteManip.c:235
Definition: attmap.h:34
bool rangeTableEntry_used(Node *node, int rt_index, int sublevels_up)
Definition: rewriteManip.c:892
void AddQual(Query *parsetree, Node *qual)
Definition: rewriteManip.c:979
Query * getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr)
Definition: rewriteManip.c:924
void IncrementVarSublevelsUp(Node *node, int delta_sublevels_up, int min_sublevels_up)
Definition: rewriteManip.c:776
bool contain_aggs_of_level(Node *node, int levelsup)
Definition: rewriteManip.c:67
Node * ReplaceVarsFromTargetList(Node *node, int target_varno, int sublevels_up, RangeTblEntry *target_rte, List *targetlist, ReplaceVarsNoMatchOption nomatch_option, int nomatch_varno, bool *outer_hasSubLinks)
bool contain_windowfuncs(Node *node)
Definition: rewriteManip.c:197
Node * replace_rte_variables(Node *node, int target_varno, int sublevels_up, replace_rte_variables_callback callback, void *callback_arg, bool *outer_hasSubLinks)
Node * replace_rte_variables_mutator(Node *node, replace_rte_variables_context *context)
int locate_agg_of_level(Node *node, int levelsup)
Definition: rewriteManip.c:131
Definition: pg_list.h:50
Node *(* replace_rte_variables_callback)(Var *var, replace_rte_variables_context *context)
Definition: rewriteManip.h:24
bool checkExprHasSubLink(Node *node)
Definition: rewriteManip.c:277