gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

273 line
7.4KB

  1. /*-------------------------------------------------------------------------
  2. *
  3. * guc_tables.h
  4. * Declarations of tables used by GUC.
  5. *
  6. * See src/backend/utils/misc/README for design notes.
  7. *
  8. * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
  9. *
  10. * src/include/utils/guc_tables.h
  11. *
  12. *-------------------------------------------------------------------------
  13. */
  14. #ifndef GUC_TABLES_H
  15. #define GUC_TABLES_H 1
  16. #include "utils/guc.h"
  17. /*
  18. * GUC supports these types of variables:
  19. */
  20. enum config_type
  21. {
  22. PGC_BOOL,
  23. PGC_INT,
  24. PGC_REAL,
  25. PGC_STRING,
  26. PGC_ENUM
  27. };
  28. union config_var_val
  29. {
  30. bool boolval;
  31. int intval;
  32. double realval;
  33. char *stringval;
  34. int enumval;
  35. };
  36. /*
  37. * The actual value of a GUC variable can include a malloc'd opaque struct
  38. * "extra", which is created by its check_hook and used by its assign_hook.
  39. */
  40. typedef struct config_var_value
  41. {
  42. union config_var_val val;
  43. void *extra;
  44. } config_var_value;
  45. /*
  46. * Groupings to help organize all the run-time options for display
  47. */
  48. enum config_group
  49. {
  50. UNGROUPED,
  51. FILE_LOCATIONS,
  52. CONN_AUTH,
  53. CONN_AUTH_SETTINGS,
  54. CONN_AUTH_AUTH,
  55. CONN_AUTH_SSL,
  56. RESOURCES,
  57. RESOURCES_MEM,
  58. RESOURCES_DISK,
  59. RESOURCES_KERNEL,
  60. RESOURCES_VACUUM_DELAY,
  61. RESOURCES_BGWRITER,
  62. RESOURCES_ASYNCHRONOUS,
  63. WAL,
  64. WAL_SETTINGS,
  65. WAL_CHECKPOINTS,
  66. WAL_ARCHIVING,
  67. WAL_ARCHIVE_RECOVERY,
  68. WAL_RECOVERY_TARGET,
  69. REPLICATION,
  70. REPLICATION_SENDING,
  71. REPLICATION_MASTER,
  72. REPLICATION_STANDBY,
  73. REPLICATION_SUBSCRIBERS,
  74. QUERY_TUNING,
  75. QUERY_TUNING_METHOD,
  76. QUERY_TUNING_COST,
  77. QUERY_TUNING_GEQO,
  78. QUERY_TUNING_OTHER,
  79. LOGGING,
  80. LOGGING_WHERE,
  81. LOGGING_WHEN,
  82. LOGGING_WHAT,
  83. PROCESS_TITLE,
  84. STATS,
  85. STATS_MONITORING,
  86. STATS_COLLECTOR,
  87. AUTOVACUUM,
  88. CLIENT_CONN,
  89. CLIENT_CONN_STATEMENT,
  90. CLIENT_CONN_LOCALE,
  91. CLIENT_CONN_PRELOAD,
  92. CLIENT_CONN_OTHER,
  93. LOCK_MANAGEMENT,
  94. COMPAT_OPTIONS,
  95. COMPAT_OPTIONS_PREVIOUS,
  96. COMPAT_OPTIONS_CLIENT,
  97. ERROR_HANDLING_OPTIONS,
  98. PRESET_OPTIONS,
  99. CUSTOM_OPTIONS,
  100. DEVELOPER_OPTIONS
  101. };
  102. /*
  103. * Stack entry for saving the state a variable had prior to an uncommitted
  104. * transactional change
  105. */
  106. typedef enum
  107. {
  108. /* This is almost GucAction, but we need a fourth state for SET+LOCAL */
  109. GUC_SAVE, /* entry caused by function SET option */
  110. GUC_SET, /* entry caused by plain SET command */
  111. GUC_LOCAL, /* entry caused by SET LOCAL command */
  112. GUC_SET_LOCAL /* entry caused by SET then SET LOCAL */
  113. } GucStackState;
  114. typedef struct guc_stack
  115. {
  116. struct guc_stack *prev; /* previous stack item, if any */
  117. int nest_level; /* nesting depth at which we made entry */
  118. GucStackState state; /* see enum above */
  119. GucSource source; /* source of the prior value */
  120. /* masked value's source must be PGC_S_SESSION, so no need to store it */
  121. GucContext scontext; /* context that set the prior value */
  122. GucContext masked_scontext; /* context that set the masked value */
  123. config_var_value prior; /* previous value of variable */
  124. config_var_value masked; /* SET value in a GUC_SET_LOCAL entry */
  125. } GucStack;
  126. /*
  127. * Generic fields applicable to all types of variables
  128. *
  129. * The short description should be less than 80 chars in length. Some
  130. * applications may use the long description as well, and will append
  131. * it to the short description. (separated by a newline or '. ')
  132. *
  133. * Note that sourcefile/sourceline are kept here, and not pushed into stacked
  134. * values, although in principle they belong with some stacked value if the
  135. * active value is session- or transaction-local. This is to avoid bloating
  136. * stack entries. We know they are only relevant when source == PGC_S_FILE.
  137. */
  138. struct config_generic
  139. {
  140. /* constant fields, must be set correctly in initial value: */
  141. const char *name; /* name of variable - MUST BE FIRST */
  142. GucContext context; /* context required to set the variable */
  143. enum config_group group; /* to help organize variables by function */
  144. const char *short_desc; /* short desc. of this variable's purpose */
  145. const char *long_desc; /* long desc. of this variable's purpose */
  146. int flags; /* flag bits, see guc.h */
  147. /* variable fields, initialized at runtime: */
  148. enum config_type vartype; /* type of variable (set only at startup) */
  149. int status; /* status bits, see below */
  150. GucSource source; /* source of the current actual value */
  151. GucSource reset_source; /* source of the reset_value */
  152. GucContext scontext; /* context that set the current value */
  153. GucContext reset_scontext; /* context that set the reset value */
  154. GucStack *stack; /* stacked prior values */
  155. void *extra; /* "extra" pointer for current actual value */
  156. char *sourcefile; /* file current setting is from (NULL if not
  157. * set in config file) */
  158. int sourceline; /* line in source file */
  159. };
  160. /* bit values in status field */
  161. #define GUC_IS_IN_FILE 0x0001 /* found it in config file */
  162. /*
  163. * Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
  164. * Do not assume that its value represents useful information elsewhere.
  165. */
  166. #define GUC_PENDING_RESTART 0x0002
  167. /* GUC records for specific variable types */
  168. struct config_bool
  169. {
  170. struct config_generic gen;
  171. /* constant fields, must be set correctly in initial value: */
  172. bool *variable;
  173. bool boot_val;
  174. GucBoolCheckHook check_hook;
  175. GucBoolAssignHook assign_hook;
  176. GucShowHook show_hook;
  177. /* variable fields, initialized at runtime: */
  178. bool reset_val;
  179. void *reset_extra;
  180. };
  181. struct config_int
  182. {
  183. struct config_generic gen;
  184. /* constant fields, must be set correctly in initial value: */
  185. int *variable;
  186. int boot_val;
  187. int min;
  188. int max;
  189. GucIntCheckHook check_hook;
  190. GucIntAssignHook assign_hook;
  191. GucShowHook show_hook;
  192. /* variable fields, initialized at runtime: */
  193. int reset_val;
  194. void *reset_extra;
  195. };
  196. struct config_real
  197. {
  198. struct config_generic gen;
  199. /* constant fields, must be set correctly in initial value: */
  200. double *variable;
  201. double boot_val;
  202. double min;
  203. double max;
  204. GucRealCheckHook check_hook;
  205. GucRealAssignHook assign_hook;
  206. GucShowHook show_hook;
  207. /* variable fields, initialized at runtime: */
  208. double reset_val;
  209. void *reset_extra;
  210. };
  211. struct config_string
  212. {
  213. struct config_generic gen;
  214. /* constant fields, must be set correctly in initial value: */
  215. char **variable;
  216. const char *boot_val;
  217. GucStringCheckHook check_hook;
  218. GucStringAssignHook assign_hook;
  219. GucShowHook show_hook;
  220. /* variable fields, initialized at runtime: */
  221. char *reset_val;
  222. void *reset_extra;
  223. };
  224. struct config_enum
  225. {
  226. struct config_generic gen;
  227. /* constant fields, must be set correctly in initial value: */
  228. int *variable;
  229. int boot_val;
  230. const struct config_enum_entry *options;
  231. GucEnumCheckHook check_hook;
  232. GucEnumAssignHook assign_hook;
  233. GucShowHook show_hook;
  234. /* variable fields, initialized at runtime: */
  235. int reset_val;
  236. void *reset_extra;
  237. };
  238. /* constant tables corresponding to enums above and in guc.h */
  239. extern const char *const config_group_names[];
  240. extern const char *const config_type_names[];
  241. extern const char *const GucContext_Names[];
  242. extern const char *const GucSource_Names[];
  243. /* get the current set of variables */
  244. extern struct config_generic **get_guc_variables(void);
  245. extern void build_guc_variables(void);
  246. /* search in enum options */
  247. extern const char *config_enum_lookup_by_value(struct config_enum *record, int val);
  248. extern bool config_enum_lookup_by_name(struct config_enum *record,
  249. const char *value, int *retval);
  250. extern struct config_generic **get_explain_guc_options(int *num);
  251. #endif /* GUC_TABLES_H */
上海开阖软件有限公司 沪ICP备12045867号-1