guc.h 5.7 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
 *
7 8 9
 * Copyright 2000-2003 by PostgreSQL Global Development Group
 * Written by Peter Eisentraut <peter_e@gmx.net>.
 *
10
 * $Id: guc.h,v 1.38 2003/07/28 19:31:32 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 43 44
 * 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
 * configuration file.  The idea is that these options are fixed for a
 * 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
 */
B
Bruce Momjian 已提交
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
 */
typedef enum
{
82 83 84 85 86 87 88 89 90 91
	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 */
	PGC_S_SESSION				/* SET command */
92
} GucSource;
93

94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
/* GUC vars that are actually declared in guc.c, rather than elsewhere */
extern bool log_statement;
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;

extern int	log_min_error_statement;
extern int	log_min_messages;
extern int	client_min_messages;
115
extern int	log_min_duration_statement;
116 117


118
extern void SetConfigOption(const char *name, const char *value,
119
				GucContext context, GucSource source);
120
extern const char *GetConfigOption(const char *name);
121
extern const char *GetConfigOptionResetString(const char *name);
122
extern void ProcessConfigFile(GucContext context);
123 124 125
extern void InitializeGUCOptions(void);
extern void ResetAllOptions(void);
extern void AtEOXact_GUC(bool isCommit);
126
extern void BeginReportingGUCOptions(void);
127 128
extern void ParseLongOption(const char *string, char **name, char **value);
extern bool set_config_option(const char *name, const char *value,
B
Bruce Momjian 已提交
129 130
				  GucContext context, GucSource source,
				  bool isLocal, bool DoIt);
131 132
extern void ShowGUCConfigOption(const char *name, DestReceiver *dest);
extern void ShowAllGUCConfig(DestReceiver *dest);
133
extern char *GetConfigOptionByName(const char *name, const char **varname);
134
extern void GetConfigOptionByNum(int varnum, const char **values, bool *noshow);
B
Bruce Momjian 已提交
135
extern int	GetNumConfigOptions(void);
136

137
extern void SetPGVariable(const char *name, List *args, bool is_local);
138 139
extern void GetPGVariable(const char *name, DestReceiver *dest);
extern TupleDesc GetPGVariableResultDesc(const char *name);
140 141 142 143
extern void ResetPGVariable(const char *name);

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

144 145 146
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);
147

B
Bruce Momjian 已提交
148 149 150 151 152
#ifdef EXEC_BACKEND
void write_nondefault_variables(GucContext context);
void read_nondefault_variables(void);
#endif

153
#endif   /* GUC_H */