]> granicus.if.org Git - postgresql/blob - src/include/utils/guc_tables.h
d3b25812a02866bf6dbabe373592de31f88e3509
[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-2011, 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_MASTER,
73         REPLICATION_STANDBY,
74         QUERY_TUNING,
75         QUERY_TUNING_METHOD,
76         QUERY_TUNING_COST,
77         QUERY_TUNING_GEQO,
78         QUERY_TUNING_OTHER,
79         LOGGING,
80         LOGGING_WHERE,
81         LOGGING_WHEN,
82         LOGGING_WHAT,
83         STATS,
84         STATS_MONITORING,
85         STATS_COLLECTOR,
86         AUTOVACUUM,
87         CLIENT_CONN,
88         CLIENT_CONN_STATEMENT,
89         CLIENT_CONN_LOCALE,
90         CLIENT_CONN_OTHER,
91         LOCK_MANAGEMENT,
92         COMPAT_OPTIONS,
93         COMPAT_OPTIONS_PREVIOUS,
94         COMPAT_OPTIONS_CLIENT,
95         ERROR_HANDLING_OPTIONS,
96         PRESET_OPTIONS,
97         CUSTOM_OPTIONS,
98         DEVELOPER_OPTIONS
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 */
112 } GucStackState;
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         config_var_value prior;         /* previous value of variable */
121         config_var_value masked;        /* SET value in a GUC_SET_LOCAL entry */
122         /* masked value's source must be PGC_S_SESSION, so no need to store it */
123 } GucStack;
124
125 /*
126  * Generic fields applicable to all types of variables
127  *
128  * The short description should be less than 80 chars in length. Some
129  * applications may use the long description as well, and will append
130  * it to the short description. (separated by a newline or '. ')
131  *
132  * Note that sourcefile/sourceline are kept here, and not pushed into stacked
133  * values, although in principle they belong with some stacked value if the
134  * active value is session- or transaction-local.  This is to avoid bloating
135  * stack entries.  We know they are only relevant when source == PGC_S_FILE.
136  */
137 struct config_generic
138 {
139         /* constant fields, must be set correctly in initial value: */
140         const char *name;                       /* name of variable - MUST BE FIRST */
141         GucContext      context;                /* context required to set the variable */
142         enum config_group group;        /* to help organize variables by function */
143         const char *short_desc;         /* short desc. of this variable's purpose */
144         const char *long_desc;          /* long desc. of this variable's purpose */
145         int                     flags;                  /* flag bits, see below */
146         /* variable fields, initialized at runtime: */
147         enum config_type vartype;       /* type of variable (set only at startup) */
148         int                     status;                 /* status bits, see below */
149         GucSource       reset_source;   /* source of the reset_value */
150         GucSource       source;                 /* source of the current actual value */
151         GucStack   *stack;                      /* stacked prior values */
152         void       *extra;                      /* "extra" pointer for current actual value */
153         char       *sourcefile;         /* file current setting is from (NULL if not
154                                                                  * file) */
155         int                     sourceline;             /* line in source file */
156 };
157
158 /* bit values in flags field are defined in guc.h */
159
160 /* bit values in status field */
161 #define GUC_IS_IN_FILE          0x0001          /* found it in config file */
162 /*
163  * Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
164  * Do not assume that its value represents useful information elsewhere.
165  */
166
167
168 /* GUC records for specific variable types */
169
170 struct config_bool
171 {
172         struct config_generic gen;
173         /* constant fields, must be set correctly in initial value: */
174         bool       *variable;
175         bool            boot_val;
176         GucBoolCheckHook check_hook;
177         GucBoolAssignHook assign_hook;
178         GucShowHook show_hook;
179         /* variable fields, initialized at runtime: */
180         bool            reset_val;
181         void       *reset_extra;
182 };
183
184 struct config_int
185 {
186         struct config_generic gen;
187         /* constant fields, must be set correctly in initial value: */
188         int                *variable;
189         int                     boot_val;
190         int                     min;
191         int                     max;
192         GucIntCheckHook check_hook;
193         GucIntAssignHook assign_hook;
194         GucShowHook show_hook;
195         /* variable fields, initialized at runtime: */
196         int                     reset_val;
197         void       *reset_extra;
198 };
199
200 struct config_real
201 {
202         struct config_generic gen;
203         /* constant fields, must be set correctly in initial value: */
204         double     *variable;
205         double          boot_val;
206         double          min;
207         double          max;
208         GucRealCheckHook check_hook;
209         GucRealAssignHook assign_hook;
210         GucShowHook show_hook;
211         /* variable fields, initialized at runtime: */
212         double          reset_val;
213         void       *reset_extra;
214 };
215
216 struct config_string
217 {
218         struct config_generic gen;
219         /* constant fields, must be set correctly in initial value: */
220         char      **variable;
221         const char *boot_val;
222         GucStringCheckHook check_hook;
223         GucStringAssignHook assign_hook;
224         GucShowHook show_hook;
225         /* variable fields, initialized at runtime: */
226         char       *reset_val;
227         void       *reset_extra;
228 };
229
230 struct config_enum
231 {
232         struct config_generic gen;
233         /* constant fields, must be set correctly in initial value: */
234         int                *variable;
235         int                     boot_val;
236         const struct config_enum_entry *options;
237         GucEnumCheckHook check_hook;
238         GucEnumAssignHook assign_hook;
239         GucShowHook show_hook;
240         /* variable fields, initialized at runtime: */
241         int                     reset_val;
242         void       *reset_extra;
243 };
244
245 /* constant tables corresponding to enums above and in guc.h */
246 extern const char *const config_group_names[];
247 extern const char *const config_type_names[];
248 extern const char *const GucContext_Names[];
249 extern const char *const GucSource_Names[];
250
251 /* get the current set of variables */
252 extern struct config_generic **get_guc_variables(void);
253
254 extern void build_guc_variables(void);
255
256 /* search in enum options */
257 extern const char *config_enum_lookup_by_value(struct config_enum * record, int val);
258 extern bool config_enum_lookup_by_name(struct config_enum * record,
259                                                    const char *value, int *retval);
260
261
262 #endif   /* GUC_TABLES_H */