guc.h 8.63 KB
Newer Older
1
/*--------------------------------------------------------------------
2 3 4 5 6
 * guc.h
 *
 * External declarations pertaining to backend/utils/misc/guc.c and
 * backend/utils/misc/guc-file.l
 *
Bruce Momjian's avatar
Bruce Momjian committed
7
 * Copyright (c) 2000-2004, PostgreSQL Global Development Group
8 9
 * Written by Peter Eisentraut <peter_e@gmx.net>.
 *
10
 * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.52 2004/10/08 01:36:36 tgl Exp $
11
 *--------------------------------------------------------------------
12 13 14 15
 */
#ifndef GUC_H
#define GUC_H

16
#include "nodes/pg_list.h"
17
#include "tcop/dest.h"
18 19
#include "utils/array.h"

20

21
/*
22 23 24
 * Certain options can only be set at certain times. The rules are
 * like this:
 *
25 26 27 28
 * INTERNAL options cannot be set by the user at all, but only through
 * internal processes ("server_version" is an example).  These are GUC
 * variables only so they can be shown by SHOW, etc.
 *
29 30 31 32 33 34
 * POSTMASTER options can only be set when the postmaster starts,
 * either from the configuration file or the command line.
 *
 * SIGHUP options can only be set at postmaster startup or by changing
 * the configuration file and sending the HUP signal to the postmaster
 * 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 37 38
 * certain point in their main loop. It's safer to wait than to read a
 * file asynchronously.)
 *
39
 * BACKEND options can only be set at postmaster startup, from the
40 41 42
 * configuration file, or by client request in the connection startup
 * packet (e.g., from libpq's PGOPTIONS variable).  Furthermore, an
 * already-started backend will ignore changes to such an option in the
Bruce Momjian's avatar
Bruce Momjian committed
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.
45 46 47
 *
 * SUSET options can be set at postmaster startup, with the SIGHUP
 * mechanism, or from SQL if you're a superuser. These options cannot
48 49
 * be set in the connection startup packet, because when it is processed
 * we don't yet know if the user is a superuser.
50
 *
51
 * USERLIMIT options can only be manipulated in certain ways by
52
 * non-superusers.
53
 *
54
 * USERSET options can be set by anyone any time.
55
 */
56 57
typedef enum
{
58 59 60 61 62 63 64
	PGC_INTERNAL,
	PGC_POSTMASTER,
	PGC_SIGHUP,
	PGC_BACKEND,
	PGC_SUSET,
	PGC_USERLIMIT,
	PGC_USERSET
65 66
} GucContext;

67 68 69 70
/*
 * The following type records the source of the current setting.  A
 * new setting can only take effect if the previous setting had the
 * same or lower level.  (E.g, changing the config file doesn't
71 72 73
 * override the postmaster command line.)  Tracking the source allows us
 * to process sources in any convenient order without affecting results.
 * Sources <= PGC_S_OVERRIDE will set the default used by RESET, as well
74 75
 * as the current value.  Note that source == PGC_S_OVERRIDE should be
 * used when setting a PGC_INTERNAL option.
76
 *
77 78
 * PGC_S_UNPRIVILEGED isn't actually a source value, but the dividing line
 * between privileged and unprivileged sources for USERLIMIT purposes.
79 80 81 82 83 84
 * Similarly, PGC_S_INTERACTIVE isn't a real source value, but is the
 * dividing line between "interactive" and "non-interactive" sources for
 * error reporting purposes.
 *
 * PGC_S_TEST is used when testing values to be stored as per-database or
 * per-user defaults ("doit" will always be false, so this never gets stored
Bruce Momjian's avatar
Bruce Momjian committed
85
 * as the actual source of any value).	This is an interactive case, but
86 87
 * it needs its own source value because some assign hooks need to make
 * different validity checks in this case.
88 89 90
 */
typedef enum
{
91 92 93 94 95 96 97 98 99
	PGC_S_DEFAULT,				/* wired-in default */
	PGC_S_ENV_VAR,				/* postmaster environment variable */
	PGC_S_FILE,					/* postgresql.conf */
	PGC_S_ARGV,					/* postmaster command line */
	PGC_S_UNPRIVILEGED,			/* dividing line for USERLIMIT */
	PGC_S_DATABASE,				/* per-database setting */
	PGC_S_USER,					/* per-user setting */
	PGC_S_CLIENT,				/* from client connection request */
	PGC_S_OVERRIDE,				/* special case to forcibly set default */
100 101
	PGC_S_INTERACTIVE,			/* dividing line for error reporting */
	PGC_S_TEST,					/* test per-database or per-user setting */
102
	PGC_S_SESSION				/* SET command */
103
} GucSource;
104

Bruce Momjian's avatar
Bruce Momjian committed
105 106 107 108
typedef const char *(*GucStringAssignHook) (const char *newval, bool doit, GucSource source);
typedef bool (*GucBoolAssignHook) (bool newval, bool doit, GucSource source);
typedef bool (*GucIntAssignHook) (int newval, bool doit, GucSource source);
typedef bool (*GucRealAssignHook) (double newval, bool doit, GucSource source);
109

Bruce Momjian's avatar
Bruce Momjian committed
110
typedef const char *(*GucShowHook) (void);
111 112 113

#define GUC_QUALIFIER_SEPARATOR '.'

114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
/* GUC vars that are actually declared in guc.c, rather than elsewhere */
extern bool log_duration;
extern bool Debug_print_plan;
extern bool Debug_print_parse;
extern bool Debug_print_rewritten;
extern bool Debug_pretty_print;
extern bool Explain_pretty_print;

extern bool log_parser_stats;
extern bool log_planner_stats;
extern bool log_executor_stats;
extern bool log_statement_stats;
extern bool log_btree_build_stats;

extern bool SQL_inheritance;
extern bool Australian_timezones;

131 132
extern bool default_with_oids;

133 134 135
extern int	log_min_error_statement;
extern int	log_min_messages;
extern int	client_min_messages;
136
extern int	log_min_duration_statement;
137

138 139
extern char *ConfigDir;
extern char *ConfigFileName;
140 141 142 143
extern char *guc_hbafile;
extern char *guc_identfile;
extern char *external_pidfile;

144

145
extern void SetConfigOption(const char *name, const char *value,
146
				GucContext context, GucSource source);
147 148

extern void DefineCustomBoolVariable(
Bruce Momjian's avatar
Bruce Momjian committed
149 150 151 152 153 154 155
						 const char *name,
						 const char *short_desc,
						 const char *long_desc,
						 bool *valueAddr,
						 GucContext context,
						 GucBoolAssignHook assign_hook,
						 GucShowHook show_hook);
156 157

extern void DefineCustomIntVariable(
Bruce Momjian's avatar
Bruce Momjian committed
158 159 160 161 162 163 164
						const char *name,
						const char *short_desc,
						const char *long_desc,
						int *valueAddr,
						GucContext context,
						GucIntAssignHook assign_hook,
						GucShowHook show_hook);
165 166

extern void DefineCustomRealVariable(
Bruce Momjian's avatar
Bruce Momjian committed
167 168 169 170 171 172 173
						 const char *name,
						 const char *short_desc,
						 const char *long_desc,
						 double *valueAddr,
						 GucContext context,
						 GucRealAssignHook assign_hook,
						 GucShowHook show_hook);
174 175

extern void DefineCustomStringVariable(
Bruce Momjian's avatar
Bruce Momjian committed
176 177 178 179 180 181 182
						   const char *name,
						   const char *short_desc,
						   const char *long_desc,
						   char **valueAddr,
						   GucContext context,
						   GucStringAssignHook assign_hook,
						   GucShowHook show_hook);
183

Bruce Momjian's avatar
Bruce Momjian committed
184
extern void EmitWarningsOnPlaceholders(const char *className);
185

186
extern const char *GetConfigOption(const char *name);
187
extern const char *GetConfigOptionResetString(const char *name);
188
extern void ProcessConfigFile(GucContext context);
189
extern void InitializeGUCOptions(void);
190
extern bool SelectConfigFiles(const char *userDoption, const char *progname);
191
extern void ResetAllOptions(void);
192
extern void AtEOXact_GUC(bool isCommit, bool isSubXact);
193
extern void BeginReportingGUCOptions(void);
194 195
extern void ParseLongOption(const char *string, char **name, char **value);
extern bool set_config_option(const char *name, const char *value,
Bruce Momjian's avatar
Bruce Momjian committed
196
				  GucContext context, GucSource source,
197
				  bool isLocal, bool changeVal);
198 199
extern void ShowGUCConfigOption(const char *name, DestReceiver *dest);
extern void ShowAllGUCConfig(DestReceiver *dest);
200
extern char *GetConfigOptionByName(const char *name, const char **varname);
201
extern void GetConfigOptionByNum(int varnum, const char **values, bool *noshow);
Bruce Momjian's avatar
Bruce Momjian committed
202
extern int	GetNumConfigOptions(void);
203

204
extern void SetPGVariable(const char *name, List *args, bool is_local);
205 206
extern void GetPGVariable(const char *name, DestReceiver *dest);
extern TupleDesc GetPGVariableResultDesc(const char *name);
207 208 209 210
extern void ResetPGVariable(const char *name);

extern char *flatten_set_variable_args(const char *name, List *args);

211 212 213
extern void ProcessGUCArray(ArrayType *array, GucSource source);
extern ArrayType *GUCArrayAdd(ArrayType *array, const char *name, const char *value);
extern ArrayType *GUCArrayDelete(ArrayType *array, const char *name);
214

Bruce Momjian's avatar
Bruce Momjian committed
215
#ifdef EXEC_BACKEND
216 217
extern void write_nondefault_variables(GucContext context);
extern void read_nondefault_variables(void);
Bruce Momjian's avatar
Bruce Momjian committed
218 219
#endif

220 221 222 223 224 225 226 227
/*
 * The following functions are not in guc.c, but are declared here to avoid
 * having to include guc.h in some widely used headers that it really doesn't
 * belong in.
 */

/* in utils/adt/datetime.c */
extern bool ClearDateCache(bool newval, bool doit, GucSource source);
Bruce Momjian's avatar
Bruce Momjian committed
228

229 230 231
/* in utils/adt/regexp.c */
extern const char *assign_regex_flavor(const char *value,
					bool doit, GucSource source);
Bruce Momjian's avatar
Bruce Momjian committed
232

233 234 235
/* in catalog/namespace.c */
extern const char *assign_search_path(const char *newval,
				   bool doit, GucSource source);
Bruce Momjian's avatar
Bruce Momjian committed
236

237 238 239 240
/* in access/transam/xlog.c */
extern const char *assign_xlog_sync_method(const char *method,
						bool doit, GucSource source);

241
#endif   /* GUC_H */