PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 * Generic fields applicable to all types of variables
137 *
138 * The short description should be less than 80 chars in length. Some
139 * applications may use the long description as well, and will append
140 * it to the short description. (separated by a newline or '. ')
141 *
142 * If the GUC accepts a special value like -1 to disable the feature, use a
143 * system default, etc., it should be mentioned in the long description with
144 * the following style:
145 *
146 * - Special values should be listed at the end of the long description.
147 * - Descriptions should use numerals (e.g., "0") instead of words (e.g.,
148 * "zero").
149 * - Special value mentions should be concise and direct (e.g., "0 disables
150 * the timeout.", "An empty string means use the operating system
151 * setting.").
152 * - Multiple special values should be listed in ascending order.
153 *
154 * As an exception, special values should _not_ be mentioned if the description
155 * would be too complex or if the meaning is sufficiently obvious.
156 *
157 * srole is the role that set the current value, or BOOTSTRAP_SUPERUSERID
158 * if the value came from an internal source or the config file. Similarly
159 * for reset_srole (which is usually BOOTSTRAP_SUPERUSERID, but not always).
160 *
161 * Variables that are currently of active interest for maintenance
162 * operations are linked into various lists using the xxx_link fields.
163 * The link fields are unused/garbage in variables not currently having
164 * the specified properties.
165 *
166 * Note that sourcefile/sourceline are kept here, and not pushed into stacked
167 * values, although in principle they belong with some stacked value if the
168 * active value is session- or transaction-local. This is to avoid bloating
169 * stack entries. We know they are only relevant when source == PGC_S_FILE.
170 */
172{
173 /* constant fields, must be set correctly in initial value: */
174 const char *name; /* name of variable - MUST BE FIRST */
175 GucContext context; /* context required to set the variable */
176 enum config_group group; /* to help organize variables by function */
177 const char *short_desc; /* short desc. of this variable's purpose */
178 const char *long_desc; /* long desc. of this variable's purpose */
179 int flags; /* flag bits, see guc.h */
180 /* variable fields, initialized at runtime: */
181 enum config_type vartype; /* type of variable (set only at startup) */
182 int status; /* status bits, see below */
183 GucSource source; /* source of the current actual value */
184 GucSource reset_source; /* source of the reset_value */
185 GucContext scontext; /* context that set the current value */
186 GucContext reset_scontext; /* context that set the reset value */
187 Oid srole; /* role that set the current value */
188 Oid reset_srole; /* role that set the reset value */
189 GucStack *stack; /* stacked prior values */
190 void *extra; /* "extra" pointer for current actual value */
191 dlist_node nondef_link; /* list link for variables that have source
192 * different from PGC_S_DEFAULT */
193 slist_node stack_link; /* list link for variables that have non-NULL
194 * stack */
195 slist_node report_link; /* list link for variables that have the
196 * GUC_NEEDS_REPORT bit set in status */
197 char *last_reported; /* if variable is GUC_REPORT, value last sent
198 * to client (NULL if not yet sent) */
199 char *sourcefile; /* file current setting is from (NULL if not
200 * set in config file) */
201 int sourceline; /* line in source file */
202};
203
204/* bit values in status field */
205#define GUC_IS_IN_FILE 0x0001 /* found it in config file */
206/*
207 * Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
208 * Do not assume that its value represents useful information elsewhere.
209 */
210#define GUC_PENDING_RESTART 0x0002 /* changed value cannot be applied yet */
211#define GUC_NEEDS_REPORT 0x0004 /* new value must be reported to client */
212
213
214/* GUC records for specific variable types */
215
217{
219 /* constant fields, must be set correctly in initial value: */
220 bool *variable;
225 /* variable fields, initialized at runtime: */
228};
229
231{
233 /* constant fields, must be set correctly in initial value: */
236 int min;
237 int max;
241 /* variable fields, initialized at runtime: */
244};
245
247{
249 /* constant fields, must be set correctly in initial value: */
250 double *variable;
251 double boot_val;
252 double min;
253 double max;
257 /* variable fields, initialized at runtime: */
258 double reset_val;
260};
261
262/*
263 * A note about string GUCs: the boot_val is allowed to be NULL, which leads
264 * to the reset_val and the actual variable value (*variable) also being NULL.
265 * However, there is no way to set a NULL value subsequently using
266 * set_config_option or any other GUC API. Also, GUC APIs such as SHOW will
267 * display a NULL value as an empty string. Callers that choose to use a NULL
268 * boot_val should overwrite the setting later in startup, or else be careful
269 * that NULL doesn't have semantics that are visibly different from an empty
270 * string.
271 */
273{
275 /* constant fields, must be set correctly in initial value: */
276 char **variable;
277 const char *boot_val;
281 /* variable fields, initialized at runtime: */
284};
285
287{
289 /* constant fields, must be set correctly in initial value: */
296 /* variable fields, initialized at runtime: */
299};
300
301/* constant tables corresponding to enums above and in guc.h */
302extern PGDLLIMPORT const char *const config_group_names[];
303extern PGDLLIMPORT const char *const config_type_names[];
304extern PGDLLIMPORT const char *const GucContext_Names[];
305extern PGDLLIMPORT const char *const GucSource_Names[];
306
307/* data arrays defining all the built-in GUC variables */
313
314/* lookup GUC variables, returning config_generic pointers */
315extern struct config_generic *find_option(const char *name,
316 bool create_placeholders,
317 bool skip_errors,
318 int elevel);
319extern struct config_generic **get_explain_guc_options(int *num);
320
321/* get string value of variable */
322extern char *ShowGUCOption(struct config_generic *record, bool use_units);
323
324/* get whether or not the GUC variable is visible to current user */
325extern bool ConfigOptionIsVisible(struct config_generic *conf);
326
327/* get the current set of variables */
328extern struct config_generic **get_guc_variables(int *num_vars);
329
330extern void build_guc_variables(void);
331
332/* search in enum options */
333extern const char *config_enum_lookup_by_value(struct config_enum *record, int val);
334extern bool config_enum_lookup_by_name(struct config_enum *record,
335 const char *value, int *retval);
336extern char *config_enum_get_options(struct config_enum *record,
337 const char *prefix,
338 const char *suffix,
339 const char *separator);
340
341#endif /* GUC_TABLES_H */
#define PGDLLIMPORT
Definition: c.h:1291
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:647
PGDLLIMPORT const char *const GucSource_Names[]
Definition: guc_tables.c:666
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:2153
struct config_generic ** get_guc_variables(int *num_vars)
Definition: guc.c:872
PGDLLIMPORT const char *const config_group_names[]
Definition: guc_tables.c:690
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:750
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:5332
PGDLLIMPORT struct config_real ConfigureNamesReal[]
Definition: guc_tables.c:3870
char * ShowGUCOption(struct config_generic *record, bool use_units)
Definition: guc.c:5466
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
PGDLLIMPORT struct config_string ConfigureNamesString[]
Definition: guc_tables.c:4161
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:4995
struct config_var_value config_var_value
PGDLLIMPORT struct config_bool ConfigureNamesBool[]
Definition: guc_tables.c:790
long val
Definition: informix.c:689
static struct @165 value
unsigned int Oid
Definition: postgres_ext.h:30
void * reset_extra
Definition: guc_tables.h:227
struct config_generic gen
Definition: guc_tables.h:218
bool * variable
Definition: guc_tables.h:220
GucBoolCheckHook check_hook
Definition: guc_tables.h:222
bool reset_val
Definition: guc_tables.h:226
GucBoolAssignHook assign_hook
Definition: guc_tables.h:223
bool boot_val
Definition: guc_tables.h:221
GucShowHook show_hook
Definition: guc_tables.h:224
Definition: guc.h:174
const struct config_enum_entry * options
Definition: guc_tables.h:292
int * variable
Definition: guc_tables.h:290
GucEnumAssignHook assign_hook
Definition: guc_tables.h:294
struct config_generic gen
Definition: guc_tables.h:288
void * reset_extra
Definition: guc_tables.h:298
GucEnumCheckHook check_hook
Definition: guc_tables.h:293
GucShowHook show_hook
Definition: guc_tables.h:295
dlist_node nondef_link
Definition: guc_tables.h:191
char * last_reported
Definition: guc_tables.h:197
enum config_group group
Definition: guc_tables.h:176
GucContext context
Definition: guc_tables.h:175
const char * long_desc
Definition: guc_tables.h:178
GucContext scontext
Definition: guc_tables.h:185
const char * name
Definition: guc_tables.h:174
slist_node stack_link
Definition: guc_tables.h:193
const char * short_desc
Definition: guc_tables.h:177
char * sourcefile
Definition: guc_tables.h:199
GucContext reset_scontext
Definition: guc_tables.h:186
GucStack * stack
Definition: guc_tables.h:189
enum config_type vartype
Definition: guc_tables.h:181
GucSource source
Definition: guc_tables.h:183
GucSource reset_source
Definition: guc_tables.h:184
slist_node report_link
Definition: guc_tables.h:195
void * reset_extra
Definition: guc_tables.h:243
int reset_val
Definition: guc_tables.h:242
int boot_val
Definition: guc_tables.h:235
GucIntAssignHook assign_hook
Definition: guc_tables.h:239
int * variable
Definition: guc_tables.h:234
GucIntCheckHook check_hook
Definition: guc_tables.h:238
GucShowHook show_hook
Definition: guc_tables.h:240
struct config_generic gen
Definition: guc_tables.h:232
double boot_val
Definition: guc_tables.h:251
void * reset_extra
Definition: guc_tables.h:259
double reset_val
Definition: guc_tables.h:258
GucRealAssignHook assign_hook
Definition: guc_tables.h:255
double * variable
Definition: guc_tables.h:250
double min
Definition: guc_tables.h:252
double max
Definition: guc_tables.h:253
struct config_generic gen
Definition: guc_tables.h:248
GucShowHook show_hook
Definition: guc_tables.h:256
GucRealCheckHook check_hook
Definition: guc_tables.h:254
struct config_generic gen
Definition: guc_tables.h:274
char * reset_val
Definition: guc_tables.h:282
GucStringCheckHook check_hook
Definition: guc_tables.h:278
GucStringAssignHook assign_hook
Definition: guc_tables.h:279
GucShowHook show_hook
Definition: guc_tables.h:280
char ** variable
Definition: guc_tables.h:276
void * reset_extra
Definition: guc_tables.h:283
const char * boot_val
Definition: guc_tables.h:277
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