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