OSDN Git Service

Revert (again) GUC patch to return commented fields to their default
[pg-rex/syncrep.git] / src / include / utils / guc.h
1 /*--------------------------------------------------------------------
2  * guc.h
3  *
4  * External declarations pertaining to backend/utils/misc/guc.c and
5  * backend/utils/misc/guc-file.l
6  *
7  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
8  * Written by Peter Eisentraut <peter_e@gmx.net>.
9  *
10  * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.75 2006/08/14 02:27:27 momjian Exp $
11  *--------------------------------------------------------------------
12  */
13 #ifndef GUC_H
14 #define GUC_H
15
16 #include "tcop/dest.h"
17 #include "utils/array.h"
18
19
20 /*
21  * Certain options can only be set at certain times. The rules are
22  * like this:
23  *
24  * INTERNAL options cannot be set by the user at all, but only through
25  * internal processes ("server_version" is an example).  These are GUC
26  * variables only so they can be shown by SHOW, etc.
27  *
28  * POSTMASTER options can only be set when the postmaster starts,
29  * either from the configuration file or the command line.
30  *
31  * SIGHUP options can only be set at postmaster startup or by changing
32  * the configuration file and sending the HUP signal to the postmaster
33  * or a backend process. (Notice that the signal receipt will not be
34  * evaluated immediately. The postmaster and the backend check it at a
35  * certain point in their main loop. It's safer to wait than to read a
36  * file asynchronously.)
37  *
38  * BACKEND options can only be set at postmaster startup, from the
39  * configuration file, or by client request in the connection startup
40  * packet (e.g., from libpq's PGOPTIONS variable).  Furthermore, an
41  * already-started backend will ignore changes to such an option in the
42  * configuration file.  The idea is that these options are fixed for a
43  * given backend once it's started, but they can vary across backends.
44  *
45  * SUSET options can be set at postmaster startup, with the SIGHUP
46  * mechanism, or from SQL if you're a superuser.
47  *
48  * USERSET options can be set by anyone any time.
49  */
50 typedef enum
51 {
52         PGC_INTERNAL,
53         PGC_POSTMASTER,
54         PGC_SIGHUP,
55         PGC_BACKEND,
56         PGC_SUSET,
57         PGC_USERSET
58 } GucContext;
59
60 /*
61  * The following type records the source of the current setting.  A
62  * new setting can only take effect if the previous setting had the
63  * same or lower level.  (E.g, changing the config file doesn't
64  * override the postmaster command line.)  Tracking the source allows us
65  * to process sources in any convenient order without affecting results.
66  * Sources <= PGC_S_OVERRIDE will set the default used by RESET, as well
67  * as the current value.  Note that source == PGC_S_OVERRIDE should be
68  * used when setting a PGC_INTERNAL option.
69  *
70  * PGC_S_INTERACTIVE isn't actually a source value, but is the
71  * dividing line between "interactive" and "non-interactive" sources for
72  * error reporting purposes.
73  *
74  * PGC_S_TEST is used when testing values to be stored as per-database or
75  * per-user defaults ("doit" will always be false, so this never gets stored
76  * as the actual source of any value).  This is an interactive case, but
77  * it needs its own source value because some assign hooks need to make
78  * different validity checks in this case.
79  */
80 typedef enum
81 {
82         PGC_S_DEFAULT,                          /* wired-in default */
83         PGC_S_ENV_VAR,                          /* postmaster environment variable */
84         PGC_S_FILE,                                     /* postgresql.conf */
85         PGC_S_ARGV,                                     /* postmaster command line */
86         PGC_S_DATABASE,                         /* per-database setting */
87         PGC_S_USER,                                     /* per-user setting */
88         PGC_S_CLIENT,                           /* from client connection request */
89         PGC_S_OVERRIDE,                         /* special case to forcibly set default */
90         PGC_S_INTERACTIVE,                      /* dividing line for error reporting */
91         PGC_S_TEST,                                     /* test per-database or per-user setting */
92         PGC_S_SESSION                           /* SET command */
93 } GucSource;
94
95 typedef const char *(*GucStringAssignHook) (const char *newval, bool doit, GucSource source);
96 typedef bool (*GucBoolAssignHook) (bool newval, bool doit, GucSource source);
97 typedef bool (*GucIntAssignHook) (int newval, bool doit, GucSource source);
98 typedef bool (*GucRealAssignHook) (double newval, bool doit, GucSource source);
99
100 typedef const char *(*GucShowHook) (void);
101
102 #define GUC_QUALIFIER_SEPARATOR '.'
103
104 /* GUC vars that are actually declared in guc.c, rather than elsewhere */
105 extern bool log_duration;
106 extern bool Debug_print_plan;
107 extern bool Debug_print_parse;
108 extern bool Debug_print_rewritten;
109 extern bool Debug_pretty_print;
110 extern bool Explain_pretty_print;
111
112 extern bool log_parser_stats;
113 extern bool log_planner_stats;
114 extern bool log_executor_stats;
115 extern bool log_statement_stats;
116 extern bool log_btree_build_stats;
117
118 extern bool SQL_inheritance;
119
120 extern bool default_with_oids;
121
122 extern int      log_min_error_statement;
123 extern int      log_min_messages;
124 extern int      client_min_messages;
125 extern int      log_min_duration_statement;
126
127 extern int      num_temp_buffers;
128
129 extern char *ConfigFileName;
130 extern char *HbaFileName;
131 extern char *IdentFileName;
132 extern char *external_pid_file;
133
134 extern int      tcp_keepalives_idle;
135 extern int      tcp_keepalives_interval;
136 extern int      tcp_keepalives_count;
137
138 extern void SetConfigOption(const char *name, const char *value,
139                                 GucContext context, GucSource source);
140
141 extern void DefineCustomBoolVariable(
142                                                  const char *name,
143                                                  const char *short_desc,
144                                                  const char *long_desc,
145                                                  bool *valueAddr,
146                                                  GucContext context,
147                                                  GucBoolAssignHook assign_hook,
148                                                  GucShowHook show_hook);
149
150 extern void DefineCustomIntVariable(
151                                                 const char *name,
152                                                 const char *short_desc,
153                                                 const char *long_desc,
154                                                 int *valueAddr,
155                                                 int minValue,
156                                                 int maxValue,
157                                                 GucContext context,
158                                                 GucIntAssignHook assign_hook,
159                                                 GucShowHook show_hook);
160
161 extern void DefineCustomRealVariable(
162                                                  const char *name,
163                                                  const char *short_desc,
164                                                  const char *long_desc,
165                                                  double *valueAddr,
166                                                  double minValue,
167                                                  double maxValue,
168                                                  GucContext context,
169                                                  GucRealAssignHook assign_hook,
170                                                  GucShowHook show_hook);
171
172 extern void DefineCustomStringVariable(
173                                                    const char *name,
174                                                    const char *short_desc,
175                                                    const char *long_desc,
176                                                    char **valueAddr,
177                                                    GucContext context,
178                                                    GucStringAssignHook assign_hook,
179                                                    GucShowHook show_hook);
180
181 extern void EmitWarningsOnPlaceholders(const char *className);
182
183 extern const char *GetConfigOption(const char *name);
184 extern const char *GetConfigOptionResetString(const char *name);
185 extern bool IsSuperuserConfigOption(const char *name);
186 extern void ProcessConfigFile(GucContext context);
187 extern void InitializeGUCOptions(void);
188 extern bool SelectConfigFiles(const char *userDoption, const char *progname);
189 extern void ResetAllOptions(void);
190 extern void AtEOXact_GUC(bool isCommit, bool isSubXact);
191 extern void BeginReportingGUCOptions(void);
192 extern void ParseLongOption(const char *string, char **name, char **value);
193 extern bool set_config_option(const char *name, const char *value,
194                                   GucContext context, GucSource source,
195                                   bool isLocal, bool changeVal);
196 extern char *GetConfigOptionByName(const char *name, const char **varname);
197 extern void GetConfigOptionByNum(int varnum, const char **values, bool *noshow);
198 extern int      GetNumConfigOptions(void);
199
200 extern void SetPGVariable(const char *name, List *args, bool is_local);
201 extern void GetPGVariable(const char *name, DestReceiver *dest);
202 extern TupleDesc GetPGVariableResultDesc(const char *name);
203 extern void ResetPGVariable(const char *name);
204
205 extern char *flatten_set_variable_args(const char *name, List *args);
206
207 extern void ProcessGUCArray(ArrayType *array, GucSource source);
208 extern ArrayType *GUCArrayAdd(ArrayType *array, const char *name, const char *value);
209 extern ArrayType *GUCArrayDelete(ArrayType *array, const char *name);
210
211 extern void pg_timezone_abbrev_initialize(void);
212
213 #ifdef EXEC_BACKEND
214 extern void write_nondefault_variables(GucContext context);
215 extern void read_nondefault_variables(void);
216 #endif
217
218 /*
219  * The following functions are not in guc.c, but are declared here to avoid
220  * having to include guc.h in some widely used headers that it really doesn't
221  * belong in.
222  */
223
224 /* in commands/tablespace.c */
225 extern const char *assign_default_tablespace(const char *newval,
226                                                   bool doit, GucSource source);
227
228 /* in utils/adt/regexp.c */
229 extern const char *assign_regex_flavor(const char *value,
230                                         bool doit, GucSource source);
231
232 /* in catalog/namespace.c */
233 extern const char *assign_search_path(const char *newval,
234                                    bool doit, GucSource source);
235
236 /* in access/transam/xlog.c */
237 extern const char *assign_xlog_sync_method(const char *method,
238                                                 bool doit, GucSource source);
239
240 #endif   /* GUC_H */