1 /*-------------------------------------------------------------------------
4 * Declarations of tables used by GUC.
6 * See src/backend/utils/misc/README for design notes.
8 * Portions Copyright (c) 1996-2012, 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
64 RESOURCES_VACUUM_DELAY,
66 RESOURCES_ASYNCHRONOUS,
89 CLIENT_CONN_STATEMENT,
94 COMPAT_OPTIONS_PREVIOUS,
95 COMPAT_OPTIONS_CLIENT,
96 ERROR_HANDLING_OPTIONS,
103 * Stack entry for saving the state a variable had prior to an uncommitted
104 * transactional change
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 */
115 typedef struct guc_stack
117 struct guc_stack *prev; /* previous stack item, if any */
118 int nest_level; /* nesting depth at which we made entry */
119 GucStackState state; /* see enum above */
120 GucSource source; /* source of the prior value */
121 /* masked value's source must be PGC_S_SESSION, so no need to store it */
122 GucContext scontext; /* context that set the prior value */
123 GucContext masked_scontext; /* context that set the masked value */
124 config_var_value prior; /* previous value of variable */
125 config_var_value masked; /* SET value in a GUC_SET_LOCAL entry */
129 * Generic fields applicable to all types of variables
131 * The short description should be less than 80 chars in length. Some
132 * applications may use the long description as well, and will append
133 * it to the short description. (separated by a newline or '. ')
135 * Note that sourcefile/sourceline are kept here, and not pushed into stacked
136 * values, although in principle they belong with some stacked value if the
137 * active value is session- or transaction-local. This is to avoid bloating
138 * stack entries. We know they are only relevant when source == PGC_S_FILE.
140 struct config_generic
142 /* constant fields, must be set correctly in initial value: */
143 const char *name; /* name of variable - MUST BE FIRST */
144 GucContext context; /* context required to set the variable */
145 enum config_group group; /* to help organize variables by function */
146 const char *short_desc; /* short desc. of this variable's purpose */
147 const char *long_desc; /* long desc. of this variable's purpose */
148 int flags; /* flag bits, see guc.h */
149 /* variable fields, initialized at runtime: */
150 enum config_type vartype; /* type of variable (set only at startup) */
151 int status; /* status bits, see below */
152 GucSource source; /* source of the current actual value */
153 GucSource reset_source; /* source of the reset_value */
154 GucContext scontext; /* context that set the current value */
155 GucContext reset_scontext; /* context that set the reset value */
156 GucStack *stack; /* stacked prior values */
157 void *extra; /* "extra" pointer for current actual value */
158 char *sourcefile; /* file current setting is from (NULL if not
159 * set in config file) */
160 int sourceline; /* line in source file */
163 /* bit values in status field */
164 #define GUC_IS_IN_FILE 0x0001 /* found it in config file */
166 * Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
167 * Do not assume that its value represents useful information elsewhere.
171 /* GUC records for specific variable types */
175 struct config_generic gen;
176 /* constant fields, must be set correctly in initial value: */
179 GucBoolCheckHook check_hook;
180 GucBoolAssignHook assign_hook;
181 GucShowHook show_hook;
182 /* variable fields, initialized at runtime: */
189 struct config_generic gen;
190 /* constant fields, must be set correctly in initial value: */
195 GucIntCheckHook check_hook;
196 GucIntAssignHook assign_hook;
197 GucShowHook show_hook;
198 /* variable fields, initialized at runtime: */
205 struct config_generic gen;
206 /* constant fields, must be set correctly in initial value: */
211 GucRealCheckHook check_hook;
212 GucRealAssignHook assign_hook;
213 GucShowHook show_hook;
214 /* variable fields, initialized at runtime: */
221 struct config_generic gen;
222 /* constant fields, must be set correctly in initial value: */
224 const char *boot_val;
225 GucStringCheckHook check_hook;
226 GucStringAssignHook assign_hook;
227 GucShowHook show_hook;
228 /* variable fields, initialized at runtime: */
235 struct config_generic gen;
236 /* constant fields, must be set correctly in initial value: */
239 const struct config_enum_entry *options;
240 GucEnumCheckHook check_hook;
241 GucEnumAssignHook assign_hook;
242 GucShowHook show_hook;
243 /* variable fields, initialized at runtime: */
248 /* constant tables corresponding to enums above and in guc.h */
249 extern const char *const config_group_names[];
250 extern const char *const config_type_names[];
251 extern const char *const GucContext_Names[];
252 extern const char *const GucSource_Names[];
254 /* get the current set of variables */
255 extern struct config_generic **get_guc_variables(void);
257 extern void build_guc_variables(void);
259 /* search in enum options */
260 extern const char *config_enum_lookup_by_value(struct config_enum * record, int val);
261 extern bool config_enum_lookup_by_name(struct config_enum * record,
262 const char *value, int *retval);
265 #endif /* GUC_TABLES_H */