PostgreSQL Source Code git master
guc_tables.h
Go to the documentation of this file.
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-2025, 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
17#include "lib/ilist.h"
18#include "utils/guc.h"
19
20/*
21 * GUC supports these types of variables:
22 */
24{
30};
31
33{
34 bool boolval;
35 int intval;
36 double realval;
37 char *stringval;
39};
40
41/*
42 * The actual value of a GUC variable can include a malloc'd opaque struct
43 * "extra", which is created by its check_hook and used by its assign_hook.
44 */
45typedef struct config_var_value
46{
48 void *extra;
50
51/*
52 * Groupings to help organize all the run-time options for display.
53 * Be sure this agrees with the way the options are categorized in config.sgml!
54 */
56{
57 UNGROUPED, /* use for options not shown in pg_settings */
105};
106
107/*
108 * Stack entry for saving the state a variable had prior to an uncommitted
109 * transactional change
110 */
111typedef enum
112{
113 /* This is almost GucAction, but we need a fourth state for SET+LOCAL */
114 GUC_SAVE, /* entry caused by function SET option */
115 GUC_SET, /* entry caused by plain SET command */
116 GUC_LOCAL, /* entry caused by SET LOCAL command */
117 GUC_SET_LOCAL, /* entry caused by SET then SET LOCAL */
119
120typedef struct guc_stack
121{
122 struct guc_stack *prev; /* previous stack item, if any */
123 int nest_level; /* nesting depth at which we made entry */
124 GucStackState state; /* see enum above */
125 GucSource source; /* source of the prior value */
126 /* masked value's source must be PGC_S_SESSION, so no need to store it */
127 GucContext scontext; /* context that set the prior value */
128 GucContext masked_scontext; /* context that set the masked value */
129 Oid srole; /* role that set the prior value */
130 Oid masked_srole; /* role that set the masked value */
131 config_var_value prior; /* previous value of variable */
132 config_var_value masked; /* SET value in a GUC_SET_LOCAL entry */
134
135
136/* GUC records for specific variable types */
137
139{
140 /* constant fields, must be set correctly in initial value: */
141 bool *variable;
146 /* variable fields, initialized at runtime: */
148};
149
151{
152 /* constant fields, must be set correctly in initial value: */
155 int min;
156 int max;
160 /* variable fields, initialized at runtime: */
162};
163
165{
166 /* constant fields, must be set correctly in initial value: */
167 double *variable;
168 double boot_val;
169 double min;
170 double max;
174 /* variable fields, initialized at runtime: */
175 double reset_val;
176};
177
178/*
179 * A note about string GUCs: the boot_val is allowed to be NULL, which leads
180 * to the reset_val and the actual variable value (*variable) also being NULL.
181 * However, there is no way to set a NULL value subsequently using
182 * set_config_option or any other GUC API. Also, GUC APIs such as SHOW will
183 * display a NULL value as an empty string. Callers that choose to use a NULL
184 * boot_val should overwrite the setting later in startup, or else be careful
185 * that NULL doesn't have semantics that are visibly different from an empty
186 * string.
187 */
189{
190 /* constant fields, must be set correctly in initial value: */
191 char **variable;
192 const char *boot_val;
196 /* variable fields, initialized at runtime: */
198};
199
201{
202 /* constant fields, must be set correctly in initial value: */
209 /* variable fields, initialized at runtime: */
211};
212
213/*
214 * Generic fields applicable to all types of variables
215 *
216 * The short description should be less than 80 chars in length. Some
217 * applications may use the long description as well, and will append
218 * it to the short description. (separated by a newline or '. ')
219 *
220 * If the GUC accepts a special value like -1 to disable the feature, use a
221 * system default, etc., it should be mentioned in the long description with
222 * the following style:
223 *
224 * - Special values should be listed at the end of the long description.
225 * - Descriptions should use numerals (e.g., "0") instead of words (e.g.,
226 * "zero").
227 * - Special value mentions should be concise and direct (e.g., "0 disables
228 * the timeout.", "An empty string means use the operating system
229 * setting.").
230 * - Multiple special values should be listed in ascending order.
231 *
232 * As an exception, special values should _not_ be mentioned if the description
233 * would be too complex or if the meaning is sufficiently obvious.
234 *
235 * srole is the role that set the current value, or BOOTSTRAP_SUPERUSERID
236 * if the value came from an internal source or the config file. Similarly
237 * for reset_srole (which is usually BOOTSTRAP_SUPERUSERID, but not always).
238 *
239 * Variables that are currently of active interest for maintenance
240 * operations are linked into various lists using the xxx_link fields.
241 * The link fields are unused/garbage in variables not currently having
242 * the specified properties.
243 *
244 * Note that sourcefile/sourceline are kept here, and not pushed into stacked
245 * values, although in principle they belong with some stacked value if the
246 * active value is session- or transaction-local. This is to avoid bloating
247 * stack entries. We know they are only relevant when source == PGC_S_FILE.
248 */
250{
251 /* constant fields, must be set correctly in initial value: */
252 const char *name; /* name of variable */
253 GucContext context; /* context required to set the variable */
254 enum config_group group; /* to help organize variables by function */
255 const char *short_desc; /* short desc. of this variable's purpose */
256 const char *long_desc; /* long desc. of this variable's purpose */
257 int flags; /* flag bits, see guc.h */
258 enum config_type vartype; /* type of variable */
259 /* variable fields, initialized at runtime: */
260 int status; /* status bits, see below */
261 GucSource source; /* source of the current actual value */
262 GucSource reset_source; /* source of the reset_value */
263 GucContext scontext; /* context that set the current value */
264 GucContext reset_scontext; /* context that set the reset value */
265 Oid srole; /* role that set the current value */
266 Oid reset_srole; /* role that set the reset value */
267 GucStack *stack; /* stacked prior values */
268 void *extra; /* "extra" pointer for current actual value */
270 dlist_node nondef_link; /* list link for variables that have source
271 * different from PGC_S_DEFAULT */
272 slist_node stack_link; /* list link for variables that have non-NULL
273 * stack */
274 slist_node report_link; /* list link for variables that have the
275 * GUC_NEEDS_REPORT bit set in status */
276 char *last_reported; /* if variable is GUC_REPORT, value last sent
277 * to client (NULL if not yet sent) */
278 char *sourcefile; /* file current setting is from (NULL if not
279 * set in config file) */
280 int sourceline; /* line in source file */
281
282 /* fields for specific variable types */
283 union
284 {
290 };
291};
292
293/* bit values in status field */
294#define GUC_IS_IN_FILE 0x0001 /* found it in config file */
295/*
296 * Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
297 * Do not assume that its value represents useful information elsewhere.
298 */
299#define GUC_PENDING_RESTART 0x0002 /* changed value cannot be applied yet */
300#define GUC_NEEDS_REPORT 0x0004 /* new value must be reported to client */
301
302
303/* constant tables corresponding to enums above and in guc.h */
304extern PGDLLIMPORT const char *const config_group_names[];
305extern PGDLLIMPORT const char *const config_type_names[];
306extern PGDLLIMPORT const char *const GucContext_Names[];
307extern PGDLLIMPORT const char *const GucSource_Names[];
308
309/* data array defining all the built-in GUC variables */
311
312/* lookup GUC variables, returning config_generic pointers */
313extern struct config_generic *find_option(const char *name,
314 bool create_placeholders,
315 bool skip_errors,
316 int elevel);
317extern struct config_generic **get_explain_guc_options(int *num);
318
319/* get string value of variable */
320extern char *ShowGUCOption(const struct config_generic *record, bool use_units);
321
322/* get whether or not the GUC variable is visible to current user */
323extern bool ConfigOptionIsVisible(const struct config_generic *conf);
324
325/* get the current set of variables */
326extern struct config_generic **get_guc_variables(int *num_vars);
327
328extern void build_guc_variables(void);
329
330/* search in enum options */
331extern const char *config_enum_lookup_by_value(const struct config_generic *record, int val);
332extern bool config_enum_lookup_by_name(const struct config_enum *record,
333 const char *value, int *retval);
334extern char *config_enum_get_options(const struct config_enum *record,
335 const char *prefix,
336 const char *suffix,
337 const char *separator);
338
339#endif /* GUC_TABLES_H */
#define PGDLLIMPORT
Definition: c.h:1310
bool(* GucBoolCheckHook)(bool *newval, void **extra, GucSource source)
Definition: guc.h:183
bool(* GucRealCheckHook)(double *newval, void **extra, GucSource source)
Definition: guc.h:185
void(* GucStringAssignHook)(const char *newval, void *extra)
Definition: guc.h:192
bool(* GucEnumCheckHook)(int *newval, void **extra, GucSource source)
Definition: guc.h:187
void(* GucBoolAssignHook)(bool newval, void *extra)
Definition: guc.h:189
void(* GucEnumAssignHook)(int newval, void *extra)
Definition: guc.h:193
GucSource
Definition: guc.h:112
bool(* GucStringCheckHook)(char **newval, void **extra, GucSource source)
Definition: guc.h:186
void(* GucIntAssignHook)(int newval, void *extra)
Definition: guc.h:190
void(* GucRealAssignHook)(double newval, void *extra)
Definition: guc.h:191
GucContext
Definition: guc.h:72
bool(* GucIntCheckHook)(int *newval, void **extra, GucSource source)
Definition: guc.h:184
const char *(* GucShowHook)(void)
Definition: guc.h:195
PGDLLIMPORT const char *const GucContext_Names[]
Definition: guc_tables.c:648
const char * config_enum_lookup_by_value(const struct config_generic *record, int val)
Definition: guc.c:2895
PGDLLIMPORT const char *const GucSource_Names[]
Definition: guc_tables.c:667
char * config_enum_get_options(const struct config_enum *record, const char *prefix, const char *suffix, const char *separator)
Definition: guc.c:2940
struct config_generic ** get_guc_variables(int *num_vars)
Definition: guc.c:839
PGDLLIMPORT struct config_generic ConfigureNames[]
PGDLLIMPORT const char *const config_group_names[]
Definition: guc_tables.c:691
struct guc_stack GucStack
bool ConfigOptionIsVisible(const struct config_generic *conf)
Definition: guc_funcs.c:607
struct config_generic * find_option(const char *name, bool create_placeholders, bool skip_errors, int elevel)
Definition: guc.c:1113
PGDLLIMPORT const char *const config_type_names[]
Definition: guc_tables.c:751
bool config_enum_lookup_by_name(const struct config_enum *record, const char *value, int *retval)
Definition: guc.c:2916
void build_guc_variables(void)
Definition: guc.c:870
struct config_generic ** get_explain_guc_options(int *num)
Definition: guc.c:5200
GucStackState
Definition: guc_tables.h:112
@ GUC_SET_LOCAL
Definition: guc_tables.h:117
@ GUC_SET
Definition: guc_tables.h:115
@ GUC_SAVE
Definition: guc_tables.h:114
@ GUC_LOCAL
Definition: guc_tables.h:116
config_group
Definition: guc_tables.h:56
@ RESOURCES_KERNEL
Definition: guc_tables.h:65
@ CLIENT_CONN_LOCALE
Definition: guc_tables.h:95
@ WAL_ARCHIVE_RECOVERY
Definition: guc_tables.h:73
@ STATS_CUMULATIVE
Definition: guc_tables.h:89
@ CLIENT_CONN_PRELOAD
Definition: guc_tables.h:96
@ VACUUM_COST_DELAY
Definition: guc_tables.h:91
@ QUERY_TUNING_OTHER
Definition: guc_tables.h:83
@ LOGGING_WHERE
Definition: guc_tables.h:84
@ CONN_AUTH_AUTH
Definition: guc_tables.h:61
@ RESOURCES_WORKER_PROCESSES
Definition: guc_tables.h:68
@ VACUUM_FREEZING
Definition: guc_tables.h:93
@ ERROR_HANDLING_OPTIONS
Definition: guc_tables.h:101
@ PROCESS_TITLE
Definition: guc_tables.h:87
@ RESOURCES_DISK
Definition: guc_tables.h:64
@ REPLICATION_SENDING
Definition: guc_tables.h:76
@ RESOURCES_IO
Definition: guc_tables.h:67
@ LOCK_MANAGEMENT
Definition: guc_tables.h:98
@ CUSTOM_OPTIONS
Definition: guc_tables.h:103
@ REPLICATION_PRIMARY
Definition: guc_tables.h:77
@ STATS_MONITORING
Definition: guc_tables.h:88
@ WAL_RECOVERY_TARGET
Definition: guc_tables.h:74
@ WAL_RECOVERY
Definition: guc_tables.h:72
@ CONN_AUTH_SSL
Definition: guc_tables.h:62
@ RESOURCES_MEM
Definition: guc_tables.h:63
@ RESOURCES_BGWRITER
Definition: guc_tables.h:66
@ PRESET_OPTIONS
Definition: guc_tables.h:102
@ DEVELOPER_OPTIONS
Definition: guc_tables.h:104
@ QUERY_TUNING_METHOD
Definition: guc_tables.h:80
@ LOGGING_WHAT
Definition: guc_tables.h:86
@ VACUUM_DEFAULT
Definition: guc_tables.h:92
@ QUERY_TUNING_GEQO
Definition: guc_tables.h:82
@ WAL_SETTINGS
Definition: guc_tables.h:69
@ COMPAT_OPTIONS_OTHER
Definition: guc_tables.h:100
@ CLIENT_CONN_STATEMENT
Definition: guc_tables.h:94
@ FILE_LOCATIONS
Definition: guc_tables.h:58
@ REPLICATION_STANDBY
Definition: guc_tables.h:78
@ QUERY_TUNING_COST
Definition: guc_tables.h:81
@ WAL_ARCHIVING
Definition: guc_tables.h:71
@ COMPAT_OPTIONS_PREVIOUS
Definition: guc_tables.h:99
@ WAL_CHECKPOINTS
Definition: guc_tables.h:70
@ CLIENT_CONN_OTHER
Definition: guc_tables.h:97
@ LOGGING_WHEN
Definition: guc_tables.h:85
@ CONN_AUTH_TCP
Definition: guc_tables.h:60
@ REPLICATION_SUBSCRIBERS
Definition: guc_tables.h:79
@ WAL_SUMMARIZATION
Definition: guc_tables.h:75
@ CONN_AUTH_SETTINGS
Definition: guc_tables.h:59
@ UNGROUPED
Definition: guc_tables.h:57
@ VACUUM_AUTOVACUUM
Definition: guc_tables.h:90
config_type
Definition: guc_tables.h:24
@ PGC_BOOL
Definition: guc_tables.h:25
@ PGC_STRING
Definition: guc_tables.h:28
@ PGC_ENUM
Definition: guc_tables.h:29
@ PGC_REAL
Definition: guc_tables.h:27
@ PGC_INT
Definition: guc_tables.h:26
struct config_var_value config_var_value
char * ShowGUCOption(const struct config_generic *record, bool use_units)
Definition: guc.c:5334
long val
Definition: informix.c:689
static struct @171 value
unsigned int Oid
Definition: postgres_ext.h:32
bool * variable
Definition: guc_tables.h:141
GucBoolCheckHook check_hook
Definition: guc_tables.h:143
bool reset_val
Definition: guc_tables.h:147
GucBoolAssignHook assign_hook
Definition: guc_tables.h:144
bool boot_val
Definition: guc_tables.h:142
GucShowHook show_hook
Definition: guc_tables.h:145
Definition: guc.h:174
const struct config_enum_entry * options
Definition: guc_tables.h:205
int * variable
Definition: guc_tables.h:203
GucEnumAssignHook assign_hook
Definition: guc_tables.h:207
GucEnumCheckHook check_hook
Definition: guc_tables.h:206
GucShowHook show_hook
Definition: guc_tables.h:208
dlist_node nondef_link
Definition: guc_tables.h:270
char * last_reported
Definition: guc_tables.h:276
enum config_group group
Definition: guc_tables.h:254
GucContext context
Definition: guc_tables.h:253
const char * long_desc
Definition: guc_tables.h:256
struct config_bool _bool
Definition: guc_tables.h:285
GucContext scontext
Definition: guc_tables.h:263
struct config_string _string
Definition: guc_tables.h:288
const char * name
Definition: guc_tables.h:252
struct config_real _real
Definition: guc_tables.h:287
slist_node stack_link
Definition: guc_tables.h:272
const char * short_desc
Definition: guc_tables.h:255
char * sourcefile
Definition: guc_tables.h:278
struct config_int _int
Definition: guc_tables.h:286
GucContext reset_scontext
Definition: guc_tables.h:264
GucStack * stack
Definition: guc_tables.h:267
enum config_type vartype
Definition: guc_tables.h:258
GucSource source
Definition: guc_tables.h:261
void * reset_extra
Definition: guc_tables.h:269
GucSource reset_source
Definition: guc_tables.h:262
slist_node report_link
Definition: guc_tables.h:274
struct config_enum _enum
Definition: guc_tables.h:289
int reset_val
Definition: guc_tables.h:161
int boot_val
Definition: guc_tables.h:154
GucIntAssignHook assign_hook
Definition: guc_tables.h:158
int * variable
Definition: guc_tables.h:153
GucIntCheckHook check_hook
Definition: guc_tables.h:157
GucShowHook show_hook
Definition: guc_tables.h:159
double boot_val
Definition: guc_tables.h:168
double reset_val
Definition: guc_tables.h:175
GucRealAssignHook assign_hook
Definition: guc_tables.h:172
double * variable
Definition: guc_tables.h:167
double min
Definition: guc_tables.h:169
double max
Definition: guc_tables.h:170
GucShowHook show_hook
Definition: guc_tables.h:173
GucRealCheckHook check_hook
Definition: guc_tables.h:171
char * reset_val
Definition: guc_tables.h:197
GucStringCheckHook check_hook
Definition: guc_tables.h:193
GucStringAssignHook assign_hook
Definition: guc_tables.h:194
GucShowHook show_hook
Definition: guc_tables.h:195
char ** variable
Definition: guc_tables.h:191
const char * boot_val
Definition: guc_tables.h:192
union config_var_val val
Definition: guc_tables.h:47
struct guc_stack * prev
Definition: guc_tables.h:122
Oid masked_srole
Definition: guc_tables.h:130
int nest_level
Definition: guc_tables.h:123
config_var_value masked
Definition: guc_tables.h:132
config_var_value prior
Definition: guc_tables.h:131
GucContext scontext
Definition: guc_tables.h:127
GucStackState state
Definition: guc_tables.h:124
GucSource source
Definition: guc_tables.h:125
GucContext masked_scontext
Definition: guc_tables.h:128
double realval
Definition: guc_tables.h:36
char * stringval
Definition: guc_tables.h:37
const char * name