guc_tables.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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-2016, 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_SECURITY,
  55. RESOURCES,
  56. RESOURCES_MEM,
  57. RESOURCES_DISK,
  58. RESOURCES_KERNEL,
  59. RESOURCES_VACUUM_DELAY,
  60. RESOURCES_BGWRITER,
  61. RESOURCES_ASYNCHRONOUS,
  62. WAL,
  63. WAL_SETTINGS,
  64. WAL_CHECKPOINTS,
  65. WAL_ARCHIVING,
  66. REPLICATION,
  67. REPLICATION_SENDING,
  68. REPLICATION_MASTER,
  69. REPLICATION_STANDBY,
  70. QUERY_TUNING,
  71. QUERY_TUNING_METHOD,
  72. QUERY_TUNING_COST,
  73. QUERY_TUNING_GEQO,
  74. QUERY_TUNING_OTHER,
  75. LOGGING,
  76. LOGGING_WHERE,
  77. LOGGING_WHEN,
  78. LOGGING_WHAT,
  79. PROCESS_TITLE,
  80. STATS,
  81. STATS_MONITORING,
  82. STATS_COLLECTOR,
  83. AUTOVACUUM,
  84. CLIENT_CONN,
  85. CLIENT_CONN_STATEMENT,
  86. CLIENT_CONN_LOCALE,
  87. CLIENT_CONN_PRELOAD,
  88. CLIENT_CONN_OTHER,
  89. LOCK_MANAGEMENT,
  90. COMPAT_OPTIONS,
  91. COMPAT_OPTIONS_PREVIOUS,
  92. COMPAT_OPTIONS_CLIENT,
  93. ERROR_HANDLING_OPTIONS,
  94. PRESET_OPTIONS,
  95. CUSTOM_OPTIONS,
  96. DEVELOPER_OPTIONS
  97. };
  98. /*
  99. * Stack entry for saving the state a variable had prior to an uncommitted
  100. * transactional change
  101. */
  102. typedef enum
  103. {
  104. /* This is almost GucAction, but we need a fourth state for SET+LOCAL */
  105. GUC_SAVE, /* entry caused by function SET option */
  106. GUC_SET, /* entry caused by plain SET command */
  107. GUC_LOCAL, /* entry caused by SET LOCAL command */
  108. GUC_SET_LOCAL /* entry caused by SET then SET LOCAL */
  109. } GucStackState;
  110. typedef struct guc_stack
  111. {
  112. struct guc_stack *prev; /* previous stack item, if any */
  113. int nest_level; /* nesting depth at which we made entry */
  114. GucStackState state; /* see enum above */
  115. GucSource source; /* source of the prior value */
  116. /* masked value's source must be PGC_S_SESSION, so no need to store it */
  117. GucContext scontext; /* context that set the prior value */
  118. GucContext masked_scontext; /* context that set the masked value */
  119. config_var_value prior; /* previous value of variable */
  120. config_var_value masked; /* SET value in a GUC_SET_LOCAL entry */
  121. } GucStack;
  122. /*
  123. * Generic fields applicable to all types of variables
  124. *
  125. * The short description should be less than 80 chars in length. Some
  126. * applications may use the long description as well, and will append
  127. * it to the short description. (separated by a newline or '. ')
  128. *
  129. * Note that sourcefile/sourceline are kept here, and not pushed into stacked
  130. * values, although in principle they belong with some stacked value if the
  131. * active value is session- or transaction-local. This is to avoid bloating
  132. * stack entries. We know they are only relevant when source == PGC_S_FILE.
  133. */
  134. struct config_generic
  135. {
  136. /* constant fields, must be set correctly in initial value: */
  137. const char *name; /* name of variable - MUST BE FIRST */
  138. GucContext context; /* context required to set the variable */
  139. enum config_group group; /* to help organize variables by function */
  140. const char *short_desc; /* short desc. of this variable's purpose */
  141. const char *long_desc; /* long desc. of this variable's purpose */
  142. int flags; /* flag bits, see guc.h */
  143. /* variable fields, initialized at runtime: */
  144. enum config_type vartype; /* type of variable (set only at startup) */
  145. int status; /* status bits, see below */
  146. GucSource source; /* source of the current actual value */
  147. GucSource reset_source; /* source of the reset_value */
  148. GucContext scontext; /* context that set the current value */
  149. GucContext reset_scontext; /* context that set the reset value */
  150. GucStack *stack; /* stacked prior values */
  151. void *extra; /* "extra" pointer for current actual value */
  152. char *sourcefile; /* file current setting is from (NULL if not
  153. * set in config file) */
  154. int sourceline; /* line in source file */
  155. };
  156. /* bit values in status field */
  157. #define GUC_IS_IN_FILE 0x0001 /* found it in config file */
  158. /*
  159. * Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
  160. * Do not assume that its value represents useful information elsewhere.
  161. */
  162. #define GUC_PENDING_RESTART 0x0002
  163. /* GUC records for specific variable types */
  164. struct config_bool
  165. {
  166. struct config_generic gen;
  167. /* constant fields, must be set correctly in initial value: */
  168. bool *variable;
  169. bool boot_val;
  170. GucBoolCheckHook check_hook;
  171. GucBoolAssignHook assign_hook;
  172. GucShowHook show_hook;
  173. /* variable fields, initialized at runtime: */
  174. bool reset_val;
  175. void *reset_extra;
  176. };
  177. struct config_int
  178. {
  179. struct config_generic gen;
  180. /* constant fields, must be set correctly in initial value: */
  181. int *variable;
  182. int boot_val;
  183. int min;
  184. int max;
  185. GucIntCheckHook check_hook;
  186. GucIntAssignHook assign_hook;
  187. GucShowHook show_hook;
  188. /* variable fields, initialized at runtime: */
  189. int reset_val;
  190. void *reset_extra;
  191. };
  192. struct config_real
  193. {
  194. struct config_generic gen;
  195. /* constant fields, must be set correctly in initial value: */
  196. double *variable;
  197. double boot_val;
  198. double min;
  199. double max;
  200. GucRealCheckHook check_hook;
  201. GucRealAssignHook assign_hook;
  202. GucShowHook show_hook;
  203. /* variable fields, initialized at runtime: */
  204. double reset_val;
  205. void *reset_extra;
  206. };
  207. struct config_string
  208. {
  209. struct config_generic gen;
  210. /* constant fields, must be set correctly in initial value: */
  211. char **variable;
  212. const char *boot_val;
  213. GucStringCheckHook check_hook;
  214. GucStringAssignHook assign_hook;
  215. GucShowHook show_hook;
  216. /* variable fields, initialized at runtime: */
  217. char *reset_val;
  218. void *reset_extra;
  219. };
  220. struct config_enum
  221. {
  222. struct config_generic gen;
  223. /* constant fields, must be set correctly in initial value: */
  224. int *variable;
  225. int boot_val;
  226. const struct config_enum_entry *options;
  227. GucEnumCheckHook check_hook;
  228. GucEnumAssignHook assign_hook;
  229. GucShowHook show_hook;
  230. /* variable fields, initialized at runtime: */
  231. int reset_val;
  232. void *reset_extra;
  233. };
  234. /* constant tables corresponding to enums above and in guc.h */
  235. extern const char *const config_group_names[];
  236. extern const char *const config_type_names[];
  237. extern const char *const GucContext_Names[];
  238. extern const char *const GucSource_Names[];
  239. /* get the current set of variables */
  240. extern struct config_generic **get_guc_variables(void);
  241. extern void build_guc_variables(void);
  242. /* search in enum options */
  243. extern const char *config_enum_lookup_by_value(struct config_enum * record, int val);
  244. extern bool config_enum_lookup_by_name(struct config_enum * record,
  245. const char *value, int *retval);
  246. #endif /* GUC_TABLES_H */