1 /*-------------------------------------------------------------------------
4 * Declarations of tables used by GUC.
6 * See src/backend/utils/misc/README for design notes.
8 * Portions Copyright (c) 1996-2011, 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,
88 CLIENT_CONN_STATEMENT,
93 COMPAT_OPTIONS_PREVIOUS,
94 COMPAT_OPTIONS_CLIENT,
95 ERROR_HANDLING_OPTIONS,
102 * Stack entry for saving the state a variable had prior to an uncommitted
103 * transactional change
107 /* This is almost GucAction, but we need a fourth state for SET+LOCAL */
108 GUC_SAVE, /* entry caused by function SET option */
109 GUC_SET, /* entry caused by plain SET command */
110 GUC_LOCAL, /* entry caused by SET LOCAL command */
111 GUC_SET_LOCAL /* entry caused by SET then SET LOCAL */
114 typedef struct guc_stack
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 config_var_value prior; /* previous value of variable */
121 config_var_value masked; /* SET value in a GUC_SET_LOCAL entry */
122 /* masked value's source must be PGC_S_SESSION, so no need to store it */
126 * Generic fields applicable to all types of variables
128 * The short description should be less than 80 chars in length. Some
129 * applications may use the long description as well, and will append
130 * it to the short description. (separated by a newline or '. ')
132 * Note that sourcefile/sourceline are kept here, and not pushed into stacked
133 * values, although in principle they belong with some stacked value if the
134 * active value is session- or transaction-local. This is to avoid bloating
135 * stack entries. We know they are only relevant when source == PGC_S_FILE.
137 struct config_generic
139 /* constant fields, must be set correctly in initial value: */
140 const char *name; /* name of variable - MUST BE FIRST */
141 GucContext context; /* context required to set the variable */
142 enum config_group group; /* to help organize variables by function */
143 const char *short_desc; /* short desc. of this variable's purpose */
144 const char *long_desc; /* long desc. of this variable's purpose */
145 int flags; /* flag bits, see below */
146 /* variable fields, initialized at runtime: */
147 enum config_type vartype; /* type of variable (set only at startup) */
148 int status; /* status bits, see below */
149 GucSource reset_source; /* source of the reset_value */
150 GucSource source; /* source of the current actual value */
151 GucStack *stack; /* stacked prior values */
152 void *extra; /* "extra" pointer for current actual value */
153 char *sourcefile; /* file current setting is from (NULL if not
155 int sourceline; /* line in source file */
158 /* bit values in flags field are defined in guc.h */
160 /* bit values in status field */
161 #define GUC_IS_IN_FILE 0x0001 /* found it in config file */
163 * Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
164 * Do not assume that its value represents useful information elsewhere.
168 /* GUC records for specific variable types */
172 struct config_generic gen;
173 /* constant fields, must be set correctly in initial value: */
176 GucBoolCheckHook check_hook;
177 GucBoolAssignHook assign_hook;
178 GucShowHook show_hook;
179 /* variable fields, initialized at runtime: */
186 struct config_generic gen;
187 /* constant fields, must be set correctly in initial value: */
192 GucIntCheckHook check_hook;
193 GucIntAssignHook assign_hook;
194 GucShowHook show_hook;
195 /* variable fields, initialized at runtime: */
202 struct config_generic gen;
203 /* constant fields, must be set correctly in initial value: */
208 GucRealCheckHook check_hook;
209 GucRealAssignHook assign_hook;
210 GucShowHook show_hook;
211 /* variable fields, initialized at runtime: */
218 struct config_generic gen;
219 /* constant fields, must be set correctly in initial value: */
221 const char *boot_val;
222 GucStringCheckHook check_hook;
223 GucStringAssignHook assign_hook;
224 GucShowHook show_hook;
225 /* variable fields, initialized at runtime: */
232 struct config_generic gen;
233 /* constant fields, must be set correctly in initial value: */
236 const struct config_enum_entry *options;
237 GucEnumCheckHook check_hook;
238 GucEnumAssignHook assign_hook;
239 GucShowHook show_hook;
240 /* variable fields, initialized at runtime: */
245 /* constant tables corresponding to enums above and in guc.h */
246 extern const char *const config_group_names[];
247 extern const char *const config_type_names[];
248 extern const char *const GucContext_Names[];
249 extern const char *const GucSource_Names[];
251 /* get the current set of variables */
252 extern struct config_generic **get_guc_variables(void);
254 extern void build_guc_variables(void);
256 /* search in enum options */
257 extern const char *config_enum_lookup_by_value(struct config_enum * record, int val);
258 extern bool config_enum_lookup_by_name(struct config_enum * record,
259 const char *value, int *retval);
262 #endif /* GUC_TABLES_H */