]> granicus.if.org Git - postgresql/blob - src/include/utils/guc_tables.h
Update copyright for 2018
[postgresql] / src / include / utils / guc_tables.h
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  */
22 enum config_type
23 {
24         PGC_BOOL,
25         PGC_INT,
26         PGC_REAL,
27         PGC_STRING,
28         PGC_ENUM
29 };
30
31 union config_var_val
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;
48 } config_var_value;
49
50 /*
51  * Groupings to help organize all the run-time options for display
52  */
53 enum config_group
54 {
55         UNGROUPED,
56         FILE_LOCATIONS,
57         CONN_AUTH,
58         CONN_AUTH_SETTINGS,
59         CONN_AUTH_SECURITY,
60         RESOURCES,
61         RESOURCES_MEM,
62         RESOURCES_DISK,
63         RESOURCES_KERNEL,
64         RESOURCES_VACUUM_DELAY,
65         RESOURCES_BGWRITER,
66         RESOURCES_ASYNCHRONOUS,
67         WAL,
68         WAL_SETTINGS,
69         WAL_CHECKPOINTS,
70         WAL_ARCHIVING,
71         REPLICATION,
72         REPLICATION_SENDING,
73         REPLICATION_MASTER,
74         REPLICATION_STANDBY,
75         REPLICATION_SUBSCRIBERS,
76         QUERY_TUNING,
77         QUERY_TUNING_METHOD,
78         QUERY_TUNING_COST,
79         QUERY_TUNING_GEQO,
80         QUERY_TUNING_OTHER,
81         LOGGING,
82         LOGGING_WHERE,
83         LOGGING_WHEN,
84         LOGGING_WHAT,
85         PROCESS_TITLE,
86         STATS,
87         STATS_MONITORING,
88         STATS_COLLECTOR,
89         AUTOVACUUM,
90         CLIENT_CONN,
91         CLIENT_CONN_STATEMENT,
92         CLIENT_CONN_LOCALE,
93         CLIENT_CONN_PRELOAD,
94         CLIENT_CONN_OTHER,
95         LOCK_MANAGEMENT,
96         COMPAT_OPTIONS,
97         COMPAT_OPTIONS_PREVIOUS,
98         COMPAT_OPTIONS_CLIENT,
99         ERROR_HANDLING_OPTIONS,
100         PRESET_OPTIONS,
101         CUSTOM_OPTIONS,
102         DEVELOPER_OPTIONS
103 };
104
105 /*
106  * Stack entry for saving the state a variable had prior to an uncommitted
107  * transactional change
108  */
109 typedef enum
110 {
111         /* This is almost GucAction, but we need a fourth state for SET+LOCAL */
112         GUC_SAVE,                                       /* entry caused by function SET option */
113         GUC_SET,                                        /* entry caused by plain SET command */
114         GUC_LOCAL,                                      /* entry caused by SET LOCAL command */
115         GUC_SET_LOCAL                           /* entry caused by SET then SET LOCAL */
116 } GucStackState;
117
118 typedef struct guc_stack
119 {
120         struct guc_stack *prev;         /* previous stack item, if any */
121         int                     nest_level;             /* nesting depth at which we made entry */
122         GucStackState state;            /* see enum above */
123         GucSource       source;                 /* source of the prior value */
124         /* masked value's source must be PGC_S_SESSION, so no need to store it */
125         GucContext      scontext;               /* context that set the prior value */
126         GucContext      masked_scontext;        /* context 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 */
129 } GucStack;
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  * Note that sourcefile/sourceline are kept here, and not pushed into stacked
139  * values, although in principle they belong with some stacked value if the
140  * active value is session- or transaction-local.  This is to avoid bloating
141  * stack entries.  We know they are only relevant when source == PGC_S_FILE.
142  */
143 struct config_generic
144 {
145         /* constant fields, must be set correctly in initial value: */
146         const char *name;                       /* name of variable - MUST BE FIRST */
147         GucContext      context;                /* context required to set the variable */
148         enum config_group group;        /* to help organize variables by function */
149         const char *short_desc;         /* short desc. of this variable's purpose */
150         const char *long_desc;          /* long desc. of this variable's purpose */
151         int                     flags;                  /* flag bits, see guc.h */
152         /* variable fields, initialized at runtime: */
153         enum config_type vartype;       /* type of variable (set only at startup) */
154         int                     status;                 /* status bits, see below */
155         GucSource       source;                 /* source of the current actual value */
156         GucSource       reset_source;   /* source of the reset_value */
157         GucContext      scontext;               /* context that set the current value */
158         GucContext      reset_scontext; /* context that set the reset value */
159         GucStack   *stack;                      /* stacked prior values */
160         void       *extra;                      /* "extra" pointer for current actual value */
161         char       *sourcefile;         /* file current setting is from (NULL if not
162                                                                  * set in config file) */
163         int                     sourceline;             /* line in source file */
164 };
165
166 /* bit values in status field */
167 #define GUC_IS_IN_FILE          0x0001  /* found it in config file */
168 /*
169  * Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
170  * Do not assume that its value represents useful information elsewhere.
171  */
172 #define GUC_PENDING_RESTART 0x0002
173
174
175 /* GUC records for specific variable types */
176
177 struct config_bool
178 {
179         struct config_generic gen;
180         /* constant fields, must be set correctly in initial value: */
181         bool       *variable;
182         bool            boot_val;
183         GucBoolCheckHook check_hook;
184         GucBoolAssignHook assign_hook;
185         GucShowHook show_hook;
186         /* variable fields, initialized at runtime: */
187         bool            reset_val;
188         void       *reset_extra;
189 };
190
191 struct config_int
192 {
193         struct config_generic gen;
194         /* constant fields, must be set correctly in initial value: */
195         int                *variable;
196         int                     boot_val;
197         int                     min;
198         int                     max;
199         GucIntCheckHook check_hook;
200         GucIntAssignHook assign_hook;
201         GucShowHook show_hook;
202         /* variable fields, initialized at runtime: */
203         int                     reset_val;
204         void       *reset_extra;
205 };
206
207 struct config_real
208 {
209         struct config_generic gen;
210         /* constant fields, must be set correctly in initial value: */
211         double     *variable;
212         double          boot_val;
213         double          min;
214         double          max;
215         GucRealCheckHook check_hook;
216         GucRealAssignHook assign_hook;
217         GucShowHook show_hook;
218         /* variable fields, initialized at runtime: */
219         double          reset_val;
220         void       *reset_extra;
221 };
222
223 struct config_string
224 {
225         struct config_generic gen;
226         /* constant fields, must be set correctly in initial value: */
227         char      **variable;
228         const char *boot_val;
229         GucStringCheckHook check_hook;
230         GucStringAssignHook assign_hook;
231         GucShowHook show_hook;
232         /* variable fields, initialized at runtime: */
233         char       *reset_val;
234         void       *reset_extra;
235 };
236
237 struct config_enum
238 {
239         struct config_generic gen;
240         /* constant fields, must be set correctly in initial value: */
241         int                *variable;
242         int                     boot_val;
243         const struct config_enum_entry *options;
244         GucEnumCheckHook check_hook;
245         GucEnumAssignHook assign_hook;
246         GucShowHook show_hook;
247         /* variable fields, initialized at runtime: */
248         int                     reset_val;
249         void       *reset_extra;
250 };
251
252 /* constant tables corresponding to enums above and in guc.h */
253 extern const char *const config_group_names[];
254 extern const char *const config_type_names[];
255 extern const char *const GucContext_Names[];
256 extern const char *const GucSource_Names[];
257
258 /* get the current set of variables */
259 extern struct config_generic **get_guc_variables(void);
260
261 extern void build_guc_variables(void);
262
263 /* search in enum options */
264 extern const char *config_enum_lookup_by_value(struct config_enum *record, int val);
265 extern bool config_enum_lookup_by_name(struct config_enum *record,
266                                                    const char *value, int *retval);
267
268 #endif                                                  /* GUC_TABLES_H */