]> granicus.if.org Git - postgresql/blob - src/include/utils/guc_tables.h
Code review for GUC revert-values-if-removed-from-postgresql.conf patch;
[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-2007, PostgreSQL Global Development Group
9  *
10  *        $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.34 2007/09/10 00:57:22 tgl Exp $
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 };
29
30 union config_var_value
31 {
32         bool            boolval;
33         int                     intval;
34         double          realval;
35         char       *stringval;
36 };
37
38 /*
39  * Groupings to help organize all the run-time options for display
40  */
41 enum config_group
42 {
43         UNGROUPED,
44         FILE_LOCATIONS,
45         CONN_AUTH,
46         CONN_AUTH_SETTINGS,
47         CONN_AUTH_SECURITY,
48         RESOURCES,
49         RESOURCES_MEM,
50         RESOURCES_FSM,
51         RESOURCES_KERNEL,
52         WAL,
53         WAL_SETTINGS,
54         WAL_CHECKPOINTS,
55         QUERY_TUNING,
56         QUERY_TUNING_METHOD,
57         QUERY_TUNING_COST,
58         QUERY_TUNING_GEQO,
59         QUERY_TUNING_OTHER,
60         LOGGING,
61         LOGGING_WHERE,
62         LOGGING_WHEN,
63         LOGGING_WHAT,
64         STATS,
65         STATS_MONITORING,
66         STATS_COLLECTOR,
67         AUTOVACUUM,
68         CLIENT_CONN,
69         CLIENT_CONN_STATEMENT,
70         CLIENT_CONN_LOCALE,
71         CLIENT_CONN_OTHER,
72         LOCK_MANAGEMENT,
73         COMPAT_OPTIONS,
74         COMPAT_OPTIONS_PREVIOUS,
75         COMPAT_OPTIONS_CLIENT,
76         PRESET_OPTIONS,
77         CUSTOM_OPTIONS,
78         DEVELOPER_OPTIONS
79 };
80
81 /*
82  * Stack entry for saving the state of a variable prior to the current
83  * transaction
84  */
85 typedef struct guc_stack
86 {
87         struct guc_stack *prev;         /* previous stack item, if any */
88         int                     nest_level;             /* nesting depth of cur transaction */
89         int                     status;                 /* previous status bits, see below */
90         GucSource       tentative_source;               /* source of the tentative_value */
91         GucSource       source;                 /* source of the actual value */
92         union config_var_value tentative_val;           /* previous tentative val */
93         union config_var_value value;           /* previous actual value */
94 } GucStack;
95
96 /*
97  * Generic fields applicable to all types of variables
98  *
99  * The short description should be less than 80 chars in length. Some
100  * applications may use the long description as well, and will append
101  * it to the short description. (separated by a newline or '. ')
102  */
103 struct config_generic
104 {
105         /* constant fields, must be set correctly in initial value: */
106         const char *name;                       /* name of variable - MUST BE FIRST */
107         GucContext      context;                /* context required to set the variable */
108         enum config_group group;        /* to help organize variables by function */
109         const char *short_desc;         /* short desc. of this variable's purpose */
110         const char *long_desc;          /* long desc. of this variable's purpose */
111         int                     flags;                  /* flag bits, see below */
112         /* variable fields, initialized at runtime: */
113         enum config_type vartype;       /* type of variable (set only at startup) */
114         int                     status;                 /* status bits, see below */
115         GucSource       reset_source;   /* source of the reset_value */
116         GucSource       tentative_source;               /* source of the tentative_value */
117         GucSource       source;                 /* source of the current actual value */
118         GucStack   *stack;                      /* stacked outside-of-transaction states */
119 };
120
121 /* bit values in flags field */
122 #define GUC_LIST_INPUT                  0x0001  /* input can be list format */
123 #define GUC_LIST_QUOTE                  0x0002  /* double-quote list elements */
124 #define GUC_NO_SHOW_ALL                 0x0004  /* exclude from SHOW ALL */
125 #define GUC_NO_RESET_ALL                0x0008  /* exclude from RESET ALL */
126 #define GUC_REPORT                              0x0010  /* auto-report changes to client */
127 #define GUC_NOT_IN_SAMPLE               0x0020  /* not in postgresql.conf.sample */
128 #define GUC_DISALLOW_IN_FILE    0x0040  /* can't set in postgresql.conf */
129 #define GUC_CUSTOM_PLACEHOLDER  0x0080  /* placeholder for custom variable */
130 #define GUC_SUPERUSER_ONLY              0x0100  /* show only to superusers */
131 #define GUC_IS_NAME                             0x0200  /* limit string to NAMEDATALEN-1 */
132
133 #define GUC_UNIT_KB                             0x0400  /* value is in kilobytes */
134 #define GUC_UNIT_BLOCKS                 0x0800  /* value is in blocks */
135 #define GUC_UNIT_XBLOCKS                0x0C00  /* value is in xlog blocks */
136 #define GUC_UNIT_MEMORY                 0x0C00  /* mask for KB, BLOCKS, XBLOCKS */
137
138 #define GUC_UNIT_MS                             0x1000  /* value is in milliseconds */
139 #define GUC_UNIT_S                              0x2000  /* value is in seconds */
140 #define GUC_UNIT_MIN                    0x4000  /* value is in minutes */
141 #define GUC_UNIT_TIME                   0x7000  /* mask for MS, S, MIN */
142
143 /* bit values in status field */
144 #define GUC_HAVE_TENTATIVE      0x0001          /* tentative value is defined */
145 #define GUC_HAVE_LOCAL          0x0002          /* a SET LOCAL has been executed */
146 #define GUC_HAVE_STACK          0x0004          /* we have stacked prior value(s) */
147 #define GUC_IS_IN_FILE          0x0008          /* found it in config file */
148 /*
149  * Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
150  * Do not assume that its value represents useful information elsewhere.
151  */
152
153
154 /* GUC records for specific variable types */
155
156 struct config_bool
157 {
158         struct config_generic gen;
159         /* constant fields, must be set correctly in initial value: */
160         bool       *variable;
161         bool            boot_val;
162         GucBoolAssignHook assign_hook;
163         GucShowHook show_hook;
164         /* variable fields, initialized at runtime: */
165         bool            reset_val;
166         bool            tentative_val;
167 };
168
169 struct config_int
170 {
171         struct config_generic gen;
172         /* constant fields, must be set correctly in initial value: */
173         int                *variable;
174         int                     boot_val;
175         int                     min;
176         int                     max;
177         GucIntAssignHook assign_hook;
178         GucShowHook show_hook;
179         /* variable fields, initialized at runtime: */
180         int                     reset_val;
181         int                     tentative_val;
182 };
183
184 struct config_real
185 {
186         struct config_generic gen;
187         /* constant fields, must be set correctly in initial value: */
188         double     *variable;
189         double          boot_val;
190         double          min;
191         double          max;
192         GucRealAssignHook assign_hook;
193         GucShowHook show_hook;
194         /* variable fields, initialized at runtime: */
195         double          reset_val;
196         double          tentative_val;
197 };
198
199 struct config_string
200 {
201         struct config_generic gen;
202         /* constant fields, must be set correctly in initial value: */
203         char      **variable;
204         const char *boot_val;
205         GucStringAssignHook assign_hook;
206         GucShowHook show_hook;
207         /* variable fields, initialized at runtime: */
208         char       *reset_val;
209         char       *tentative_val;
210 };
211
212 /* constant tables corresponding to enums above and in guc.h */
213 extern const char *const config_group_names[];
214 extern const char *const config_type_names[];
215 extern const char *const GucContext_Names[];
216 extern const char *const GucSource_Names[];
217
218 /* get the current set of variables */
219 extern struct config_generic **get_guc_variables(void);
220
221 extern void build_guc_variables(void);
222
223 #endif   /* GUC_TABLES_H */