1 /*--------------------------------------------------------------------
4 * External declarations pertaining to backend/utils/misc/guc.c and
5 * backend/utils/misc/guc-file.l
7 * Copyright (c) 2000-2006, PostgreSQL Global Development Group
8 * Written by Peter Eisentraut <peter_e@gmx.net>.
10 * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.75 2006/08/14 02:27:27 momjian Exp $
11 *--------------------------------------------------------------------
16 #include "tcop/dest.h"
17 #include "utils/array.h"
21 * Certain options can only be set at certain times. The rules are
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.
28 * POSTMASTER options can only be set when the postmaster starts,
29 * either from the configuration file or the command line.
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.)
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.
45 * SUSET options can be set at postmaster startup, with the SIGHUP
46 * mechanism, or from SQL if you're a superuser.
48 * USERSET options can be set by anyone any time.
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.
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.
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.
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 */
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);
100 typedef const char *(*GucShowHook) (void);
102 #define GUC_QUALIFIER_SEPARATOR '.'
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;
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;
118 extern bool SQL_inheritance;
120 extern bool default_with_oids;
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;
127 extern int num_temp_buffers;
129 extern char *ConfigFileName;
130 extern char *HbaFileName;
131 extern char *IdentFileName;
132 extern char *external_pid_file;
134 extern int tcp_keepalives_idle;
135 extern int tcp_keepalives_interval;
136 extern int tcp_keepalives_count;
138 extern void SetConfigOption(const char *name, const char *value,
139 GucContext context, GucSource source);
141 extern void DefineCustomBoolVariable(
143 const char *short_desc,
144 const char *long_desc,
147 GucBoolAssignHook assign_hook,
148 GucShowHook show_hook);
150 extern void DefineCustomIntVariable(
152 const char *short_desc,
153 const char *long_desc,
158 GucIntAssignHook assign_hook,
159 GucShowHook show_hook);
161 extern void DefineCustomRealVariable(
163 const char *short_desc,
164 const char *long_desc,
169 GucRealAssignHook assign_hook,
170 GucShowHook show_hook);
172 extern void DefineCustomStringVariable(
174 const char *short_desc,
175 const char *long_desc,
178 GucStringAssignHook assign_hook,
179 GucShowHook show_hook);
181 extern void EmitWarningsOnPlaceholders(const char *className);
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);
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);
205 extern char *flatten_set_variable_args(const char *name, List *args);
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);
211 extern void pg_timezone_abbrev_initialize(void);
214 extern void write_nondefault_variables(GucContext context);
215 extern void read_nondefault_variables(void);
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
224 /* in commands/tablespace.c */
225 extern const char *assign_default_tablespace(const char *newval,
226 bool doit, GucSource source);
228 /* in utils/adt/regexp.c */
229 extern const char *assign_regex_flavor(const char *value,
230 bool doit, GucSource source);
232 /* in catalog/namespace.c */
233 extern const char *assign_search_path(const char *newval,
234 bool doit, GucSource source);
236 /* in access/transam/xlog.c */
237 extern const char *assign_xlog_sync_method(const char *method,
238 bool doit, GucSource source);