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