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

190 行
6.4KB

  1. /*-------------------------------------------------------------------------
  2. *
  3. * optimizer.h
  4. * External API for the Postgres planner.
  5. *
  6. * This header is meant to define everything that the core planner
  7. * exposes for use by non-planner modules.
  8. *
  9. * Note that there are files outside src/backend/optimizer/ that are
  10. * considered planner modules, because they're too much in bed with
  11. * planner operations to be treated otherwise. FDW planning code is an
  12. * example. For the most part, however, code outside the core planner
  13. * should not need to include any optimizer/ header except this one.
  14. *
  15. * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
  16. * Portions Copyright (c) 1994, Regents of the University of California
  17. *
  18. * src/include/optimizer/optimizer.h
  19. *
  20. *-------------------------------------------------------------------------
  21. */
  22. #ifndef OPTIMIZER_H
  23. #define OPTIMIZER_H
  24. #include "nodes/parsenodes.h"
  25. /*
  26. * We don't want to include nodes/pathnodes.h here, because non-planner
  27. * code should generally treat PlannerInfo as an opaque typedef.
  28. * But we'd like such code to use that typedef name, so define the
  29. * typedef either here or in pathnodes.h, whichever is read first.
  30. */
  31. #ifndef HAVE_PLANNERINFO_TYPEDEF
  32. typedef struct PlannerInfo PlannerInfo;
  33. #define HAVE_PLANNERINFO_TYPEDEF 1
  34. #endif
  35. /* Likewise for IndexOptInfo and SpecialJoinInfo. */
  36. #ifndef HAVE_INDEXOPTINFO_TYPEDEF
  37. typedef struct IndexOptInfo IndexOptInfo;
  38. #define HAVE_INDEXOPTINFO_TYPEDEF 1
  39. #endif
  40. #ifndef HAVE_SPECIALJOININFO_TYPEDEF
  41. typedef struct SpecialJoinInfo SpecialJoinInfo;
  42. #define HAVE_SPECIALJOININFO_TYPEDEF 1
  43. #endif
  44. /* It also seems best not to include plannodes.h, params.h, or htup.h here */
  45. struct PlannedStmt;
  46. struct ParamListInfoData;
  47. struct HeapTupleData;
  48. /* in path/clausesel.c: */
  49. extern Selectivity clause_selectivity(PlannerInfo *root,
  50. Node *clause,
  51. int varRelid,
  52. JoinType jointype,
  53. SpecialJoinInfo *sjinfo);
  54. extern Selectivity clauselist_selectivity_simple(PlannerInfo *root,
  55. List *clauses,
  56. int varRelid,
  57. JoinType jointype,
  58. SpecialJoinInfo *sjinfo,
  59. Bitmapset *estimatedclauses);
  60. extern Selectivity clauselist_selectivity(PlannerInfo *root,
  61. List *clauses,
  62. int varRelid,
  63. JoinType jointype,
  64. SpecialJoinInfo *sjinfo);
  65. /* in path/costsize.c: */
  66. /* widely used cost parameters */
  67. extern PGDLLIMPORT double seq_page_cost;
  68. extern PGDLLIMPORT double random_page_cost;
  69. extern PGDLLIMPORT double cpu_tuple_cost;
  70. extern PGDLLIMPORT double cpu_index_tuple_cost;
  71. extern PGDLLIMPORT double cpu_operator_cost;
  72. extern PGDLLIMPORT double parallel_tuple_cost;
  73. extern PGDLLIMPORT double parallel_setup_cost;
  74. extern PGDLLIMPORT int effective_cache_size;
  75. extern double clamp_row_est(double nrows);
  76. /* in path/indxpath.c: */
  77. extern bool is_pseudo_constant_for_index(Node *expr, IndexOptInfo *index);
  78. /* in plan/planner.c: */
  79. /* possible values for force_parallel_mode */
  80. typedef enum
  81. {
  82. FORCE_PARALLEL_OFF,
  83. FORCE_PARALLEL_ON,
  84. FORCE_PARALLEL_REGRESS
  85. } ForceParallelMode;
  86. /* GUC parameters */
  87. extern int force_parallel_mode;
  88. extern bool parallel_leader_participation;
  89. extern struct PlannedStmt *planner(Query *parse, int cursorOptions,
  90. struct ParamListInfoData *boundParams);
  91. extern Expr *expression_planner(Expr *expr);
  92. extern Expr *expression_planner_with_deps(Expr *expr,
  93. List **relationOids,
  94. List **invalItems);
  95. extern bool plan_cluster_use_sort(Oid tableOid, Oid indexOid);
  96. extern int plan_create_index_workers(Oid tableOid, Oid indexOid);
  97. /* in plan/setrefs.c: */
  98. extern void extract_query_dependencies(Node *query,
  99. List **relationOids,
  100. List **invalItems,
  101. bool *hasRowSecurity);
  102. /* in prep/prepqual.c: */
  103. extern Node *negate_clause(Node *node);
  104. extern Expr *canonicalize_qual(Expr *qual, bool is_check);
  105. /* in util/clauses.c: */
  106. extern bool contain_mutable_functions(Node *clause);
  107. extern bool contain_volatile_functions(Node *clause);
  108. extern bool contain_volatile_functions_not_nextval(Node *clause);
  109. extern Node *eval_const_expressions(PlannerInfo *root, Node *node);
  110. extern Node *estimate_expression_value(PlannerInfo *root, Node *node);
  111. extern Expr *evaluate_expr(Expr *expr, Oid result_type, int32 result_typmod,
  112. Oid result_collation);
  113. extern List *expand_function_arguments(List *args, Oid result_type,
  114. struct HeapTupleData *func_tuple);
  115. /* in util/predtest.c: */
  116. extern bool predicate_implied_by(List *predicate_list, List *clause_list,
  117. bool weak);
  118. extern bool predicate_refuted_by(List *predicate_list, List *clause_list,
  119. bool weak);
  120. /* in util/tlist.c: */
  121. extern int count_nonjunk_tlist_entries(List *tlist);
  122. extern TargetEntry *get_sortgroupref_tle(Index sortref,
  123. List *targetList);
  124. extern TargetEntry *get_sortgroupclause_tle(SortGroupClause *sgClause,
  125. List *targetList);
  126. extern Node *get_sortgroupclause_expr(SortGroupClause *sgClause,
  127. List *targetList);
  128. extern List *get_sortgrouplist_exprs(List *sgClauses,
  129. List *targetList);
  130. extern SortGroupClause *get_sortgroupref_clause(Index sortref,
  131. List *clauses);
  132. extern SortGroupClause *get_sortgroupref_clause_noerr(Index sortref,
  133. List *clauses);
  134. /* in util/var.c: */
  135. /* Bits that can be OR'd into the flags argument of pull_var_clause() */
  136. #define PVC_INCLUDE_AGGREGATES 0x0001 /* include Aggrefs in output list */
  137. #define PVC_RECURSE_AGGREGATES 0x0002 /* recurse into Aggref arguments */
  138. #define PVC_INCLUDE_WINDOWFUNCS 0x0004 /* include WindowFuncs in output list */
  139. #define PVC_RECURSE_WINDOWFUNCS 0x0008 /* recurse into WindowFunc arguments */
  140. #define PVC_INCLUDE_PLACEHOLDERS 0x0010 /* include PlaceHolderVars in
  141. * output list */
  142. #define PVC_RECURSE_PLACEHOLDERS 0x0020 /* recurse into PlaceHolderVar
  143. * arguments */
  144. extern Bitmapset *pull_varnos(Node *node);
  145. extern Bitmapset *pull_varnos_of_level(Node *node, int levelsup);
  146. extern void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos);
  147. extern List *pull_vars_of_level(Node *node, int levelsup);
  148. extern bool contain_var_clause(Node *node);
  149. extern bool contain_vars_of_level(Node *node, int levelsup);
  150. extern int locate_var_of_level(Node *node, int levelsup);
  151. extern List *pull_var_clause(Node *node, int flags);
  152. extern Node *flatten_join_alias_vars(Query *query, Node *node);
  153. #endif /* OPTIMIZER_H */
上海开阖软件有限公司 沪ICP备12045867号-1