OSDN Git Service

Disallow RESET ROLE and RESET SESSION AUTHORIZATION inside security-definer
[pg-rex/syncrep.git] / src / include / utils / guc.h
1 /*--------------------------------------------------------------------
2  * guc.h
3  *
4  * External declarations pertaining to backend/utils/misc/guc.c and
5  * backend/utils/misc/guc-file.l
6  *
7  * Copyright (c) 2000-2009, PostgreSQL Global Development Group
8  * Written by Peter Eisentraut <peter_e@gmx.net>.
9  *
10  * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.104 2009/09/03 22:08:05 tgl Exp $
11  *--------------------------------------------------------------------
12  */
13 #ifndef GUC_H
14 #define GUC_H
15
16 #include "nodes/parsenodes.h"
17 #include "tcop/dest.h"
18 #include "utils/array.h"
19
20
21 /*
22  * Certain options can only be set at certain times. The rules are
23  * like this:
24  *
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.
28  *
29  * POSTMASTER options can only be set when the postmaster starts,
30  * either from the configuration file or the command line.
31  *
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.)
38  *
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.
45  *
46  * SUSET options can be set at postmaster startup, with the SIGHUP
47  * mechanism, or from SQL if you're a superuser.
48  *
49  * USERSET options can be set by anyone any time.
50  */
51 typedef enum
52 {
53         PGC_INTERNAL,
54         PGC_POSTMASTER,
55         PGC_SIGHUP,
56         PGC_BACKEND,
57         PGC_SUSET,
58         PGC_USERSET
59 } GucContext;
60
61 /*
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.
70  *
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.
74  *
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.
80  */
81 typedef enum
82 {
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 */
94 } GucSource;
95
96 /*
97  * Enum values are made up of an array of name-value pairs
98  */
99 struct config_enum_entry
100 {
101         const char *name;
102         int                     val;
103         bool            hidden;
104 };
105
106
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);
112
113 typedef const char *(*GucShowHook) (void);
114
115 typedef enum
116 {
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 */
121 } GucAction;
122
123 #define GUC_QUALIFIER_SEPARATOR '.'
124
125 /*
126  * bit values in "flags" of a GUC variable
127  */
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 */
138
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 */
143
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 */
148
149 #define GUC_NOT_WHILE_SEC_DEF   0x8000  /* can't change inside sec-def func */
150
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;
157
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;
163
164 extern PGDLLIMPORT bool check_function_bodies;
165 extern bool default_with_oids;
166 extern bool SQL_inheritance;
167
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;
173
174 extern int      num_temp_buffers;
175
176 extern char *ConfigFileName;
177 extern char *HbaFileName;
178 extern char *IdentFileName;
179 extern char *external_pid_file;
180
181 extern int      tcp_keepalives_idle;
182 extern int      tcp_keepalives_interval;
183 extern int      tcp_keepalives_count;
184
185 extern void SetConfigOption(const char *name, const char *value,
186                                 GucContext context, GucSource source);
187
188 extern void DefineCustomBoolVariable(
189                                                  const char *name,
190                                                  const char *short_desc,
191                                                  const char *long_desc,
192                                                  bool *valueAddr,
193                                                  bool bootValue,
194                                                  GucContext context,
195                                                  int flags,
196                                                  GucBoolAssignHook assign_hook,
197                                                  GucShowHook show_hook);
198
199 extern void DefineCustomIntVariable(
200                                                 const char *name,
201                                                 const char *short_desc,
202                                                 const char *long_desc,
203                                                 int *valueAddr,
204                                                 int bootValue,
205                                                 int minValue,
206                                                 int maxValue,
207                                                 GucContext context,
208                                                 int flags,
209                                                 GucIntAssignHook assign_hook,
210                                                 GucShowHook show_hook);
211
212 extern void DefineCustomRealVariable(
213                                                  const char *name,
214                                                  const char *short_desc,
215                                                  const char *long_desc,
216                                                  double *valueAddr,
217                                                  double bootValue,
218                                                  double minValue,
219                                                  double maxValue,
220                                                  GucContext context,
221                                                  int flags,
222                                                  GucRealAssignHook assign_hook,
223                                                  GucShowHook show_hook);
224
225 extern void DefineCustomStringVariable(
226                                                    const char *name,
227                                                    const char *short_desc,
228                                                    const char *long_desc,
229                                                    char **valueAddr,
230                                                    const char *bootValue,
231                                                    GucContext context,
232                                                    int flags,
233                                                    GucStringAssignHook assign_hook,
234                                                    GucShowHook show_hook);
235
236 extern void DefineCustomEnumVariable(
237                                                  const char *name,
238                                                  const char *short_desc,
239                                                  const char *long_desc,
240                                                  int *valueAddr,
241                                                  int bootValue,
242                                                  const struct config_enum_entry * options,
243                                                  GucContext context,
244                                                  int flags,
245                                                  GucEnumAssignHook assign_hook,
246                                                  GucShowHook show_hook);
247
248 extern void EmitWarningsOnPlaceholders(const char *className);
249
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);
270
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);
274
275 extern void ExecSetVariableStmt(VariableSetStmt *stmt);
276 extern char *ExtractSetVariableArgs(VariableSetStmt *stmt);
277
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);
282
283 extern int      GUC_complaint_elevel(GucSource source);
284
285 extern void pg_timezone_abbrev_initialize(void);
286
287 #ifdef EXEC_BACKEND
288 extern void write_nondefault_variables(GucContext context);
289 extern void read_nondefault_variables(void);
290 #endif
291
292 /*
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
295  * belong in.
296  */
297
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);
303
304 /* in catalog/namespace.c */
305 extern const char *assign_search_path(const char *newval,
306                                    bool doit, GucSource source);
307
308 /* in access/transam/xlog.c */
309 extern bool assign_xlog_sync_method(int newval,
310                                                 bool doit, GucSource source);
311
312 #endif   /* GUC_H */