1 | /*------------------------------------------------------------------------- |
2 | * |
3 | * nodeFuncs.h |
4 | * Various general-purpose manipulations of PGNode trees |
5 | * |
6 | * Portions Copyright (c) 1996-2017, PostgreSQL Global Development PGGroup |
7 | * Portions Copyright (c) 1994, Regents of the University of California |
8 | * |
9 | * src/include/nodes/nodeFuncs.h |
10 | * |
11 | *------------------------------------------------------------------------- |
12 | */ |
13 | #pragma once |
14 | |
15 | #include "nodes/parsenodes.hpp" |
16 | |
17 | namespace duckdb_libpgquery { |
18 | |
19 | /* flags bits for query_tree_walker and query_tree_mutator */ |
20 | #define QTW_IGNORE_RT_SUBQUERIES 0x01 /* subqueries in rtable */ |
21 | #define QTW_IGNORE_CTE_SUBQUERIES 0x02 /* subqueries in cteList */ |
22 | #define QTW_IGNORE_RC_SUBQUERIES 0x03 /* both of above */ |
23 | #define QTW_IGNORE_JOINALIASES 0x04 /* JOIN alias var lists */ |
24 | #define QTW_IGNORE_RANGE_TABLE 0x08 /* skip rangetable entirely */ |
25 | #define QTW_EXAMINE_RTES 0x10 /* examine RTEs */ |
26 | #define QTW_DONT_COPY_QUERY 0x20 /* do not copy top PGQuery */ |
27 | |
28 | /* callback function for check_functions_in_node */ |
29 | typedef bool (*check_function_callback)(PGOid func_id, void *context); |
30 | |
31 | PGOid exprType(const PGNode *expr); |
32 | int32_t exprTypmod(const PGNode *expr); |
33 | bool exprIsLengthCoercion(const PGNode *expr, int32_t *coercedTypmod); |
34 | PGNode *relabel_to_typmod(PGNode *expr, int32_t typmod); |
35 | PGNode *strip_implicit_coercions(PGNode *node); |
36 | bool expression_returns_set(PGNode *clause); |
37 | |
38 | PGOid exprCollation(const PGNode *expr); |
39 | PGOid exprInputCollation(const PGNode *expr); |
40 | void exprSetCollation(PGNode *expr, PGOid collation); |
41 | void exprSetInputCollation(PGNode *expr, PGOid inputcollation); |
42 | |
43 | int exprLocation(const PGNode *expr); |
44 | |
45 | void fix_opfuncids(PGNode *node); |
46 | void set_opfuncid(PGOpExpr *opexpr); |
47 | void set_sa_opfuncid(PGScalarArrayOpExpr *opexpr); |
48 | |
49 | bool check_functions_in_node(PGNode *node, check_function_callback checker, void *context); |
50 | |
51 | bool expression_tree_walker(PGNode *node, bool (*walker)(), void *context); |
52 | PGNode *expression_tree_mutator(PGNode *node, PGNode *(*mutator)(), void *context); |
53 | |
54 | bool query_tree_walker(PGQuery *query, bool (*walker)(), void *context, int flags); |
55 | PGQuery *query_tree_mutator(PGQuery *query, PGNode *(*mutator)(), void *context, int flags); |
56 | |
57 | bool range_table_walker(PGList *rtable, bool (*walker)(), void *context, int flags); |
58 | PGList *range_table_mutator(PGList *rtable, PGNode *(*mutator)(), void *context, int flags); |
59 | |
60 | bool query_or_expression_tree_walker(PGNode *node, bool (*walker)(), void *context, int flags); |
61 | PGNode *query_or_expression_tree_mutator(PGNode *node, PGNode *(*mutator)(), void *context, int flags); |
62 | |
63 | bool raw_expression_tree_walker(PGNode *node, bool (*walker)(), void *context); |
64 | |
65 | struct PlanState; |
66 | bool planstate_tree_walker(struct PlanState *planstate, bool (*walker)(), void *context); |
67 | |
68 | } |
69 | |