]> granicus.if.org Git - postgresql/blobdiff - src/include/utils/guc.h
Phase 2 of pgindent updates.
[postgresql] / src / include / utils / guc.h
index c07f263ea073b0dab52c0f3960904e0767cceb45..c1870d213014342f84888746eac23f71691e73e5 100644 (file)
@@ -4,7 +4,7 @@
  * External declarations pertaining to backend/utils/misc/guc.c and
  * backend/utils/misc/guc-file.l
  *
- * Copyright (c) 2000-2011, PostgreSQL Global Development Group
+ * Copyright (c) 2000-2017, PostgreSQL Global Development Group
  * Written by Peter Eisentraut <peter_e@gmx.net>.
  *
  * src/include/utils/guc.h
 #include "utils/array.h"
 
 
+/* upper limit for GUC variables measured in kilobytes of memory */
+/* note that various places assume the byte size fits in a "long" variable */
+#if SIZEOF_SIZE_T > 4 && SIZEOF_LONG > 4
+#define MAX_KILOBYTES  INT_MAX
+#else
+#define MAX_KILOBYTES  (INT_MAX / 1024)
+#endif
+
+/*
+ * Automatic configuration file name for ALTER SYSTEM.
+ * This file will be used to store values of configuration parameters
+ * set by ALTER SYSTEM command.
+ */
+#define PG_AUTOCONF_FILENAME           "postgresql.auto.conf"
+
 /*
  * Certain options can only be set at certain times. The rules are
  * like this:
  * certain point in their main loop. It's safer to wait than to read a
  * file asynchronously.)
  *
- * BACKEND options can only be set at postmaster startup, from the
- * 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.
+ * BACKEND and SU_BACKEND options can only be set at postmaster startup,
+ * from the configuration file, or by client request in the connection
+ * startup packet (e.g., from libpq's PGOPTIONS variable).  SU_BACKEND
+ * options can be set from the startup packet only when the user is a
+ * superuser.  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.
  *
  * SUSET options can be set at postmaster startup, with the SIGHUP
- * mechanism, or from SQL if you're a superuser.
+ * mechanism, or from the startup packet or SQL if you're a superuser.
  *
  * USERSET options can be set by anyone any time.
  */
@@ -53,6 +70,7 @@ typedef enum
        PGC_INTERNAL,
        PGC_POSTMASTER,
        PGC_SIGHUP,
+       PGC_SU_BACKEND,
        PGC_BACKEND,
        PGC_SUSET,
        PGC_USERSET
@@ -72,20 +90,26 @@ typedef enum
  * 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
- * as the actual source of any value). This is an interactive case, but
- * it needs its own source value because some assign hooks need to make
- * different validity checks in this case.
+ * PGC_S_TEST is used when testing values to be used later ("doit" will always
+ * be false, so this never gets stored as the actual source of any value).
+ * For example, ALTER DATABASE/ROLE tests proposed per-database or per-user
+ * defaults this way, and CREATE FUNCTION tests proposed function SET clauses
+ * this way.  This is an interactive case, but it needs its own source value
+ * because some assign hooks need to make different validity checks in this
+ * case.  In particular, references to nonexistent database objects generally
+ * shouldn't throw hard errors in this case, at most NOTICEs, since the
+ * objects might exist by the time the setting is used for real.
  *
  * NB: see GucSource_Names in guc.c if you change this.
  */
 typedef enum
 {
-       PGC_S_DEFAULT,                          /* wired-in default */
+       PGC_S_DEFAULT,                          /* hard-wired default ("boot_val") */
+       PGC_S_DYNAMIC_DEFAULT,          /* default computed during initialization */
        PGC_S_ENV_VAR,                          /* postmaster environment variable */
        PGC_S_FILE,                                     /* postgresql.conf */
        PGC_S_ARGV,                                     /* postmaster command line */
+       PGC_S_GLOBAL,                           /* global in-database setting */
        PGC_S_DATABASE,                         /* per-database setting */
        PGC_S_USER,                                     /* per-user setting */
        PGC_S_DATABASE_USER,            /* per-user-and-database setting */
@@ -97,27 +121,45 @@ typedef enum
 } GucSource;
 
 /*
- * Parsing the configuation file will return a list of name-value pairs
+ * Parsing the configuration file(s) will return a list of name-value pairs
+ * with source location info.  We also abuse this data structure to carry
+ * error reports about the config files.  An entry reporting an error will
+ * have errmsg != NULL, and might have NULLs for name, value, and/or filename.
+ *
+ * If "ignore" is true, don't attempt to apply the item (it might be an error
+ * report, or an item we determined to be duplicate).  "applied" is set true
+ * if we successfully applied, or could have applied, the setting.
  */
 typedef struct ConfigVariable
 {
-       char       *name;
-       char       *value;
+       char       *name;
+       char       *value;
+       char       *errmsg;
        char       *filename;
        int                     sourceline;
-       struct ConfigVariable  *next;
+       bool            ignore;
+       bool            applied;
+       struct ConfigVariable *next;
 } ConfigVariable;
 
-extern bool ParseConfigFile(const char *config_file, const char *calling_file,
+extern bool ParseConfigFile(const char *config_file, bool strict,
+                               const char *calling_file, int calling_lineno,
                                int depth, int elevel,
                                ConfigVariable **head_p, ConfigVariable **tail_p);
 extern bool ParseConfigFp(FILE *fp, const char *config_file,
                          int depth, int elevel,
                          ConfigVariable **head_p, ConfigVariable **tail_p);
+extern bool ParseConfigDirectory(const char *includedir,
+                                        const char *calling_file, int calling_lineno,
+                                        int depth, int elevel,
+                                        ConfigVariable **head_p,
+                                        ConfigVariable **tail_p);
 extern void FreeConfigVariables(ConfigVariable *list);
 
 /*
- * Enum values are made up of an array of name-value pairs
+ * The possible values of an enum variable are specified by an array of
+ * name-value pairs.  The "hidden" flag means the value is accepted but
+ * won't be displayed when guc.c is asked for a list of acceptable values.
  */
 struct config_enum_entry
 {
@@ -126,21 +168,32 @@ struct config_enum_entry
        bool            hidden;
 };
 
-
-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);
-typedef bool (*GucEnumAssignHook) (int newval, bool doit, GucSource source);
+/*
+ * Signatures for per-variable check/assign/show hook functions
+ */
+typedef bool (*GucBoolCheckHook) (bool *newval, void **extra, GucSource source);
+typedef bool (*GucIntCheckHook) (int *newval, void **extra, GucSource source);
+typedef bool (*GucRealCheckHook) (double *newval, void **extra, GucSource source);
+typedef bool (*GucStringCheckHook) (char **newval, void **extra, GucSource source);
+typedef bool (*GucEnumCheckHook) (int *newval, void **extra, GucSource source);
+
+typedef void (*GucBoolAssignHook) (bool newval, void *extra);
+typedef void (*GucIntAssignHook) (int newval, void *extra);
+typedef void (*GucRealAssignHook) (double newval, void *extra);
+typedef void (*GucStringAssignHook) (const char *newval, void *extra);
+typedef void (*GucEnumAssignHook) (int newval, void *extra);
 
 typedef const char *(*GucShowHook) (void);
 
+/*
+ * Miscellaneous
+ */
 typedef enum
 {
        /* Types of set_config_option actions */
        GUC_ACTION_SET,                         /* regular SET command */
        GUC_ACTION_LOCAL,                       /* SET LOCAL command */
-       GUC_ACTION_SAVE                         /* function SET option */
+       GUC_ACTION_SAVE                         /* function SET option, or temp assignment */
 } GucAction;
 
 #define GUC_QUALIFIER_SEPARATOR '.'
@@ -158,18 +211,23 @@ typedef enum
 #define GUC_CUSTOM_PLACEHOLDER 0x0080  /* placeholder for custom variable */
 #define GUC_SUPERUSER_ONLY             0x0100  /* show only to superusers */
 #define GUC_IS_NAME                            0x0200  /* limit string to NAMEDATALEN-1 */
+#define GUC_NOT_WHILE_SEC_REST 0x0400  /* can't set if security restricted */
+#define GUC_DISALLOW_IN_AUTO_FILE 0x0800       /* can't set in
+                                                                                        * PG_AUTOCONF_FILENAME */
 
-#define GUC_UNIT_KB                            0x0400  /* value is in kilobytes */
-#define GUC_UNIT_BLOCKS                        0x0800  /* value is in blocks */
-#define GUC_UNIT_XBLOCKS               0x0C00  /* value is in xlog blocks */
-#define GUC_UNIT_MEMORY                        0x0C00  /* mask for KB, BLOCKS, XBLOCKS */
+#define GUC_UNIT_KB                            0x1000  /* value is in kilobytes */
+#define GUC_UNIT_BLOCKS                        0x2000  /* value is in blocks */
+#define GUC_UNIT_XBLOCKS               0x3000  /* value is in xlog blocks */
+#define GUC_UNIT_MB                            0x4000  /* value is in megabytes */
+#define GUC_UNIT_MEMORY                        0xF000  /* mask for size-related units */
 
-#define GUC_UNIT_MS                            0x1000  /* value is in milliseconds */
-#define GUC_UNIT_S                             0x2000  /* value is in seconds */
-#define GUC_UNIT_MIN                   0x4000  /* value is in minutes */
-#define GUC_UNIT_TIME                  0x7000  /* mask for MS, S, MIN */
+#define GUC_UNIT_MS                       0x10000      /* value is in milliseconds */
+#define GUC_UNIT_S                        0x20000      /* value is in seconds */
+#define GUC_UNIT_MIN              0x30000      /* value is in minutes */
+#define GUC_UNIT_TIME             0xF0000      /* mask for time-related units */
+
+#define GUC_UNIT                               (GUC_UNIT_MEMORY | GUC_UNIT_TIME)
 
-#define GUC_NOT_WHILE_SEC_REST 0x8000  /* can't set if security restricted */
 
 /* GUC vars that are actually declared in guc.c, rather than elsewhere */
 extern bool log_duration;
@@ -186,7 +244,6 @@ extern bool log_btree_build_stats;
 
 extern PGDLLIMPORT bool check_function_bodies;
 extern bool default_with_oids;
-extern bool SQL_inheritance;
 
 extern int     log_min_error_statement;
 extern int     log_min_messages;
@@ -194,14 +251,15 @@ extern int        client_min_messages;
 extern int     log_min_duration_statement;
 extern int     log_temp_files;
 
+extern int     temp_file_limit;
+
 extern int     num_temp_buffers;
 
-extern char *data_directory;
+extern char *cluster_name;
 extern char *ConfigFileName;
 extern char *HbaFileName;
 extern char *IdentFileName;
 extern char *external_pid_file;
-extern char *XactIsoLevel_string;
 
 extern char *application_name;
 
@@ -209,6 +267,13 @@ extern int tcp_keepalives_idle;
 extern int     tcp_keepalives_interval;
 extern int     tcp_keepalives_count;
 
+#ifdef TRACE_SORT
+extern bool trace_sort;
+#endif
+
+/*
+ * Functions exported by guc.c
+ */
 extern void SetConfigOption(const char *name, const char *value,
                                GucContext context, GucSource source);
 
@@ -220,6 +285,7 @@ extern void DefineCustomBoolVariable(
                                                 bool bootValue,
                                                 GucContext context,
                                                 int flags,
+                                                GucBoolCheckHook check_hook,
                                                 GucBoolAssignHook assign_hook,
                                                 GucShowHook show_hook);
 
@@ -233,6 +299,7 @@ extern void DefineCustomIntVariable(
                                                int maxValue,
                                                GucContext context,
                                                int flags,
+                                               GucIntCheckHook check_hook,
                                                GucIntAssignHook assign_hook,
                                                GucShowHook show_hook);
 
@@ -246,6 +313,7 @@ extern void DefineCustomRealVariable(
                                                 double maxValue,
                                                 GucContext context,
                                                 int flags,
+                                                GucRealCheckHook check_hook,
                                                 GucRealAssignHook assign_hook,
                                                 GucShowHook show_hook);
 
@@ -257,6 +325,7 @@ extern void DefineCustomStringVariable(
                                                   const char *bootValue,
                                                   GucContext context,
                                                   int flags,
+                                                  GucStringCheckHook check_hook,
                                                   GucStringAssignHook assign_hook,
                                                   GucShowHook show_hook);
 
@@ -266,15 +335,17 @@ extern void DefineCustomEnumVariable(
                                                 const char *long_desc,
                                                 int *valueAddr,
                                                 int bootValue,
-                                                const struct config_enum_entry * options,
+                                                const struct config_enum_entry *options,
                                                 GucContext context,
                                                 int flags,
+                                                GucEnumCheckHook check_hook,
                                                 GucEnumAssignHook assign_hook,
                                                 GucShowHook show_hook);
 
 extern void EmitWarningsOnPlaceholders(const char *className);
 
-extern const char *GetConfigOption(const char *name, bool restrict_superuser);
+extern const char *GetConfigOption(const char *name, bool missing_ok,
+                               bool restrict_superuser);
 extern const char *GetConfigOptionResetString(const char *name);
 extern void ProcessConfigFile(GucContext context);
 extern void InitializeGUCOptions(void);
@@ -288,10 +359,13 @@ extern void ParseLongOption(const char *string, char **name, char **value);
 extern bool parse_int(const char *value, int *result, int flags,
                  const char **hintmsg);
 extern bool parse_real(const char *value, double *result);
-extern bool set_config_option(const char *name, const char *value,
+extern int set_config_option(const char *name, const char *value,
                                  GucContext context, GucSource source,
-                                 GucAction action, bool changeVal);
-extern char *GetConfigOptionByName(const char *name, const char **varname);
+                                 GucAction action, bool changeVal, int elevel,
+                                 bool is_reload);
+extern void AlterSystemSetConfigFile(AlterSystemStmt *setstmt);
+extern char *GetConfigOptionByName(const char *name, const char **varname,
+                                         bool missing_ok);
 extern void GetConfigOptionByNum(int varnum, const char **values, bool *noshow);
 extern int     GetNumConfigOptions(void);
 
@@ -299,7 +373,7 @@ extern void SetPGVariable(const char *name, List *args, bool is_local);
 extern void GetPGVariable(const char *name, DestReceiver *dest);
 extern TupleDesc GetPGVariableResultDesc(const char *name);
 
-extern void ExecSetVariableStmt(VariableSetStmt *stmt);
+extern void ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel);
 extern char *ExtractSetVariableArgs(VariableSetStmt *stmt);
 
 extern void ProcessGUCArray(ArrayType *array,
@@ -308,15 +382,37 @@ extern ArrayType *GUCArrayAdd(ArrayType *array, const char *name, const char *va
 extern ArrayType *GUCArrayDelete(ArrayType *array, const char *name);
 extern ArrayType *GUCArrayReset(ArrayType *array);
 
-extern int     GUC_complaint_elevel(GucSource source);
-
-extern void pg_timezone_abbrev_initialize(void);
-
 #ifdef EXEC_BACKEND
 extern void write_nondefault_variables(GucContext context);
 extern void read_nondefault_variables(void);
 #endif
 
+/* GUC serialization */
+extern Size EstimateGUCStateSpace(void);
+extern void SerializeGUCState(Size maxsize, char *start_address);
+extern void RestoreGUCState(void *gucstate);
+
+/* Support for messages reported from GUC check hooks */
+
+extern PGDLLIMPORT char *GUC_check_errmsg_string;
+extern PGDLLIMPORT char *GUC_check_errdetail_string;
+extern PGDLLIMPORT char *GUC_check_errhint_string;
+
+extern void GUC_check_errcode(int sqlerrcode);
+
+#define GUC_check_errmsg \
+       pre_format_elog_string(errno, TEXTDOMAIN), \
+       GUC_check_errmsg_string = format_elog_string
+
+#define GUC_check_errdetail \
+       pre_format_elog_string(errno, TEXTDOMAIN), \
+       GUC_check_errdetail_string = format_elog_string
+
+#define GUC_check_errhint \
+       pre_format_elog_string(errno, TEXTDOMAIN), \
+       GUC_check_errhint_string = format_elog_string
+
+
 /*
  * 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
@@ -324,17 +420,16 @@ extern void read_nondefault_variables(void);
  */
 
 /* in commands/tablespace.c */
-extern const char *assign_default_tablespace(const char *newval,
-                                                 bool doit, GucSource source);
-extern const char *assign_temp_tablespaces(const char *newval,
-                                               bool doit, GucSource source);
+extern bool check_default_tablespace(char **newval, void **extra, GucSource source);
+extern bool check_temp_tablespaces(char **newval, void **extra, GucSource source);
+extern void assign_temp_tablespaces(const char *newval, void *extra);
 
 /* in catalog/namespace.c */
-extern const char *assign_search_path(const char *newval,
-                                  bool doit, GucSource source);
+extern bool check_search_path(char **newval, void **extra, GucSource source);
+extern void assign_search_path(const char *newval, void *extra);
 
 /* in access/transam/xlog.c */
-extern bool assign_xlog_sync_method(int newval,
-                                               bool doit, GucSource source);
+extern bool check_wal_buffers(int *newval, void **extra, GucSource source);
+extern void assign_xlog_sync_method(int new_sync_method, void *extra);
 
-#endif   /* GUC_H */
+#endif                                                 /* GUC_H */