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-2021, 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 {
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 {
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 */
98 };
99 
100 /*
101  * Stack entry for saving the state a variable had prior to an uncommitted
102  * transactional change
103  */
104 typedef enum
105 {
106  /* This is almost GucAction, but we need a fourth state for SET+LOCAL */
107  GUC_SAVE, /* entry caused by function SET option */
108  GUC_SET, /* entry caused by plain SET command */
109  GUC_LOCAL, /* entry caused by SET LOCAL command */
110  GUC_SET_LOCAL /* entry caused by SET then SET LOCAL */
111 } GucStackState;
112 
113 typedef struct guc_stack
114 {
115  struct guc_stack *prev; /* previous stack item, if any */
116  int nest_level; /* nesting depth at which we made entry */
117  GucStackState state; /* see enum above */
118  GucSource source; /* source of the prior value */
119  /* masked value's source must be PGC_S_SESSION, so no need to store it */
120  GucContext scontext; /* context that set the prior value */
121  GucContext masked_scontext; /* context that set the masked value */
122  config_var_value prior; /* previous value of variable */
123  config_var_value masked; /* SET value in a GUC_SET_LOCAL entry */
124 } GucStack;
125 
126 /*
127  * Generic fields applicable to all types of variables
128  *
129  * The short description should be less than 80 chars in length. Some
130  * applications may use the long description as well, and will append
131  * it to the short description. (separated by a newline or '. ')
132  *
133  * Note that sourcefile/sourceline are kept here, and not pushed into stacked
134  * values, although in principle they belong with some stacked value if the
135  * active value is session- or transaction-local. This is to avoid bloating
136  * stack entries. We know they are only relevant when source == PGC_S_FILE.
137  */
139 {
140  /* constant fields, must be set correctly in initial value: */
141  const char *name; /* name of variable - MUST BE FIRST */
142  GucContext context; /* context required to set the variable */
143  enum config_group group; /* to help organize variables by function */
144  const char *short_desc; /* short desc. of this variable's purpose */
145  const char *long_desc; /* long desc. of this variable's purpose */
146  int flags; /* flag bits, see guc.h */
147  /* variable fields, initialized at runtime: */
148  enum config_type vartype; /* type of variable (set only at startup) */
149  int status; /* status bits, see below */
150  GucSource source; /* source of the current actual value */
151  GucSource reset_source; /* source of the reset_value */
152  GucContext scontext; /* context that set the current value */
153  GucContext reset_scontext; /* context that set the reset value */
154  GucStack *stack; /* stacked prior values */
155  void *extra; /* "extra" pointer for current actual value */
156  char *last_reported; /* if variable is GUC_REPORT, value last sent
157  * to client (NULL if not yet sent) */
158  char *sourcefile; /* file current setting is from (NULL if not
159  * set in config file) */
160  int sourceline; /* line in source file */
161 };
162 
163 /* bit values in status field */
164 #define GUC_IS_IN_FILE 0x0001 /* found it in config file */
165 /*
166  * Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
167  * Do not assume that its value represents useful information elsewhere.
168  */
169 #define GUC_PENDING_RESTART 0x0002 /* changed value cannot be applied yet */
170 #define GUC_NEEDS_REPORT 0x0004 /* new value must be reported to client */
171 
172 
173 /* GUC records for specific variable types */
174 
176 {
177  struct config_generic gen;
178  /* constant fields, must be set correctly in initial value: */
179  bool *variable;
180  bool boot_val;
184  /* variable fields, initialized at runtime: */
185  bool reset_val;
186  void *reset_extra;
187 };
188 
190 {
191  struct config_generic gen;
192  /* constant fields, must be set correctly in initial value: */
193  int *variable;
194  int boot_val;
195  int min;
196  int max;
200  /* variable fields, initialized at runtime: */
202  void *reset_extra;
203 };
204 
206 {
207  struct config_generic gen;
208  /* constant fields, must be set correctly in initial value: */
209  double *variable;
210  double boot_val;
211  double min;
212  double max;
216  /* variable fields, initialized at runtime: */
217  double reset_val;
218  void *reset_extra;
219 };
220 
222 {
223  struct config_generic gen;
224  /* constant fields, must be set correctly in initial value: */
225  char **variable;
226  const char *boot_val;
230  /* variable fields, initialized at runtime: */
231  char *reset_val;
232  void *reset_extra;
233 };
234 
236 {
237  struct config_generic gen;
238  /* constant fields, must be set correctly in initial value: */
239  int *variable;
240  int boot_val;
241  const struct config_enum_entry *options;
245  /* variable fields, initialized at runtime: */
247  void *reset_extra;
248 };
249 
250 /* constant tables corresponding to enums above and in guc.h */
251 extern const char *const config_group_names[];
252 extern const char *const config_type_names[];
253 extern const char *const GucContext_Names[];
254 extern const char *const GucSource_Names[];
255 
256 /* get the current set of variables */
257 extern struct config_generic **get_guc_variables(void);
258 
259 extern void build_guc_variables(void);
260 
261 /* search in enum options */
262 extern const char *config_enum_lookup_by_value(struct config_enum *record, int val);
263 extern bool config_enum_lookup_by_name(struct config_enum *record,
264  const char *value, int *retval);
265 extern struct config_generic **get_explain_guc_options(int *num);
266 
267 #endif /* GUC_TABLES_H */
struct guc_stack * prev
Definition: guc_tables.h:115
GucSource source
Definition: guc_tables.h:150
GucEnumCheckHook check_hook
Definition: guc_tables.h:242
void * reset_extra
Definition: guc_tables.h:202
GucContext
Definition: guc.h:68
void(* GucBoolAssignHook)(bool newval, void *extra)
Definition: guc.h:180
config_group
Definition: guc_tables.h:54
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:6999
int nest_level
Definition: guc_tables.h:116
const char * long_desc
Definition: guc_tables.h:145
const char *const config_type_names[]
Definition: guc.c:830
GucRealAssignHook assign_hook
Definition: guc_tables.h:214
double reset_val
Definition: guc_tables.h:217
bool(* GucEnumCheckHook)(int *newval, void **extra, GucSource source)
Definition: guc.h:178
bool(* GucBoolCheckHook)(bool *newval, void **extra, GucSource source)
Definition: guc.h:174
Definition: guc.h:164
char ** variable
Definition: guc_tables.h:225
const char * name
Definition: guc_tables.h:141
bool * variable
Definition: guc_tables.h:179
const char * short_desc
Definition: guc_tables.h:144
int boot_val
Definition: guc_tables.h:194
GucStringCheckHook check_hook
Definition: guc_tables.h:227
const char * boot_val
Definition: guc_tables.h:226
GucEnumAssignHook assign_hook
Definition: guc_tables.h:243
const char *(* GucShowHook)(void)
Definition: guc.h:186
GucBoolAssignHook assign_hook
Definition: guc_tables.h:182
config_var_value masked
Definition: guc_tables.h:123
void build_guc_variables(void)
Definition: guc.c:5276
void(* GucStringAssignHook)(const char *newval, void *extra)
Definition: guc.h:183
GucRealCheckHook check_hook
Definition: guc_tables.h:213
GucContext scontext
Definition: guc_tables.h:152
struct config_var_value config_var_value
GucIntAssignHook assign_hook
Definition: guc_tables.h:198
GucIntCheckHook check_hook
Definition: guc_tables.h:197
GucStackState
Definition: guc_tables.h:104
void(* GucIntAssignHook)(int newval, void *extra)
Definition: guc.h:181
GucSource
Definition: guc.h:104
bool(* GucIntCheckHook)(int *newval, void **extra, GucSource source)
Definition: guc.h:175
GucShowHook show_hook
Definition: guc_tables.h:199
int * variable
Definition: guc_tables.h:193
int * variable
Definition: guc_tables.h:239
struct config_generic ** get_explain_guc_options(int *num)
Definition: guc.c:9469
void * reset_extra
Definition: guc_tables.h:247
char * sourcefile
Definition: guc_tables.h:158
bool boot_val
Definition: guc_tables.h:180
const struct config_enum_entry * options
Definition: guc_tables.h:241
bool config_enum_lookup_by_name(struct config_enum *record, const char *value, int *retval)
Definition: guc.c:7022
GucSource source
Definition: guc_tables.h:118
GucShowHook show_hook
Definition: guc_tables.h:229
GucSource reset_source
Definition: guc_tables.h:151
GucContext masked_scontext
Definition: guc_tables.h:121
GucShowHook show_hook
Definition: guc_tables.h:215
double * variable
Definition: guc_tables.h:209
const char *const config_group_names[]
Definition: guc.c:732
const char *const GucContext_Names[]
Definition: guc.c:689
void * reset_extra
Definition: guc_tables.h:218
GucShowHook show_hook
Definition: guc_tables.h:244
GucContext scontext
Definition: guc_tables.h:120
config_type
Definition: guc_tables.h:22
bool(* GucRealCheckHook)(double *newval, void **extra, GucSource source)
Definition: guc.h:176
double max
Definition: guc_tables.h:212
GucBoolCheckHook check_hook
Definition: guc_tables.h:181
struct guc_stack GucStack
GucShowHook show_hook
Definition: guc_tables.h:183
static struct @143 value
const char *const GucSource_Names[]
Definition: guc.c:708
char * last_reported
Definition: guc_tables.h:156
struct config_generic ** get_guc_variables(void)
Definition: guc.c:5264
char * reset_val
Definition: guc_tables.h:231
GucStackState state
Definition: guc_tables.h:117
GucStringAssignHook assign_hook
Definition: guc_tables.h:228
double boot_val
Definition: guc_tables.h:210
void(* GucEnumAssignHook)(int newval, void *extra)
Definition: guc.h:184
double min
Definition: guc_tables.h:211
void * reset_extra
Definition: guc_tables.h:232
void * reset_extra
Definition: guc_tables.h:186
char * stringval
Definition: guc_tables.h:36
GucStack * stack
Definition: guc_tables.h:154
void(* GucRealAssignHook)(double newval, void *extra)
Definition: guc.h:182
double realval
Definition: guc_tables.h:35
bool reset_val
Definition: guc_tables.h:185
bool(* GucStringCheckHook)(char **newval, void **extra, GucSource source)
Definition: guc.h:177
long val
Definition: informix.c:664
config_var_value prior
Definition: guc_tables.h:122
GucContext context
Definition: guc_tables.h:142
GucContext reset_scontext
Definition: guc_tables.h:153
int reset_val
Definition: guc_tables.h:201