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