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 */
103};
104
105/*
106 * Stack entry for saving the state a variable had prior to an uncommitted
107 * transactional change
108 */
109typedef enum
110{
111 /* This is almost GucAction, but we need a fourth state for SET+LOCAL */
112 GUC_SAVE, /* entry caused by function SET option */
113 GUC_SET, /* entry caused by plain SET command */
114 GUC_LOCAL, /* entry caused by SET LOCAL command */
115 GUC_SET_LOCAL, /* entry caused by SET then SET LOCAL */
117
118typedef struct guc_stack
119{
120 struct guc_stack *prev; /* previous stack item, if any */
121 int nest_level; /* nesting depth at which we made entry */
122 GucStackState state; /* see enum above */
123 GucSource source; /* source of the prior value */
124 /* masked value's source must be PGC_S_SESSION, so no need to store it */
125 GucContext scontext; /* context that set the prior value */
126 GucContext masked_scontext; /* context that set the masked value */
127 Oid srole; /* role that set the prior value */
128 Oid masked_srole; /* role that set the masked value */
129 config_var_value prior; /* previous value of variable */
130 config_var_value masked; /* SET value in a GUC_SET_LOCAL entry */
132
133/*
134 * Generic fields applicable to all types of variables
135 *
136 * The short description should be less than 80 chars in length. Some
137 * applications may use the long description as well, and will append
138 * it to the short description. (separated by a newline or '. ')
139 *
140 * srole is the role that set the current value, or BOOTSTRAP_SUPERUSERID
141 * if the value came from an internal source or the config file. Similarly
142 * for reset_srole (which is usually BOOTSTRAP_SUPERUSERID, but not always).
143 *
144 * Variables that are currently of active interest for maintenance
145 * operations are linked into various lists using the xxx_link fields.
146 * The link fields are unused/garbage in variables not currently having
147 * the specified properties.
148 *
149 * Note that sourcefile/sourceline are kept here, and not pushed into stacked
150 * values, although in principle they belong with some stacked value if the
151 * active value is session- or transaction-local. This is to avoid bloating
152 * stack entries. We know they are only relevant when source == PGC_S_FILE.
153 */
155{
156 /* constant fields, must be set correctly in initial value: */
157 const char *name; /* name of variable - MUST BE FIRST */
158 GucContext context; /* context required to set the variable */
159 enum config_group group; /* to help organize variables by function */
160 const char *short_desc; /* short desc. of this variable's purpose */
161 const char *long_desc; /* long desc. of this variable's purpose */
162 int flags; /* flag bits, see guc.h */
163 /* variable fields, initialized at runtime: */
164 enum config_type vartype; /* type of variable (set only at startup) */
165 int status; /* status bits, see below */
166 GucSource source; /* source of the current actual value */
167 GucSource reset_source; /* source of the reset_value */
168 GucContext scontext; /* context that set the current value */
169 GucContext reset_scontext; /* context that set the reset value */
170 Oid srole; /* role that set the current value */
171 Oid reset_srole; /* role that set the reset value */
172 GucStack *stack; /* stacked prior values */
173 void *extra; /* "extra" pointer for current actual value */
174 dlist_node nondef_link; /* list link for variables that have source
175 * different from PGC_S_DEFAULT */
176 slist_node stack_link; /* list link for variables that have non-NULL
177 * stack */
178 slist_node report_link; /* list link for variables that have the
179 * GUC_NEEDS_REPORT bit set in status */
180 char *last_reported; /* if variable is GUC_REPORT, value last sent
181 * to client (NULL if not yet sent) */
182 char *sourcefile; /* file current setting is from (NULL if not
183 * set in config file) */
184 int sourceline; /* line in source file */
185};
186
187/* bit values in status field */
188#define GUC_IS_IN_FILE 0x0001 /* found it in config file */
189/*
190 * Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
191 * Do not assume that its value represents useful information elsewhere.
192 */
193#define GUC_PENDING_RESTART 0x0002 /* changed value cannot be applied yet */
194#define GUC_NEEDS_REPORT 0x0004 /* new value must be reported to client */
195
196
197/* GUC records for specific variable types */
198
200{
202 /* constant fields, must be set correctly in initial value: */
203 bool *variable;
208 /* variable fields, initialized at runtime: */
211};
212
214{
216 /* constant fields, must be set correctly in initial value: */
219 int min;
220 int max;
224 /* variable fields, initialized at runtime: */
227};
228
230{
232 /* constant fields, must be set correctly in initial value: */
233 double *variable;
234 double boot_val;
235 double min;
236 double max;
240 /* variable fields, initialized at runtime: */
241 double reset_val;
243};
244
245/*
246 * A note about string GUCs: the boot_val is allowed to be NULL, which leads
247 * to the reset_val and the actual variable value (*variable) also being NULL.
248 * However, there is no way to set a NULL value subsequently using
249 * set_config_option or any other GUC API. Also, GUC APIs such as SHOW will
250 * display a NULL value as an empty string. Callers that choose to use a NULL
251 * boot_val should overwrite the setting later in startup, or else be careful
252 * that NULL doesn't have semantics that are visibly different from an empty
253 * string.
254 */
256{
258 /* constant fields, must be set correctly in initial value: */
259 char **variable;
260 const char *boot_val;
264 /* variable fields, initialized at runtime: */
267};
268
270{
272 /* constant fields, must be set correctly in initial value: */
279 /* variable fields, initialized at runtime: */
282};
283
284/* constant tables corresponding to enums above and in guc.h */
285extern PGDLLIMPORT const char *const config_group_names[];
286extern PGDLLIMPORT const char *const config_type_names[];
287extern PGDLLIMPORT const char *const GucContext_Names[];
288extern PGDLLIMPORT const char *const GucSource_Names[];
289
290/* data arrays defining all the built-in GUC variables */
296
297/* lookup GUC variables, returning config_generic pointers */
298extern struct config_generic *find_option(const char *name,
299 bool create_placeholders,
300 bool skip_errors,
301 int elevel);
302extern struct config_generic **get_explain_guc_options(int *num);
303
304/* get string value of variable */
305extern char *ShowGUCOption(struct config_generic *record, bool use_units);
306
307/* get whether or not the GUC variable is visible to current user */
308extern bool ConfigOptionIsVisible(struct config_generic *conf);
309
310/* get the current set of variables */
311extern struct config_generic **get_guc_variables(int *num_vars);
312
313extern void build_guc_variables(void);
314
315/* search in enum options */
316extern const char *config_enum_lookup_by_value(struct config_enum *record, int val);
317extern bool config_enum_lookup_by_name(struct config_enum *record,
318 const char *value, int *retval);
319extern char *config_enum_get_options(struct config_enum *record,
320 const char *prefix,
321 const char *suffix,
322 const char *separator);
323
324#endif /* GUC_TABLES_H */
#define PGDLLIMPORT
Definition: c.h:1277
bool(* GucBoolCheckHook)(bool *newval, void **extra, GucSource source)
Definition: guc.h:179
bool(* GucRealCheckHook)(double *newval, void **extra, GucSource source)
Definition: guc.h:181
void(* GucStringAssignHook)(const char *newval, void *extra)
Definition: guc.h:188
bool(* GucEnumCheckHook)(int *newval, void **extra, GucSource source)
Definition: guc.h:183
void(* GucBoolAssignHook)(bool newval, void *extra)
Definition: guc.h:185
void(* GucEnumAssignHook)(int newval, void *extra)
Definition: guc.h:189
GucSource
Definition: guc.h:108
bool(* GucStringCheckHook)(char **newval, void **extra, GucSource source)
Definition: guc.h:182
void(* GucIntAssignHook)(int newval, void *extra)
Definition: guc.h:186
void(* GucRealAssignHook)(double newval, void *extra)
Definition: guc.h:187
GucContext
Definition: guc.h:68
bool(* GucIntCheckHook)(int *newval, void **extra, GucSource source)
Definition: guc.h:180
const char *(* GucShowHook)(void)
Definition: guc.h:191
PGDLLIMPORT const char *const GucContext_Names[]
Definition: guc_tables.c:630
PGDLLIMPORT const char *const GucSource_Names[]
Definition: guc_tables.c:649
bool config_enum_lookup_by_name(struct config_enum *record, const char *value, int *retval)
Definition: guc.c:3046
PGDLLIMPORT struct config_int ConfigureNamesInt[]
Definition: guc_tables.c:2106
struct config_generic ** get_guc_variables(int *num_vars)
Definition: guc.c:872
PGDLLIMPORT const char *const config_group_names[]
Definition: guc_tables.c:673
struct guc_stack GucStack
struct config_generic * find_option(const char *name, bool create_placeholders, bool skip_errors, int elevel)
Definition: guc.c:1235
char * config_enum_get_options(struct config_enum *record, const char *prefix, const char *suffix, const char *separator)
Definition: guc.c:3072
PGDLLIMPORT const char *const config_type_names[]
Definition: guc_tables.c:731
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:3023
void build_guc_variables(void)
Definition: guc.c:903
bool ConfigOptionIsVisible(struct config_generic *conf)
Definition: guc_funcs.c:581
struct config_generic ** get_explain_guc_options(int *num)
Definition: guc.c:5331
PGDLLIMPORT struct config_real ConfigureNamesReal[]
Definition: guc_tables.c:3753
char * ShowGUCOption(struct config_generic *record, bool use_units)
Definition: guc.c:5465
GucStackState
Definition: guc_tables.h:110
@ GUC_SET_LOCAL
Definition: guc_tables.h:115
@ GUC_SET
Definition: guc_tables.h:113
@ GUC_SAVE
Definition: guc_tables.h:112
@ GUC_LOCAL
Definition: guc_tables.h:114
config_group
Definition: guc_tables.h:56
@ RESOURCES_KERNEL
Definition: guc_tables.h:65
@ CLIENT_CONN_LOCALE
Definition: guc_tables.h:93
@ WAL_ARCHIVE_RECOVERY
Definition: guc_tables.h:72
@ STATS_CUMULATIVE
Definition: guc_tables.h:88
@ CLIENT_CONN_PRELOAD
Definition: guc_tables.h:94
@ VACUUM_COST_DELAY
Definition: guc_tables.h:90
@ QUERY_TUNING_OTHER
Definition: guc_tables.h:82
@ LOGGING_WHERE
Definition: guc_tables.h:83
@ CONN_AUTH_AUTH
Definition: guc_tables.h:61
@ VACUUM_FREEZING
Definition: guc_tables.h:91
@ ERROR_HANDLING_OPTIONS
Definition: guc_tables.h:99
@ PROCESS_TITLE
Definition: guc_tables.h:86
@ RESOURCES_DISK
Definition: guc_tables.h:64
@ REPLICATION_SENDING
Definition: guc_tables.h:75
@ LOCK_MANAGEMENT
Definition: guc_tables.h:96
@ CUSTOM_OPTIONS
Definition: guc_tables.h:101
@ REPLICATION_PRIMARY
Definition: guc_tables.h:76
@ STATS_MONITORING
Definition: guc_tables.h:87
@ WAL_RECOVERY_TARGET
Definition: guc_tables.h:73
@ WAL_RECOVERY
Definition: guc_tables.h:71
@ 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:100
@ DEVELOPER_OPTIONS
Definition: guc_tables.h:102
@ QUERY_TUNING_METHOD
Definition: guc_tables.h:79
@ LOGGING_WHAT
Definition: guc_tables.h:85
@ RESOURCES_ASYNCHRONOUS
Definition: guc_tables.h:67
@ QUERY_TUNING_GEQO
Definition: guc_tables.h:81
@ WAL_SETTINGS
Definition: guc_tables.h:68
@ COMPAT_OPTIONS_OTHER
Definition: guc_tables.h:98
@ CLIENT_CONN_STATEMENT
Definition: guc_tables.h:92
@ FILE_LOCATIONS
Definition: guc_tables.h:58
@ REPLICATION_STANDBY
Definition: guc_tables.h:77
@ QUERY_TUNING_COST
Definition: guc_tables.h:80
@ WAL_ARCHIVING
Definition: guc_tables.h:70
@ COMPAT_OPTIONS_PREVIOUS
Definition: guc_tables.h:97
@ WAL_CHECKPOINTS
Definition: guc_tables.h:69
@ CLIENT_CONN_OTHER
Definition: guc_tables.h:95
@ LOGGING_WHEN
Definition: guc_tables.h:84
@ CONN_AUTH_TCP
Definition: guc_tables.h:60
@ REPLICATION_SUBSCRIBERS
Definition: guc_tables.h:78
@ WAL_SUMMARIZATION
Definition: guc_tables.h:74
@ CONN_AUTH_SETTINGS
Definition: guc_tables.h:59
@ UNGROUPED
Definition: guc_tables.h:57
@ VACUUM_AUTOVACUUM
Definition: guc_tables.h:89
PGDLLIMPORT struct config_string ConfigureNamesString[]
Definition: guc_tables.c:4034
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
PGDLLIMPORT struct config_enum ConfigureNamesEnum[]
Definition: guc_tables.c:4833
struct config_var_value config_var_value
PGDLLIMPORT struct config_bool ConfigureNamesBool[]
Definition: guc_tables.c:771
static struct @162 value
long val
Definition: informix.c:689
unsigned int Oid
Definition: postgres_ext.h:32
void * reset_extra
Definition: guc_tables.h:210
struct config_generic gen
Definition: guc_tables.h:201
bool * variable
Definition: guc_tables.h:203
GucBoolCheckHook check_hook
Definition: guc_tables.h:205
bool reset_val
Definition: guc_tables.h:209
GucBoolAssignHook assign_hook
Definition: guc_tables.h:206
bool boot_val
Definition: guc_tables.h:204
GucShowHook show_hook
Definition: guc_tables.h:207
Definition: guc.h:170
const struct config_enum_entry * options
Definition: guc_tables.h:275
int * variable
Definition: guc_tables.h:273
GucEnumAssignHook assign_hook
Definition: guc_tables.h:277
struct config_generic gen
Definition: guc_tables.h:271
void * reset_extra
Definition: guc_tables.h:281
GucEnumCheckHook check_hook
Definition: guc_tables.h:276
GucShowHook show_hook
Definition: guc_tables.h:278
dlist_node nondef_link
Definition: guc_tables.h:174
char * last_reported
Definition: guc_tables.h:180
enum config_group group
Definition: guc_tables.h:159
GucContext context
Definition: guc_tables.h:158
const char * long_desc
Definition: guc_tables.h:161
GucContext scontext
Definition: guc_tables.h:168
const char * name
Definition: guc_tables.h:157
slist_node stack_link
Definition: guc_tables.h:176
const char * short_desc
Definition: guc_tables.h:160
char * sourcefile
Definition: guc_tables.h:182
GucContext reset_scontext
Definition: guc_tables.h:169
GucStack * stack
Definition: guc_tables.h:172
enum config_type vartype
Definition: guc_tables.h:164
GucSource source
Definition: guc_tables.h:166
GucSource reset_source
Definition: guc_tables.h:167
slist_node report_link
Definition: guc_tables.h:178
void * reset_extra
Definition: guc_tables.h:226
int reset_val
Definition: guc_tables.h:225
int boot_val
Definition: guc_tables.h:218
GucIntAssignHook assign_hook
Definition: guc_tables.h:222
int * variable
Definition: guc_tables.h:217
GucIntCheckHook check_hook
Definition: guc_tables.h:221
GucShowHook show_hook
Definition: guc_tables.h:223
struct config_generic gen
Definition: guc_tables.h:215
double boot_val
Definition: guc_tables.h:234
void * reset_extra
Definition: guc_tables.h:242
double reset_val
Definition: guc_tables.h:241
GucRealAssignHook assign_hook
Definition: guc_tables.h:238
double * variable
Definition: guc_tables.h:233
double min
Definition: guc_tables.h:235
double max
Definition: guc_tables.h:236
struct config_generic gen
Definition: guc_tables.h:231
GucShowHook show_hook
Definition: guc_tables.h:239
GucRealCheckHook check_hook
Definition: guc_tables.h:237
struct config_generic gen
Definition: guc_tables.h:257
char * reset_val
Definition: guc_tables.h:265
GucStringCheckHook check_hook
Definition: guc_tables.h:261
GucStringAssignHook assign_hook
Definition: guc_tables.h:262
GucShowHook show_hook
Definition: guc_tables.h:263
char ** variable
Definition: guc_tables.h:259
void * reset_extra
Definition: guc_tables.h:266
const char * boot_val
Definition: guc_tables.h:260
union config_var_val val
Definition: guc_tables.h:47
struct guc_stack * prev
Definition: guc_tables.h:120
Oid masked_srole
Definition: guc_tables.h:128
int nest_level
Definition: guc_tables.h:121
config_var_value masked
Definition: guc_tables.h:130
config_var_value prior
Definition: guc_tables.h:129
GucContext scontext
Definition: guc_tables.h:125
GucStackState state
Definition: guc_tables.h:122
GucSource source
Definition: guc_tables.h:123
GucContext masked_scontext
Definition: guc_tables.h:126
double realval
Definition: guc_tables.h:36
char * stringval
Definition: guc_tables.h:37
const char * name