| 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 |  | 
|---|
| 18 | /* flags bits for query_tree_walker and query_tree_mutator */ | 
|---|
| 19 | #define QTW_IGNORE_RT_SUBQUERIES	0x01	/* subqueries in rtable */ | 
|---|
| 20 | #define QTW_IGNORE_CTE_SUBQUERIES	0x02	/* subqueries in cteList */ | 
|---|
| 21 | #define QTW_IGNORE_RC_SUBQUERIES	0x03	/* both of above */ | 
|---|
| 22 | #define QTW_IGNORE_JOINALIASES		0x04	/* JOIN alias var lists */ | 
|---|
| 23 | #define QTW_IGNORE_RANGE_TABLE		0x08	/* skip rangetable entirely */ | 
|---|
| 24 | #define QTW_EXAMINE_RTES			0x10	/* examine RTEs */ | 
|---|
| 25 | #define QTW_DONT_COPY_QUERY			0x20	/* do not copy top PGQuery */ | 
|---|
| 26 |  | 
|---|
| 27 | /* callback function for check_functions_in_node */ | 
|---|
| 28 | typedef bool (*check_function_callback) (PGOid func_id, void *context); | 
|---|
| 29 |  | 
|---|
| 30 |  | 
|---|
| 31 | extern PGOid	exprType(const PGNode *expr); | 
|---|
| 32 | extern int32_t exprTypmod(const PGNode *expr); | 
|---|
| 33 | extern bool exprIsLengthCoercion(const PGNode *expr, int32_t *coercedTypmod); | 
|---|
| 34 | extern PGNode *relabel_to_typmod(PGNode *expr, int32_t typmod); | 
|---|
| 35 | extern PGNode *strip_implicit_coercions(PGNode *node); | 
|---|
| 36 | extern bool expression_returns_set(PGNode *clause); | 
|---|
| 37 |  | 
|---|
| 38 | extern PGOid	exprCollation(const PGNode *expr); | 
|---|
| 39 | extern PGOid	exprInputCollation(const PGNode *expr); | 
|---|
| 40 | extern void exprSetCollation(PGNode *expr, PGOid collation); | 
|---|
| 41 | extern void exprSetInputCollation(PGNode *expr, PGOid inputcollation); | 
|---|
| 42 |  | 
|---|
| 43 | extern int	exprLocation(const PGNode *expr); | 
|---|
| 44 |  | 
|---|
| 45 | extern void fix_opfuncids(PGNode *node); | 
|---|
| 46 | extern void set_opfuncid(PGOpExpr *opexpr); | 
|---|
| 47 | extern void set_sa_opfuncid(PGScalarArrayOpExpr *opexpr); | 
|---|
| 48 |  | 
|---|
| 49 | extern bool check_functions_in_node(PGNode *node, check_function_callback checker, | 
|---|
| 50 | void *context); | 
|---|
| 51 |  | 
|---|
| 52 | extern bool expression_tree_walker(PGNode *node, bool (*walker) (), | 
|---|
| 53 | void *context); | 
|---|
| 54 | extern PGNode *expression_tree_mutator(PGNode *node, PGNode *(*mutator) (), | 
|---|
| 55 | void *context); | 
|---|
| 56 |  | 
|---|
| 57 | extern bool query_tree_walker(PGQuery *query, bool (*walker) (), | 
|---|
| 58 | void *context, int flags); | 
|---|
| 59 | extern PGQuery *query_tree_mutator(PGQuery *query, PGNode *(*mutator) (), | 
|---|
| 60 | void *context, int flags); | 
|---|
| 61 |  | 
|---|
| 62 | extern bool range_table_walker(PGList *rtable, bool (*walker) (), | 
|---|
| 63 | void *context, int flags); | 
|---|
| 64 | extern PGList *range_table_mutator(PGList *rtable, PGNode *(*mutator) (), | 
|---|
| 65 | void *context, int flags); | 
|---|
| 66 |  | 
|---|
| 67 | extern bool query_or_expression_tree_walker(PGNode *node, bool (*walker) (), | 
|---|
| 68 | void *context, int flags); | 
|---|
| 69 | extern PGNode *query_or_expression_tree_mutator(PGNode *node, PGNode *(*mutator) (), | 
|---|
| 70 | void *context, int flags); | 
|---|
| 71 |  | 
|---|
| 72 | extern bool raw_expression_tree_walker(PGNode *node, bool (*walker) (), | 
|---|
| 73 | void *context); | 
|---|
| 74 |  | 
|---|
| 75 | struct PlanState; | 
|---|
| 76 | extern bool planstate_tree_walker(struct PlanState *planstate, bool (*walker) (), | 
|---|
| 77 | void *context); | 
|---|
| 78 |  | 
|---|
| 79 |  | 
|---|