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