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-2022, 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 "utils/guc.h"
18 
19 /*
20  * GUC supports these types of variables:
21  */
23 {
28  PGC_ENUM
29 };
30 
32 {
33  bool boolval;
34  int intval;
35  double realval;
36  char *stringval;
37  int enumval;
38 };
39 
40 /*
41  * The actual value of a GUC variable can include a malloc'd opaque struct
42  * "extra", which is created by its check_hook and used by its assign_hook.
43  */
44 typedef struct config_var_value
45 {
46  union config_var_val val;
47  void *extra;
49 
50 /*
51  * Groupings to help organize all the run-time options for display.
52  * Be sure this agrees with the way the options are categorized in config.sgml!
53  */
55 {
56  UNGROUPED, /* use for options not shown in pg_settings */
99 };
100 
101 /*
102  * Stack entry for saving the state a variable had prior to an uncommitted
103  * transactional change
104  */
105 typedef enum
106 {
107  /* This is almost GucAction, but we need a fourth state for SET+LOCAL */
108  GUC_SAVE, /* entry caused by function SET option */
109  GUC_SET, /* entry caused by plain SET command */
110  GUC_LOCAL, /* entry caused by SET LOCAL command */
111  GUC_SET_LOCAL /* entry caused by SET then SET LOCAL */
113 
114 typedef struct guc_stack
115 {
116  struct guc_stack *prev; /* previous stack item, if any */
117  int nest_level; /* nesting depth at which we made entry */
118  GucStackState state; /* see enum above */
119  GucSource source; /* source of the prior value */
120  /* masked value's source must be PGC_S_SESSION, so no need to store it */
121  GucContext scontext; /* context that set the prior value */
122  GucContext masked_scontext; /* context that set the masked value */
123  config_var_value prior; /* previous value of variable */
124  config_var_value masked; /* SET value in a GUC_SET_LOCAL entry */
126 
127 /*
128  * Generic fields applicable to all types of variables
129  *
130  * The short description should be less than 80 chars in length. Some
131  * applications may use the long description as well, and will append
132  * it to the short description. (separated by a newline or '. ')
133  *
134  * Note that sourcefile/sourceline are kept here, and not pushed into stacked
135  * values, although in principle they belong with some stacked value if the
136  * active value is session- or transaction-local. This is to avoid bloating
137  * stack entries. We know they are only relevant when source == PGC_S_FILE.
138  */
140 {
141  /* constant fields, must be set correctly in initial value: */
142  const char *name; /* name of variable - MUST BE FIRST */
143  GucContext context; /* context required to set the variable */
144  enum config_group group; /* to help organize variables by function */
145  const char *short_desc; /* short desc. of this variable's purpose */
146  const char *long_desc; /* long desc. of this variable's purpose */
147  int flags; /* flag bits, see guc.h */
148  /* variable fields, initialized at runtime: */
149  enum config_type vartype; /* type of variable (set only at startup) */
150  int status; /* status bits, see below */
151  GucSource source; /* source of the current actual value */
152  GucSource reset_source; /* source of the reset_value */
153  GucContext scontext; /* context that set the current value */
154  GucContext reset_scontext; /* context that set the reset value */
155  GucStack *stack; /* stacked prior values */
156  void *extra; /* "extra" pointer for current actual value */
157  char *last_reported; /* if variable is GUC_REPORT, value last sent
158  * to client (NULL if not yet sent) */
159  char *sourcefile; /* file current setting is from (NULL if not
160  * set in config file) */
161  int sourceline; /* line in source file */
162 };
163 
164 /* bit values in status field */
165 #define GUC_IS_IN_FILE 0x0001 /* found it in config file */
166 /*
167  * Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
168  * Do not assume that its value represents useful information elsewhere.
169  */
170 #define GUC_PENDING_RESTART 0x0002 /* changed value cannot be applied yet */
171 #define GUC_NEEDS_REPORT 0x0004 /* new value must be reported to client */
172 
173 
174 /* GUC records for specific variable types */
175 
177 {
178  struct config_generic gen;
179  /* constant fields, must be set correctly in initial value: */
180  bool *variable;
181  bool boot_val;
185  /* variable fields, initialized at runtime: */
186  bool reset_val;
187  void *reset_extra;
188 };
189 
191 {
192  struct config_generic gen;
193  /* constant fields, must be set correctly in initial value: */
194  int *variable;
195  int boot_val;
196  int min;
197  int max;
201  /* variable fields, initialized at runtime: */
203  void *reset_extra;
204 };
205 
207 {
208  struct config_generic gen;
209  /* constant fields, must be set correctly in initial value: */
210  double *variable;
211  double boot_val;
212  double min;
213  double max;
217  /* variable fields, initialized at runtime: */
218  double reset_val;
219  void *reset_extra;
220 };
221 
223 {
224  struct config_generic gen;
225  /* constant fields, must be set correctly in initial value: */
226  char **variable;
227  const char *boot_val;
231  /* variable fields, initialized at runtime: */
232  char *reset_val;
233  void *reset_extra;
234 };
235 
237 {
238  struct config_generic gen;
239  /* constant fields, must be set correctly in initial value: */
240  int *variable;
241  int boot_val;
242  const struct config_enum_entry *options;
246  /* variable fields, initialized at runtime: */
248  void *reset_extra;
249 };
250 
251 /* constant tables corresponding to enums above and in guc.h */
252 extern PGDLLIMPORT const char *const config_group_names[];
253 extern PGDLLIMPORT const char *const config_type_names[];
254 extern PGDLLIMPORT const char *const GucContext_Names[];
255 extern PGDLLIMPORT const char *const GucSource_Names[];
256 
257 /* get the current set of variables */
258 extern struct config_generic **get_guc_variables(void);
259 
260 extern void build_guc_variables(void);
261 
262 /* search in enum options */
263 extern const char *config_enum_lookup_by_value(struct config_enum *record, int val);
264 extern bool config_enum_lookup_by_name(struct config_enum *record,
265  const char *value, int *retval);
266 extern struct config_generic **get_explain_guc_options(int *num);
267 
268 #endif /* GUC_TABLES_H */
#define PGDLLIMPORT
Definition: c.h:1342
bool(* GucBoolCheckHook)(bool *newval, void **extra, GucSource source)
Definition: guc.h:178
bool(* GucRealCheckHook)(double *newval, void **extra, GucSource source)
Definition: guc.h:180
void(* GucStringAssignHook)(const char *newval, void *extra)
Definition: guc.h:187
bool(* GucEnumCheckHook)(int *newval, void **extra, GucSource source)
Definition: guc.h:182
void(* GucBoolAssignHook)(bool newval, void *extra)
Definition: guc.h:184
void(* GucEnumAssignHook)(int newval, void *extra)
Definition: guc.h:188
const char *(* GucShowHook)(void)
Definition: guc.h:190
GucSource
Definition: guc.h:109
bool(* GucStringCheckHook)(char **newval, void **extra, GucSource source)
Definition: guc.h:181
void(* GucIntAssignHook)(int newval, void *extra)
Definition: guc.h:185
void(* GucRealAssignHook)(double newval, void *extra)
Definition: guc.h:186
GucContext
Definition: guc.h:69
bool(* GucIntCheckHook)(int *newval, void **extra, GucSource source)
Definition: guc.h:179
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:7256
PGDLLIMPORT const char *const GucContext_Names[]
Definition: guc.c:730
PGDLLIMPORT const char *const GucSource_Names[]
Definition: guc.c:749
bool config_enum_lookup_by_name(struct config_enum *record, const char *value, int *retval)
Definition: guc.c:7279
PGDLLIMPORT const char *const config_group_names[]
Definition: guc.c:773
struct guc_stack GucStack
struct config_generic ** get_guc_variables(void)
Definition: guc.c:5401
PGDLLIMPORT const char *const config_type_names[]
Definition: guc.c:873
void build_guc_variables(void)
Definition: guc.c:5413
struct config_generic ** get_explain_guc_options(int *num)
Definition: guc.c:9824
GucStackState
Definition: guc_tables.h:106
@ GUC_SET_LOCAL
Definition: guc_tables.h:111
@ GUC_SET
Definition: guc_tables.h:109
@ GUC_SAVE
Definition: guc_tables.h:108
@ GUC_LOCAL
Definition: guc_tables.h:110
config_group
Definition: guc_tables.h:55
@ RESOURCES_KERNEL
Definition: guc_tables.h:63
@ CLIENT_CONN_LOCALE
Definition: guc_tables.h:89
@ WAL_ARCHIVE_RECOVERY
Definition: guc_tables.h:71
@ STATS_CUMULATIVE
Definition: guc_tables.h:86
@ AUTOVACUUM
Definition: guc_tables.h:87
@ CLIENT_CONN_PRELOAD
Definition: guc_tables.h:90
@ QUERY_TUNING_OTHER
Definition: guc_tables.h:80
@ LOGGING_WHERE
Definition: guc_tables.h:81
@ CONN_AUTH_AUTH
Definition: guc_tables.h:59
@ ERROR_HANDLING_OPTIONS
Definition: guc_tables.h:95
@ PROCESS_TITLE
Definition: guc_tables.h:84
@ RESOURCES_DISK
Definition: guc_tables.h:62
@ REPLICATION_SENDING
Definition: guc_tables.h:73
@ LOCK_MANAGEMENT
Definition: guc_tables.h:92
@ CUSTOM_OPTIONS
Definition: guc_tables.h:97
@ REPLICATION_PRIMARY
Definition: guc_tables.h:74
@ STATS_MONITORING
Definition: guc_tables.h:85
@ WAL_RECOVERY_TARGET
Definition: guc_tables.h:72
@ WAL_RECOVERY
Definition: guc_tables.h:70
@ CONN_AUTH_SSL
Definition: guc_tables.h:60
@ RESOURCES_MEM
Definition: guc_tables.h:61
@ RESOURCES_BGWRITER
Definition: guc_tables.h:65
@ PRESET_OPTIONS
Definition: guc_tables.h:96
@ DEVELOPER_OPTIONS
Definition: guc_tables.h:98
@ RESOURCES_VACUUM_DELAY
Definition: guc_tables.h:64
@ QUERY_TUNING_METHOD
Definition: guc_tables.h:77
@ LOGGING_WHAT
Definition: guc_tables.h:83
@ RESOURCES_ASYNCHRONOUS
Definition: guc_tables.h:66
@ QUERY_TUNING_GEQO
Definition: guc_tables.h:79
@ WAL_SETTINGS
Definition: guc_tables.h:67
@ CLIENT_CONN_STATEMENT
Definition: guc_tables.h:88
@ FILE_LOCATIONS
Definition: guc_tables.h:57
@ COMPAT_OPTIONS_CLIENT
Definition: guc_tables.h:94
@ REPLICATION_STANDBY
Definition: guc_tables.h:75
@ QUERY_TUNING_COST
Definition: guc_tables.h:78
@ WAL_ARCHIVING
Definition: guc_tables.h:69
@ COMPAT_OPTIONS_PREVIOUS
Definition: guc_tables.h:93
@ WAL_CHECKPOINTS
Definition: guc_tables.h:68
@ CLIENT_CONN_OTHER
Definition: guc_tables.h:91
@ LOGGING_WHEN
Definition: guc_tables.h:82
@ REPLICATION_SUBSCRIBERS
Definition: guc_tables.h:76
@ CONN_AUTH_SETTINGS
Definition: guc_tables.h:58
@ UNGROUPED
Definition: guc_tables.h:56
config_type
Definition: guc_tables.h:23
@ PGC_BOOL
Definition: guc_tables.h:24
@ PGC_STRING
Definition: guc_tables.h:27
@ PGC_ENUM
Definition: guc_tables.h:28
@ PGC_REAL
Definition: guc_tables.h:26
@ PGC_INT
Definition: guc_tables.h:25
struct config_var_value config_var_value
static struct @151 value
long val
Definition: informix.c:664
void * reset_extra
Definition: guc_tables.h:187
struct config_generic gen
Definition: guc_tables.h:178
bool * variable
Definition: guc_tables.h:180
GucBoolCheckHook check_hook
Definition: guc_tables.h:182
bool reset_val
Definition: guc_tables.h:186
GucBoolAssignHook assign_hook
Definition: guc_tables.h:183
bool boot_val
Definition: guc_tables.h:181
GucShowHook show_hook
Definition: guc_tables.h:184
Definition: guc.h:169
const struct config_enum_entry * options
Definition: guc_tables.h:242
int * variable
Definition: guc_tables.h:240
GucEnumAssignHook assign_hook
Definition: guc_tables.h:244
struct config_generic gen
Definition: guc_tables.h:238
void * reset_extra
Definition: guc_tables.h:248
GucEnumCheckHook check_hook
Definition: guc_tables.h:243
GucShowHook show_hook
Definition: guc_tables.h:245
char * last_reported
Definition: guc_tables.h:157
enum config_group group
Definition: guc_tables.h:144
GucContext context
Definition: guc_tables.h:143
const char * long_desc
Definition: guc_tables.h:146
GucContext scontext
Definition: guc_tables.h:153
const char * name
Definition: guc_tables.h:142
const char * short_desc
Definition: guc_tables.h:145
char * sourcefile
Definition: guc_tables.h:159
GucContext reset_scontext
Definition: guc_tables.h:154
GucStack * stack
Definition: guc_tables.h:155
enum config_type vartype
Definition: guc_tables.h:149
GucSource source
Definition: guc_tables.h:151
GucSource reset_source
Definition: guc_tables.h:152
void * reset_extra
Definition: guc_tables.h:203
int reset_val
Definition: guc_tables.h:202
int boot_val
Definition: guc_tables.h:195
GucIntAssignHook assign_hook
Definition: guc_tables.h:199
int * variable
Definition: guc_tables.h:194
GucIntCheckHook check_hook
Definition: guc_tables.h:198
GucShowHook show_hook
Definition: guc_tables.h:200
struct config_generic gen
Definition: guc_tables.h:192
double boot_val
Definition: guc_tables.h:211
void * reset_extra
Definition: guc_tables.h:219
double reset_val
Definition: guc_tables.h:218
GucRealAssignHook assign_hook
Definition: guc_tables.h:215
double * variable
Definition: guc_tables.h:210
double min
Definition: guc_tables.h:212
double max
Definition: guc_tables.h:213
struct config_generic gen
Definition: guc_tables.h:208
GucShowHook show_hook
Definition: guc_tables.h:216
GucRealCheckHook check_hook
Definition: guc_tables.h:214
struct config_generic gen
Definition: guc_tables.h:224
char * reset_val
Definition: guc_tables.h:232
GucStringCheckHook check_hook
Definition: guc_tables.h:228
GucStringAssignHook assign_hook
Definition: guc_tables.h:229
GucShowHook show_hook
Definition: guc_tables.h:230
char ** variable
Definition: guc_tables.h:226
void * reset_extra
Definition: guc_tables.h:233
const char * boot_val
Definition: guc_tables.h:227
union config_var_val val
Definition: guc_tables.h:46
struct guc_stack * prev
Definition: guc_tables.h:116
int nest_level
Definition: guc_tables.h:117
config_var_value masked
Definition: guc_tables.h:124
config_var_value prior
Definition: guc_tables.h:123
GucContext scontext
Definition: guc_tables.h:121
GucStackState state
Definition: guc_tables.h:118
GucSource source
Definition: guc_tables.h:119
GucContext masked_scontext
Definition: guc_tables.h:122
double realval
Definition: guc_tables.h:35
char * stringval
Definition: guc_tables.h:36