PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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-2017, 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 
21 
22 typedef Node *(*replace_rte_variables_callback) (Var *var,
24 
26 {
27  replace_rte_variables_callback callback; /* callback function */
28  void *callback_arg; /* context data for callback function */
29  int target_varno; /* RTE index to search for */
30  int sublevels_up; /* (current) nesting depth */
31  bool inserted_sublink; /* have we inserted a SubLink? */
32 };
33 
35 {
36  REPLACEVARS_REPORT_ERROR, /* throw error if no match */
37  REPLACEVARS_CHANGE_VARNO, /* change the Var's varno, nothing else */
38  REPLACEVARS_SUBSTITUTE_NULL /* replace with a NULL Const */
40 
41 
42 extern void OffsetVarNodes(Node *node, int offset, int sublevels_up);
43 extern void ChangeVarNodes(Node *node, int old_varno, int new_varno,
44  int sublevels_up);
45 extern void IncrementVarSublevelsUp(Node *node, int delta_sublevels_up,
46  int min_sublevels_up);
47 extern void IncrementVarSublevelsUp_rtable(List *rtable,
48  int delta_sublevels_up, int min_sublevels_up);
49 
50 extern bool rangeTableEntry_used(Node *node, int rt_index,
51  int sublevels_up);
52 
53 extern Query *getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr);
54 
55 extern void AddQual(Query *parsetree, Node *qual);
56 extern void AddInvertedQual(Query *parsetree, Node *qual);
57 
58 extern bool contain_aggs_of_level(Node *node, int levelsup);
59 extern int locate_agg_of_level(Node *node, int levelsup);
60 extern bool contain_windowfuncs(Node *node);
61 extern int locate_windowfunc(Node *node);
62 extern bool checkExprHasSubLink(Node *node);
63 
64 extern Node *replace_rte_variables(Node *node,
65  int target_varno, int sublevels_up,
67  void *callback_arg,
68  bool *outer_hasSubLinks);
71 
72 extern Node *map_variable_attnos(Node *node,
73  int target_varno, int sublevels_up,
74  const AttrNumber *attno_map, int map_length,
75  Oid to_rowtype, bool *found_whole_row);
76 
77 extern Node *ReplaceVarsFromTargetList(Node *node,
78  int target_varno, int sublevels_up,
79  RangeTblEntry *target_rte,
80  List *targetlist,
81  ReplaceVarsNoMatchOption nomatch_option,
82  int nomatch_varno,
83  bool *outer_hasSubLinks);
84 
85 #endif /* REWRITEMANIP_H */
void AddInvertedQual(Query *parsetree, Node *qual)
void OffsetVarNodes(Node *node, int offset, int sublevels_up)
Definition: rewriteManip.c:424
Node *(* replace_rte_variables_callback)(Var *var, replace_rte_variables_context *context)
Definition: rewriteManip.h:22
void IncrementVarSublevelsUp_rtable(List *rtable, int delta_sublevels_up, int min_sublevels_up)
Definition: rewriteManip.c:796
Definition: nodes.h:509
ReplaceVarsNoMatchOption
Definition: rewriteManip.h:34
Node * map_variable_attnos(Node *node, int target_varno, int sublevels_up, const AttrNumber *attno_map, int map_length, Oid to_rowtype, bool *found_whole_row)
replace_rte_variables_callback callback
Definition: rewriteManip.h:27
void ChangeVarNodes(Node *node, int old_varno, int new_varno, int sublevels_up)
Definition: rewriteManip.c:607
unsigned int Oid
Definition: postgres_ext.h:31
Definition: primnodes.h:163
int locate_windowfunc(Node *node)
Definition: rewriteManip.c:235
bool rangeTableEntry_used(Node *node, int rt_index, int sublevels_up)
Definition: rewriteManip.c:889
void AddQual(Query *parsetree, Node *qual)
Definition: rewriteManip.c:976
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
Query * getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr)
Definition: rewriteManip.c:921
void IncrementVarSublevelsUp(Node *node, int delta_sublevels_up, int min_sublevels_up)
Definition: rewriteManip.c:773
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:45
int16 AttrNumber
Definition: attnum.h:21
bool checkExprHasSubLink(Node *node)
Definition: rewriteManip.c:277