OSDN Git Service

Introduce Streaming Replication.
[pg-rex/syncrep.git] / 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-2010, PostgreSQL Global Development Group
9  *
10  *        $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.48 2010/01/15 09:19:09 heikki 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         PGC_ENUM
29 };
30
31 union config_var_value
32 {
33         bool            boolval;
34         int                     intval;
35         double          realval;
36         char       *stringval;
37         int                     enumval;
38 };
39
40 /*
41  * Groupings to help organize all the run-time options for display
42  */
43 enum config_group
44 {
45         UNGROUPED,
46         FILE_LOCATIONS,
47         CONN_AUTH,
48         CONN_AUTH_SETTINGS,
49         CONN_AUTH_SECURITY,
50         RESOURCES,
51         RESOURCES_MEM,
52         RESOURCES_KERNEL,
53         WAL,
54         WAL_SETTINGS,
55         WAL_CHECKPOINTS,
56         WAL_REPLICATION,
57         QUERY_TUNING,
58         QUERY_TUNING_METHOD,
59         QUERY_TUNING_COST,
60         QUERY_TUNING_GEQO,
61         QUERY_TUNING_OTHER,
62         LOGGING,
63         LOGGING_WHERE,
64         LOGGING_WHEN,
65         LOGGING_WHAT,
66         STATS,
67         STATS_MONITORING,
68         STATS_COLLECTOR,
69         AUTOVACUUM,
70         CLIENT_CONN,
71         CLIENT_CONN_STATEMENT,
72         CLIENT_CONN_LOCALE,
73         CLIENT_CONN_OTHER,
74         LOCK_MANAGEMENT,
75         COMPAT_OPTIONS,
76         COMPAT_OPTIONS_PREVIOUS,
77         COMPAT_OPTIONS_CLIENT,
78         PRESET_OPTIONS,
79         CUSTOM_OPTIONS,
80         DEVELOPER_OPTIONS
81 };
82
83 /*
84  * Stack entry for saving the state a variable had prior to an uncommitted
85  * transactional change
86  */
87 typedef enum
88 {
89         /* This is almost GucAction, but we need a fourth state for SET+LOCAL */
90         GUC_SAVE,                                       /* entry caused by function SET option */
91         GUC_SET,                                        /* entry caused by plain SET command */
92         GUC_LOCAL,                                      /* entry caused by SET LOCAL command */
93         GUC_SET_LOCAL                           /* entry caused by SET then SET LOCAL */
94 } GucStackState;
95
96 typedef struct guc_stack
97 {
98         struct guc_stack *prev;         /* previous stack item, if any */
99         int                     nest_level;             /* nesting depth at which we made entry */
100         GucStackState state;            /* see enum above */
101         GucSource       source;                 /* source of the prior value */
102         union config_var_value prior;           /* previous value of variable */
103         union config_var_value masked;          /* SET value in a GUC_SET_LOCAL entry */
104         /* masked value's source must be PGC_S_SESSION, so no need to store it */
105 } GucStack;
106
107 /*
108  * Generic fields applicable to all types of variables
109  *
110  * The short description should be less than 80 chars in length. Some
111  * applications may use the long description as well, and will append
112  * it to the short description. (separated by a newline or '. ')
113  */
114 struct config_generic
115 {
116         /* constant fields, must be set correctly in initial value: */
117         const char *name;                       /* name of variable - MUST BE FIRST */
118         GucContext      context;                /* context required to set the variable */
119         enum config_group group;        /* to help organize variables by function */
120         const char *short_desc;         /* short desc. of this variable's purpose */
121         const char *long_desc;          /* long desc. of this variable's purpose */
122         int                     flags;                  /* flag bits, see below */
123         /* variable fields, initialized at runtime: */
124         enum config_type vartype;       /* type of variable (set only at startup) */
125         int                     status;                 /* status bits, see below */
126         GucSource       reset_source;   /* source of the reset_value */
127         GucSource       source;                 /* source of the current actual value */
128         GucStack   *stack;                      /* stacked prior values */
129         char       *sourcefile;         /* file this settings is from (NULL if not
130                                                                  * file) */
131         int                     sourceline;             /* line in source file */
132 };
133
134 /* bit values in flags field are defined in guc.h */
135
136 /* bit values in status field */
137 #define GUC_IS_IN_FILE          0x0001          /* found it in config file */
138 /*
139  * Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
140  * Do not assume that its value represents useful information elsewhere.
141  */
142
143
144 /* GUC records for specific variable types */
145
146 struct config_bool
147 {
148         struct config_generic gen;
149         /* constant fields, must be set correctly in initial value: */
150         bool       *variable;
151         bool            boot_val;
152         GucBoolAssignHook assign_hook;
153         GucShowHook show_hook;
154         /* variable fields, initialized at runtime: */
155         bool            reset_val;
156 };
157
158 struct config_int
159 {
160         struct config_generic gen;
161         /* constant fields, must be set correctly in initial value: */
162         int                *variable;
163         int                     boot_val;
164         int                     min;
165         int                     max;
166         GucIntAssignHook assign_hook;
167         GucShowHook show_hook;
168         /* variable fields, initialized at runtime: */
169         int                     reset_val;
170 };
171
172 struct config_real
173 {
174         struct config_generic gen;
175         /* constant fields, must be set correctly in initial value: */
176         double     *variable;
177         double          boot_val;
178         double          min;
179         double          max;
180         GucRealAssignHook assign_hook;
181         GucShowHook show_hook;
182         /* variable fields, initialized at runtime: */
183         double          reset_val;
184 };
185
186 struct config_string
187 {
188         struct config_generic gen;
189         /* constant fields, must be set correctly in initial value: */
190         char      **variable;
191         const char *boot_val;
192         GucStringAssignHook assign_hook;
193         GucShowHook show_hook;
194         /* variable fields, initialized at runtime: */
195         char       *reset_val;
196 };
197
198 struct config_enum
199 {
200         struct config_generic gen;
201         /* constant fields, must be set correctly in initial value: */
202         int                *variable;
203         int                     boot_val;
204         const struct config_enum_entry *options;
205         GucEnumAssignHook assign_hook;
206         GucShowHook show_hook;
207         /* variable fields, initialized at runtime: */
208         int                     reset_val;
209 };
210
211 /* constant tables corresponding to enums above and in guc.h */
212 extern const char *const config_group_names[];
213 extern const char *const config_type_names[];
214 extern const char *const GucContext_Names[];
215 extern const char *const GucSource_Names[];
216
217 /* get the current set of variables */
218 extern struct config_generic **get_guc_variables(void);
219
220 extern void build_guc_variables(void);
221
222 /* search in enum options */
223 extern const char *config_enum_lookup_by_value(struct config_enum * record, int val);
224 extern bool config_enum_lookup_by_name(struct config_enum * record,
225                                                    const char *value, int *retval);
226
227
228 #endif   /* GUC_TABLES_H */