1 /*--------------------------------------------------------------------
4 * External declarations pertaining to backend/utils/misc/guc.c and
5 * backend/utils/misc/guc-file.l
7 * Copyright (c) 2000-2008, PostgreSQL Global Development Group
8 * Written by Peter Eisentraut <peter_e@gmx.net>.
10 * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.92 2008/03/16 16:42:44 mha Exp $
11 *--------------------------------------------------------------------
16 #include "nodes/parsenodes.h"
17 #include "tcop/dest.h"
18 #include "utils/array.h"
22 * Certain options can only be set at certain times. The rules are
25 * INTERNAL options cannot be set by the user at all, but only through
26 * internal processes ("server_version" is an example). These are GUC
27 * variables only so they can be shown by SHOW, etc.
29 * POSTMASTER options can only be set when the postmaster starts,
30 * either from the configuration file or the command line.
32 * SIGHUP options can only be set at postmaster startup or by changing
33 * the configuration file and sending the HUP signal to the postmaster
34 * or a backend process. (Notice that the signal receipt will not be
35 * evaluated immediately. The postmaster and the backend check it at a
36 * certain point in their main loop. It's safer to wait than to read a
37 * file asynchronously.)
39 * BACKEND options can only be set at postmaster startup, from the
40 * configuration file, or by client request in the connection startup
41 * packet (e.g., from libpq's PGOPTIONS variable). Furthermore, an
42 * already-started backend will ignore changes to such an option in the
43 * configuration file. The idea is that these options are fixed for a
44 * given backend once it's started, but they can vary across backends.
46 * SUSET options can be set at postmaster startup, with the SIGHUP
47 * mechanism, or from SQL if you're a superuser.
49 * USERSET options can be set by anyone any time.
62 * The following type records the source of the current setting. A
63 * new setting can only take effect if the previous setting had the
64 * same or lower level. (E.g, changing the config file doesn't
65 * override the postmaster command line.) Tracking the source allows us
66 * to process sources in any convenient order without affecting results.
67 * Sources <= PGC_S_OVERRIDE will set the default used by RESET, as well
68 * as the current value. Note that source == PGC_S_OVERRIDE should be
69 * used when setting a PGC_INTERNAL option.
71 * PGC_S_INTERACTIVE isn't actually a source value, but is the
72 * dividing line between "interactive" and "non-interactive" sources for
73 * error reporting purposes.
75 * PGC_S_TEST is used when testing values to be stored as per-database or
76 * per-user defaults ("doit" will always be false, so this never gets stored
77 * as the actual source of any value). This is an interactive case, but
78 * it needs its own source value because some assign hooks need to make
79 * different validity checks in this case.
83 PGC_S_DEFAULT, /* wired-in default */
84 PGC_S_ENV_VAR, /* postmaster environment variable */
85 PGC_S_FILE, /* postgresql.conf */
86 PGC_S_ARGV, /* postmaster command line */
87 PGC_S_DATABASE, /* per-database setting */
88 PGC_S_USER, /* per-user setting */
89 PGC_S_CLIENT, /* from client connection request */
90 PGC_S_OVERRIDE, /* special case to forcibly set default */
91 PGC_S_INTERACTIVE, /* dividing line for error reporting */
92 PGC_S_TEST, /* test per-database or per-user setting */
93 PGC_S_SESSION /* SET command */
97 * Enum values are made up of an array of name-value pairs
99 struct config_enum_entry
106 typedef const char *(*GucStringAssignHook) (const char *newval, bool doit, GucSource source);
107 typedef bool (*GucBoolAssignHook) (bool newval, bool doit, GucSource source);
108 typedef bool (*GucIntAssignHook) (int newval, bool doit, GucSource source);
109 typedef bool (*GucRealAssignHook) (double newval, bool doit, GucSource source);
110 typedef bool (*GucEnumAssignHook) (int newval, bool doit, GucSource source);
112 typedef const char *(*GucShowHook) (void);
116 /* Types of set_config_option actions */
117 GUC_ACTION_SET, /* regular SET command */
118 GUC_ACTION_LOCAL, /* SET LOCAL command */
119 GUC_ACTION_SAVE /* function SET option */
122 #define GUC_QUALIFIER_SEPARATOR '.'
124 /* GUC vars that are actually declared in guc.c, rather than elsewhere */
125 extern bool log_duration;
126 extern bool Debug_print_plan;
127 extern bool Debug_print_parse;
128 extern bool Debug_print_rewritten;
129 extern bool Debug_pretty_print;
130 extern bool Explain_pretty_print;
132 extern bool log_parser_stats;
133 extern bool log_planner_stats;
134 extern bool log_executor_stats;
135 extern bool log_statement_stats;
136 extern bool log_btree_build_stats;
138 extern PGDLLIMPORT bool check_function_bodies;
139 extern bool default_with_oids;
140 extern bool SQL_inheritance;
142 extern int log_min_error_statement;
143 extern int log_min_messages;
144 extern int client_min_messages;
145 extern int log_min_duration_statement;
146 extern int log_temp_files;
148 extern int num_temp_buffers;
150 extern char *ConfigFileName;
151 extern char *HbaFileName;
152 extern char *IdentFileName;
153 extern char *external_pid_file;
155 extern int tcp_keepalives_idle;
156 extern int tcp_keepalives_interval;
157 extern int tcp_keepalives_count;
159 extern void SetConfigOption(const char *name, const char *value,
160 GucContext context, GucSource source);
162 extern void DefineCustomBoolVariable(
164 const char *short_desc,
165 const char *long_desc,
168 GucBoolAssignHook assign_hook,
169 GucShowHook show_hook);
171 extern void DefineCustomIntVariable(
173 const char *short_desc,
174 const char *long_desc,
179 GucIntAssignHook assign_hook,
180 GucShowHook show_hook);
182 extern void DefineCustomRealVariable(
184 const char *short_desc,
185 const char *long_desc,
190 GucRealAssignHook assign_hook,
191 GucShowHook show_hook);
193 extern void DefineCustomStringVariable(
195 const char *short_desc,
196 const char *long_desc,
199 GucStringAssignHook assign_hook,
200 GucShowHook show_hook);
202 extern void DefineCustomEnumVariable(
204 const char *short_desc,
205 const char *long_desc,
207 const struct config_enum_entry *options,
209 GucEnumAssignHook assign_hook,
210 GucShowHook show_hook);
212 extern void EmitWarningsOnPlaceholders(const char *className);
214 extern const char *GetConfigOption(const char *name);
215 extern const char *GetConfigOptionResetString(const char *name);
216 extern bool IsSuperuserConfigOption(const char *name);
217 extern void ProcessConfigFile(GucContext context);
218 extern void InitializeGUCOptions(void);
219 extern bool SelectConfigFiles(const char *userDoption, const char *progname);
220 extern void ResetAllOptions(void);
221 extern void AtStart_GUC(void);
222 extern int NewGUCNestLevel(void);
223 extern void AtEOXact_GUC(bool isCommit, int nestLevel);
224 extern void BeginReportingGUCOptions(void);
225 extern void ParseLongOption(const char *string, char **name, char **value);
226 extern bool set_config_option(const char *name, const char *value,
227 GucContext context, GucSource source,
228 GucAction action, bool changeVal);
229 extern char *GetConfigOptionByName(const char *name, const char **varname);
230 extern void GetConfigOptionByNum(int varnum, const char **values, bool *noshow);
231 extern int GetNumConfigOptions(void);
233 extern void SetPGVariable(const char *name, List *args, bool is_local);
234 extern void GetPGVariable(const char *name, DestReceiver *dest);
235 extern TupleDesc GetPGVariableResultDesc(const char *name);
237 extern void ExecSetVariableStmt(VariableSetStmt *stmt);
238 extern char *ExtractSetVariableArgs(VariableSetStmt *stmt);
240 extern void ProcessGUCArray(ArrayType *array,
241 GucContext context, GucSource source, GucAction action);
242 extern ArrayType *GUCArrayAdd(ArrayType *array, const char *name, const char *value);
243 extern ArrayType *GUCArrayDelete(ArrayType *array, const char *name);
245 extern int GUC_complaint_elevel(GucSource source);
247 extern void pg_timezone_abbrev_initialize(void);
250 extern void write_nondefault_variables(GucContext context);
251 extern void read_nondefault_variables(void);
255 * The following functions are not in guc.c, but are declared here to avoid
256 * having to include guc.h in some widely used headers that it really doesn't
260 /* in commands/tablespace.c */
261 extern const char *assign_default_tablespace(const char *newval,
262 bool doit, GucSource source);
263 extern const char *assign_temp_tablespaces(const char *newval,
264 bool doit, GucSource source);
266 /* in utils/adt/regexp.c */
267 extern const char *assign_regex_flavor(const char *value,
268 bool doit, GucSource source);
270 /* in catalog/namespace.c */
271 extern const char *assign_search_path(const char *newval,
272 bool doit, GucSource source);
274 /* in access/transam/xlog.c */
275 extern const char *assign_xlog_sync_method(const char *method,
276 bool doit, GucSource source);