1 /*--------------------------------------------------------------------
4 * External declarations pertaining to backend/utils/misc/guc.c and
5 * backend/utils/misc/guc-file.l
7 * Copyright (c) 2000-2009, PostgreSQL Global Development Group
8 * Written by Peter Eisentraut <peter_e@gmx.net>.
10 * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.104 2009/09/03 22:08:05 tgl 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
107 typedef const char *(*GucStringAssignHook) (const char *newval, bool doit, GucSource source);
108 typedef bool (*GucBoolAssignHook) (bool newval, bool doit, GucSource source);
109 typedef bool (*GucIntAssignHook) (int newval, bool doit, GucSource source);
110 typedef bool (*GucRealAssignHook) (double newval, bool doit, GucSource source);
111 typedef bool (*GucEnumAssignHook) (int newval, bool doit, GucSource source);
113 typedef const char *(*GucShowHook) (void);
117 /* Types of set_config_option actions */
118 GUC_ACTION_SET, /* regular SET command */
119 GUC_ACTION_LOCAL, /* SET LOCAL command */
120 GUC_ACTION_SAVE /* function SET option */
123 #define GUC_QUALIFIER_SEPARATOR '.'
126 * bit values in "flags" of a GUC variable
128 #define GUC_LIST_INPUT 0x0001 /* input can be list format */
129 #define GUC_LIST_QUOTE 0x0002 /* double-quote list elements */
130 #define GUC_NO_SHOW_ALL 0x0004 /* exclude from SHOW ALL */
131 #define GUC_NO_RESET_ALL 0x0008 /* exclude from RESET ALL */
132 #define GUC_REPORT 0x0010 /* auto-report changes to client */
133 #define GUC_NOT_IN_SAMPLE 0x0020 /* not in postgresql.conf.sample */
134 #define GUC_DISALLOW_IN_FILE 0x0040 /* can't set in postgresql.conf */
135 #define GUC_CUSTOM_PLACEHOLDER 0x0080 /* placeholder for custom variable */
136 #define GUC_SUPERUSER_ONLY 0x0100 /* show only to superusers */
137 #define GUC_IS_NAME 0x0200 /* limit string to NAMEDATALEN-1 */
139 #define GUC_UNIT_KB 0x0400 /* value is in kilobytes */
140 #define GUC_UNIT_BLOCKS 0x0800 /* value is in blocks */
141 #define GUC_UNIT_XBLOCKS 0x0C00 /* value is in xlog blocks */
142 #define GUC_UNIT_MEMORY 0x0C00 /* mask for KB, BLOCKS, XBLOCKS */
144 #define GUC_UNIT_MS 0x1000 /* value is in milliseconds */
145 #define GUC_UNIT_S 0x2000 /* value is in seconds */
146 #define GUC_UNIT_MIN 0x4000 /* value is in minutes */
147 #define GUC_UNIT_TIME 0x7000 /* mask for MS, S, MIN */
149 #define GUC_NOT_WHILE_SEC_DEF 0x8000 /* can't change inside sec-def func */
151 /* GUC vars that are actually declared in guc.c, rather than elsewhere */
152 extern bool log_duration;
153 extern bool Debug_print_plan;
154 extern bool Debug_print_parse;
155 extern bool Debug_print_rewritten;
156 extern bool Debug_pretty_print;
158 extern bool log_parser_stats;
159 extern bool log_planner_stats;
160 extern bool log_executor_stats;
161 extern bool log_statement_stats;
162 extern bool log_btree_build_stats;
164 extern PGDLLIMPORT bool check_function_bodies;
165 extern bool default_with_oids;
166 extern bool SQL_inheritance;
168 extern int log_min_error_statement;
169 extern int log_min_messages;
170 extern int client_min_messages;
171 extern int log_min_duration_statement;
172 extern int log_temp_files;
174 extern int num_temp_buffers;
176 extern char *ConfigFileName;
177 extern char *HbaFileName;
178 extern char *IdentFileName;
179 extern char *external_pid_file;
181 extern int tcp_keepalives_idle;
182 extern int tcp_keepalives_interval;
183 extern int tcp_keepalives_count;
185 extern void SetConfigOption(const char *name, const char *value,
186 GucContext context, GucSource source);
188 extern void DefineCustomBoolVariable(
190 const char *short_desc,
191 const char *long_desc,
196 GucBoolAssignHook assign_hook,
197 GucShowHook show_hook);
199 extern void DefineCustomIntVariable(
201 const char *short_desc,
202 const char *long_desc,
209 GucIntAssignHook assign_hook,
210 GucShowHook show_hook);
212 extern void DefineCustomRealVariable(
214 const char *short_desc,
215 const char *long_desc,
222 GucRealAssignHook assign_hook,
223 GucShowHook show_hook);
225 extern void DefineCustomStringVariable(
227 const char *short_desc,
228 const char *long_desc,
230 const char *bootValue,
233 GucStringAssignHook assign_hook,
234 GucShowHook show_hook);
236 extern void DefineCustomEnumVariable(
238 const char *short_desc,
239 const char *long_desc,
242 const struct config_enum_entry * options,
245 GucEnumAssignHook assign_hook,
246 GucShowHook show_hook);
248 extern void EmitWarningsOnPlaceholders(const char *className);
250 extern const char *GetConfigOption(const char *name);
251 extern const char *GetConfigOptionResetString(const char *name);
252 extern void ProcessConfigFile(GucContext context);
253 extern void InitializeGUCOptions(void);
254 extern bool SelectConfigFiles(const char *userDoption, const char *progname);
255 extern void ResetAllOptions(void);
256 extern void AtStart_GUC(void);
257 extern int NewGUCNestLevel(void);
258 extern void AtEOXact_GUC(bool isCommit, int nestLevel);
259 extern void BeginReportingGUCOptions(void);
260 extern void ParseLongOption(const char *string, char **name, char **value);
261 extern bool parse_int(const char *value, int *result, int flags,
262 const char **hintmsg);
263 extern bool parse_real(const char *value, double *result);
264 extern bool set_config_option(const char *name, const char *value,
265 GucContext context, GucSource source,
266 GucAction action, bool changeVal);
267 extern char *GetConfigOptionByName(const char *name, const char **varname);
268 extern void GetConfigOptionByNum(int varnum, const char **values, bool *noshow);
269 extern int GetNumConfigOptions(void);
271 extern void SetPGVariable(const char *name, List *args, bool is_local);
272 extern void GetPGVariable(const char *name, DestReceiver *dest);
273 extern TupleDesc GetPGVariableResultDesc(const char *name);
275 extern void ExecSetVariableStmt(VariableSetStmt *stmt);
276 extern char *ExtractSetVariableArgs(VariableSetStmt *stmt);
278 extern void ProcessGUCArray(ArrayType *array,
279 GucContext context, GucSource source, GucAction action);
280 extern ArrayType *GUCArrayAdd(ArrayType *array, const char *name, const char *value);
281 extern ArrayType *GUCArrayDelete(ArrayType *array, const char *name);
283 extern int GUC_complaint_elevel(GucSource source);
285 extern void pg_timezone_abbrev_initialize(void);
288 extern void write_nondefault_variables(GucContext context);
289 extern void read_nondefault_variables(void);
293 * The following functions are not in guc.c, but are declared here to avoid
294 * having to include guc.h in some widely used headers that it really doesn't
298 /* in commands/tablespace.c */
299 extern const char *assign_default_tablespace(const char *newval,
300 bool doit, GucSource source);
301 extern const char *assign_temp_tablespaces(const char *newval,
302 bool doit, GucSource source);
304 /* in catalog/namespace.c */
305 extern const char *assign_search_path(const char *newval,
306 bool doit, GucSource source);
308 /* in access/transam/xlog.c */
309 extern bool assign_xlog_sync_method(int newval,
310 bool doit, GucSource source);