gooderp18绿色标准版
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

160 行
4.8KB

  1. /*-------------------------------------------------------------------------
  2. *
  3. * nodeFuncs.h
  4. * Various general-purpose manipulations of Node trees
  5. *
  6. * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
  7. * Portions Copyright (c) 1994, Regents of the University of California
  8. *
  9. * src/include/nodes/nodeFuncs.h
  10. *
  11. *-------------------------------------------------------------------------
  12. */
  13. #ifndef NODEFUNCS_H
  14. #define NODEFUNCS_H
  15. #include "nodes/parsenodes.h"
  16. /* flags bits for query_tree_walker and query_tree_mutator */
  17. #define QTW_IGNORE_RT_SUBQUERIES 0x01 /* subqueries in rtable */
  18. #define QTW_IGNORE_CTE_SUBQUERIES 0x02 /* subqueries in cteList */
  19. #define QTW_IGNORE_RC_SUBQUERIES 0x03 /* both of above */
  20. #define QTW_IGNORE_JOINALIASES 0x04 /* JOIN alias var lists */
  21. #define QTW_IGNORE_RANGE_TABLE 0x08 /* skip rangetable entirely */
  22. #define QTW_EXAMINE_RTES_BEFORE 0x10 /* examine RTE nodes before their
  23. * contents */
  24. #define QTW_EXAMINE_RTES_AFTER 0x20 /* examine RTE nodes after their
  25. * contents */
  26. #define QTW_DONT_COPY_QUERY 0x40 /* do not copy top Query */
  27. #define QTW_EXAMINE_SORTGROUP 0x80 /* include SortGroupNode lists */
  28. /* callback function for check_functions_in_node */
  29. typedef bool (*check_function_callback) (Oid func_id, void *context);
  30. extern Oid exprType(const Node *expr);
  31. extern int32 exprTypmod(const Node *expr);
  32. extern bool exprIsLengthCoercion(const Node *expr, int32 *coercedTypmod);
  33. extern Node *relabel_to_typmod(Node *expr, int32 typmod);
  34. extern Node *strip_implicit_coercions(Node *node);
  35. extern bool expression_returns_set(Node *clause);
  36. extern Oid exprCollation(const Node *expr);
  37. extern Oid exprInputCollation(const Node *expr);
  38. extern void exprSetCollation(Node *expr, Oid collation);
  39. extern void exprSetInputCollation(Node *expr, Oid inputcollation);
  40. extern int exprLocation(const Node *expr);
  41. extern void fix_opfuncids(Node *node);
  42. extern void set_opfuncid(OpExpr *opexpr);
  43. extern void set_sa_opfuncid(ScalarArrayOpExpr *opexpr);
  44. /* Is clause a FuncExpr clause? */
  45. static inline bool
  46. is_funcclause(const void *clause)
  47. {
  48. return clause != NULL && IsA(clause, FuncExpr);
  49. }
  50. /* Is clause an OpExpr clause? */
  51. static inline bool
  52. is_opclause(const void *clause)
  53. {
  54. return clause != NULL && IsA(clause, OpExpr);
  55. }
  56. /* Extract left arg of a binary opclause, or only arg of a unary opclause */
  57. static inline Node *
  58. get_leftop(const void *clause)
  59. {
  60. const OpExpr *expr = (const OpExpr *) clause;
  61. if (expr->args != NIL)
  62. return (Node *) linitial(expr->args);
  63. else
  64. return NULL;
  65. }
  66. /* Extract right arg of a binary opclause (NULL if it's a unary opclause) */
  67. static inline Node *
  68. get_rightop(const void *clause)
  69. {
  70. const OpExpr *expr = (const OpExpr *) clause;
  71. if (list_length(expr->args) >= 2)
  72. return (Node *) lsecond(expr->args);
  73. else
  74. return NULL;
  75. }
  76. /* Is clause an AND clause? */
  77. static inline bool
  78. is_andclause(const void *clause)
  79. {
  80. return (clause != NULL &&
  81. IsA(clause, BoolExpr) &&
  82. ((const BoolExpr *) clause)->boolop == AND_EXPR);
  83. }
  84. /* Is clause an OR clause? */
  85. static inline bool
  86. is_orclause(const void *clause)
  87. {
  88. return (clause != NULL &&
  89. IsA(clause, BoolExpr) &&
  90. ((const BoolExpr *) clause)->boolop == OR_EXPR);
  91. }
  92. /* Is clause a NOT clause? */
  93. static inline bool
  94. is_notclause(const void *clause)
  95. {
  96. return (clause != NULL &&
  97. IsA(clause, BoolExpr) &&
  98. ((const BoolExpr *) clause)->boolop == NOT_EXPR);
  99. }
  100. /* Extract argument from a clause known to be a NOT clause */
  101. static inline Expr *
  102. get_notclausearg(const void *notclause)
  103. {
  104. return (Expr *) linitial(((const BoolExpr *) notclause)->args);
  105. }
  106. extern bool check_functions_in_node(Node *node, check_function_callback checker,
  107. void *context);
  108. extern bool expression_tree_walker(Node *node, bool (*walker) (),
  109. void *context);
  110. extern Node *expression_tree_mutator(Node *node, Node *(*mutator) (),
  111. void *context);
  112. extern bool query_tree_walker(Query *query, bool (*walker) (),
  113. void *context, int flags);
  114. extern Query *query_tree_mutator(Query *query, Node *(*mutator) (),
  115. void *context, int flags);
  116. extern bool range_table_walker(List *rtable, bool (*walker) (),
  117. void *context, int flags);
  118. extern List *range_table_mutator(List *rtable, Node *(*mutator) (),
  119. void *context, int flags);
  120. extern bool range_table_entry_walker(RangeTblEntry *rte, bool (*walker) (),
  121. void *context, int flags);
  122. extern bool query_or_expression_tree_walker(Node *node, bool (*walker) (),
  123. void *context, int flags);
  124. extern Node *query_or_expression_tree_mutator(Node *node, Node *(*mutator) (),
  125. void *context, int flags);
  126. extern bool raw_expression_tree_walker(Node *node, bool (*walker) (),
  127. void *context);
  128. struct PlanState;
  129. extern bool planstate_tree_walker(struct PlanState *planstate, bool (*walker) (),
  130. void *context);
  131. #endif /* NODEFUNCS_H */
上海开阖软件有限公司 沪ICP备12045867号-1