1 /*-------------------------------------------------------------------------
4 * Declarations of tables used by GUC.
6 * See src/backend/utils/misc/README for design notes.
8 * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
10 * src/include/utils/guc_tables.h
12 *-------------------------------------------------------------------------
15 #define GUC_TABLES_H 1
17 #include "utils/guc.h"
20 * GUC supports these types of variables:
41 * The actual value of a GUC variable can include a malloc'd opaque struct
42 * "extra", which is created by its check_hook and used by its assign_hook.
44 typedef struct config_var_value
46 union config_var_val val;
51 * Groupings to help organize all the run-time options for display
65 RESOURCES_VACUUM_DELAY,
67 RESOURCES_ASYNCHRONOUS,
76 REPLICATION_SUBSCRIBERS,
92 CLIENT_CONN_STATEMENT,
98 COMPAT_OPTIONS_PREVIOUS,
99 COMPAT_OPTIONS_CLIENT,
100 ERROR_HANDLING_OPTIONS,
107 * Stack entry for saving the state a variable had prior to an uncommitted
108 * transactional change
112 /* This is almost GucAction, but we need a fourth state for SET+LOCAL */
113 GUC_SAVE, /* entry caused by function SET option */
114 GUC_SET, /* entry caused by plain SET command */
115 GUC_LOCAL, /* entry caused by SET LOCAL command */
116 GUC_SET_LOCAL /* entry caused by SET then SET LOCAL */
119 typedef struct guc_stack
121 struct guc_stack *prev; /* previous stack item, if any */
122 int nest_level; /* nesting depth at which we made entry */
123 GucStackState state; /* see enum above */
124 GucSource source; /* source of the prior value */
125 /* masked value's source must be PGC_S_SESSION, so no need to store it */
126 GucContext scontext; /* context that set the prior value */
127 GucContext masked_scontext; /* context that set the masked value */
128 config_var_value prior; /* previous value of variable */
129 config_var_value masked; /* SET value in a GUC_SET_LOCAL entry */
133 * Generic fields applicable to all types of variables
135 * The short description should be less than 80 chars in length. Some
136 * applications may use the long description as well, and will append
137 * it to the short description. (separated by a newline or '. ')
139 * Note that sourcefile/sourceline are kept here, and not pushed into stacked
140 * values, although in principle they belong with some stacked value if the
141 * active value is session- or transaction-local. This is to avoid bloating
142 * stack entries. We know they are only relevant when source == PGC_S_FILE.
144 struct config_generic
146 /* constant fields, must be set correctly in initial value: */
147 const char *name; /* name of variable - MUST BE FIRST */
148 GucContext context; /* context required to set the variable */
149 enum config_group group; /* to help organize variables by function */
150 const char *short_desc; /* short desc. of this variable's purpose */
151 const char *long_desc; /* long desc. of this variable's purpose */
152 int flags; /* flag bits, see guc.h */
153 /* variable fields, initialized at runtime: */
154 enum config_type vartype; /* type of variable (set only at startup) */
155 int status; /* status bits, see below */
156 GucSource source; /* source of the current actual value */
157 GucSource reset_source; /* source of the reset_value */
158 GucContext scontext; /* context that set the current value */
159 GucContext reset_scontext; /* context that set the reset value */
160 GucStack *stack; /* stacked prior values */
161 void *extra; /* "extra" pointer for current actual value */
162 char *sourcefile; /* file current setting is from (NULL if not
163 * set in config file) */
164 int sourceline; /* line in source file */
167 /* bit values in status field */
168 #define GUC_IS_IN_FILE 0x0001 /* found it in config file */
170 * Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
171 * Do not assume that its value represents useful information elsewhere.
173 #define GUC_PENDING_RESTART 0x0002
176 /* GUC records for specific variable types */
180 struct config_generic gen;
181 /* constant fields, must be set correctly in initial value: */
184 GucBoolCheckHook check_hook;
185 GucBoolAssignHook assign_hook;
186 GucShowHook show_hook;
187 /* variable fields, initialized at runtime: */
194 struct config_generic gen;
195 /* constant fields, must be set correctly in initial value: */
200 GucIntCheckHook check_hook;
201 GucIntAssignHook assign_hook;
202 GucShowHook show_hook;
203 /* variable fields, initialized at runtime: */
210 struct config_generic gen;
211 /* constant fields, must be set correctly in initial value: */
216 GucRealCheckHook check_hook;
217 GucRealAssignHook assign_hook;
218 GucShowHook show_hook;
219 /* variable fields, initialized at runtime: */
226 struct config_generic gen;
227 /* constant fields, must be set correctly in initial value: */
229 const char *boot_val;
230 GucStringCheckHook check_hook;
231 GucStringAssignHook assign_hook;
232 GucShowHook show_hook;
233 /* variable fields, initialized at runtime: */
240 struct config_generic gen;
241 /* constant fields, must be set correctly in initial value: */
244 const struct config_enum_entry *options;
245 GucEnumCheckHook check_hook;
246 GucEnumAssignHook assign_hook;
247 GucShowHook show_hook;
248 /* variable fields, initialized at runtime: */
253 /* constant tables corresponding to enums above and in guc.h */
254 extern const char *const config_group_names[];
255 extern const char *const config_type_names[];
256 extern const char *const GucContext_Names[];
257 extern const char *const GucSource_Names[];
259 /* get the current set of variables */
260 extern struct config_generic **get_guc_variables(void);
262 extern void build_guc_variables(void);
264 /* search in enum options */
265 extern const char *config_enum_lookup_by_value(struct config_enum *record, int val);
266 extern bool config_enum_lookup_by_name(struct config_enum *record,
267 const char *value, int *retval);
269 #endif /* GUC_TABLES_H */