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-2024, 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 CombineRangeTables(List **dst_rtable, List **dst_perminfos,
45  List *src_rtable, List *src_perminfos);
46 extern void OffsetVarNodes(Node *node, int offset, int sublevels_up);
47 extern void ChangeVarNodes(Node *node, int rt_index, int new_index,
48  int sublevels_up);
49 extern void IncrementVarSublevelsUp(Node *node, int delta_sublevels_up,
50  int min_sublevels_up);
51 extern void IncrementVarSublevelsUp_rtable(List *rtable,
52  int delta_sublevels_up, int min_sublevels_up);
53 
54 extern bool rangeTableEntry_used(Node *node, int rt_index,
55  int sublevels_up);
56 
57 extern Query *getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr);
58 
59 extern void AddQual(Query *parsetree, Node *qual);
60 extern void AddInvertedQual(Query *parsetree, Node *qual);
61 
62 extern bool contain_aggs_of_level(Node *node, int levelsup);
63 extern int locate_agg_of_level(Node *node, int levelsup);
64 extern bool contain_windowfuncs(Node *node);
65 extern int locate_windowfunc(Node *node);
66 extern bool checkExprHasSubLink(Node *node);
67 
68 extern Node *add_nulling_relids(Node *node,
69  const Bitmapset *target_relids,
70  const Bitmapset *added_relids);
71 extern Node *remove_nulling_relids(Node *node,
72  const Bitmapset *removable_relids,
73  const Bitmapset *except_relids);
74 
75 extern Node *replace_rte_variables(Node *node,
76  int target_varno, int sublevels_up,
78  void *callback_arg,
79  bool *outer_hasSubLinks);
82 
84  int target_varno, int sublevels_up,
85  const struct AttrMap *attno_map,
86  Oid to_rowtype, bool *found_whole_row);
87 
88 extern Node *ReplaceVarsFromTargetList(Node *node,
89  int target_varno, int sublevels_up,
90  RangeTblEntry *target_rte,
91  List *targetlist,
92  ReplaceVarsNoMatchOption nomatch_option,
93  int nomatch_varno,
94  bool *outer_hasSubLinks);
95 
96 #endif /* REWRITEMANIP_H */
unsigned int Oid
Definition: postgres_ext.h:31
tree context
Definition: radixtree.h:1829
bool contain_windowfuncs(Node *node)
Definition: rewriteManip.c:215
Node * ReplaceVarsFromTargetList(Node *node, int target_varno, int sublevels_up, RangeTblEntry *target_rte, List *targetlist, ReplaceVarsNoMatchOption nomatch_option, int nomatch_varno, bool *outer_hasSubLinks)
void IncrementVarSublevelsUp_rtable(List *rtable, int delta_sublevels_up, int min_sublevels_up)
Definition: rewriteManip.c:872
void ChangeVarNodes(Node *node, int rt_index, int new_index, int sublevels_up)
Definition: rewriteManip.c:674
Node * replace_rte_variables_mutator(Node *node, replace_rte_variables_context *context)
void OffsetVarNodes(Node *node, int offset, int sublevels_up)
Definition: rewriteManip.c:480
bool checkExprHasSubLink(Node *node)
Definition: rewriteManip.c:295
Query * getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr)
Definition: rewriteManip.c:998
void CombineRangeTables(List **dst_rtable, List **dst_perminfos, List *src_rtable, List *src_perminfos)
Definition: rewriteManip.c:350
void AddQual(Query *parsetree, Node *qual)
Node * remove_nulling_relids(Node *node, const Bitmapset *removable_relids, const Bitmapset *except_relids)
Node * replace_rte_variables(Node *node, int target_varno, int sublevels_up, replace_rte_variables_callback callback, void *callback_arg, bool *outer_hasSubLinks)
int locate_agg_of_level(Node *node, int levelsup)
Definition: rewriteManip.c:149
Node *(* replace_rte_variables_callback)(Var *var, replace_rte_variables_context *context)
Definition: rewriteManip.h:24
bool rangeTableEntry_used(Node *node, int rt_index, int sublevels_up)
Definition: rewriteManip.c:966
Node * map_variable_attnos(Node *node, int target_varno, int sublevels_up, const struct AttrMap *attno_map, Oid to_rowtype, bool *found_whole_row)
bool contain_aggs_of_level(Node *node, int levelsup)
Definition: rewriteManip.c:85
int locate_windowfunc(Node *node)
Definition: rewriteManip.c:253
void AddInvertedQual(Query *parsetree, Node *qual)
Node * add_nulling_relids(Node *node, const Bitmapset *target_relids, const Bitmapset *added_relids)
ReplaceVarsNoMatchOption
Definition: rewriteManip.h:37
@ REPLACEVARS_SUBSTITUTE_NULL
Definition: rewriteManip.h:40
@ REPLACEVARS_CHANGE_VARNO
Definition: rewriteManip.h:39
@ REPLACEVARS_REPORT_ERROR
Definition: rewriteManip.h:38
void IncrementVarSublevelsUp(Node *node, int delta_sublevels_up, int min_sublevels_up)
Definition: rewriteManip.c:849
Definition: attmap.h:35
Definition: pg_list.h:54
Definition: nodes.h:129
Definition: primnodes.h:248
replace_rte_variables_callback callback
Definition: rewriteManip.h:29
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:46