]> granicus.if.org Git - postgresql/blobdiff - src/include/utils/guc_tables.h
Update copyright for 2014
[postgresql] / src / include / utils / guc_tables.h
index 6345fb1abd7986e9dcc9d4c559b64a8442449bb7..47ff88051787d2f0e40da36b6f7828ec73f70a2b 100644 (file)
@@ -5,9 +5,9 @@
  *
  * See src/backend/utils/misc/README for design notes.
  *
- * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
  *
- *       $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.27 2006/08/13 02:22:24 momjian Exp $
+ *       src/include/utils/guc_tables.h
  *
  *-------------------------------------------------------------------------
  */
@@ -24,17 +24,29 @@ enum config_type
        PGC_BOOL,
        PGC_INT,
        PGC_REAL,
-       PGC_STRING
+       PGC_STRING,
+       PGC_ENUM
 };
 
-union config_var_value
+union config_var_val
 {
        bool            boolval;
        int                     intval;
        double          realval;
        char       *stringval;
+       int                     enumval;
 };
 
+/*
+ * The actual value of a GUC variable can include a malloc'd opaque struct
+ * "extra", which is created by its check_hook and used by its assign_hook.
+ */
+typedef struct config_var_value
+{
+       union config_var_val val;
+       void       *extra;
+} config_var_value;
+
 /*
  * Groupings to help organize all the run-time options for display
  */
@@ -47,11 +59,19 @@ enum config_group
        CONN_AUTH_SECURITY,
        RESOURCES,
        RESOURCES_MEM,
-       RESOURCES_FSM,
+       RESOURCES_DISK,
        RESOURCES_KERNEL,
+       RESOURCES_VACUUM_DELAY,
+       RESOURCES_BGWRITER,
+       RESOURCES_ASYNCHRONOUS,
        WAL,
        WAL_SETTINGS,
        WAL_CHECKPOINTS,
+       WAL_ARCHIVING,
+       REPLICATION,
+       REPLICATION_SENDING,
+       REPLICATION_MASTER,
+       REPLICATION_STANDBY,
        QUERY_TUNING,
        QUERY_TUNING_METHOD,
        QUERY_TUNING_COST,
@@ -68,29 +88,42 @@ enum config_group
        CLIENT_CONN,
        CLIENT_CONN_STATEMENT,
        CLIENT_CONN_LOCALE,
+       CLIENT_CONN_PRELOAD,
        CLIENT_CONN_OTHER,
        LOCK_MANAGEMENT,
        COMPAT_OPTIONS,
        COMPAT_OPTIONS_PREVIOUS,
        COMPAT_OPTIONS_CLIENT,
+       ERROR_HANDLING_OPTIONS,
        PRESET_OPTIONS,
        CUSTOM_OPTIONS,
        DEVELOPER_OPTIONS
 };
 
 /*
- * Stack entry for saving the state of a variable prior to the current
- * transaction
+ * Stack entry for saving the state a variable had prior to an uncommitted
+ * transactional change
  */
+typedef enum
+{
+       /* This is almost GucAction, but we need a fourth state for SET+LOCAL */
+       GUC_SAVE,                                       /* entry caused by function SET option */
+       GUC_SET,                                        /* entry caused by plain SET command */
+       GUC_LOCAL,                                      /* entry caused by SET LOCAL command */
+       GUC_SET_LOCAL                           /* entry caused by SET then SET LOCAL */
+} GucStackState;
+
 typedef struct guc_stack
 {
        struct guc_stack *prev;         /* previous stack item, if any */
-       int                     nest_level;             /* nesting depth of cur transaction */
-       int                     status;                 /* previous status bits, see below */
-       GucSource       tentative_source;               /* source of the tentative_value */
-       GucSource       source;                 /* source of the actual value */
-       union config_var_value tentative_val;           /* previous tentative val */
-       union config_var_value value;           /* previous actual value */
+       int                     nest_level;             /* nesting depth at which we made entry */
+       GucStackState state;            /* see enum above */
+       GucSource       source;                 /* source of the prior value */
+       /* masked value's source must be PGC_S_SESSION, so no need to store it */
+       GucContext      scontext;               /* context that set the prior value */
+       GucContext      masked_scontext;        /* context that set the masked value */
+       config_var_value prior;         /* previous value of variable */
+       config_var_value masked;        /* SET value in a GUC_SET_LOCAL entry */
 } GucStack;
 
 /*
@@ -99,6 +132,11 @@ typedef struct guc_stack
  * The short description should be less than 80 chars in length. Some
  * applications may use the long description as well, and will append
  * it to the short description. (separated by a newline or '. ')
+ *
+ * Note that sourcefile/sourceline are kept here, and not pushed into stacked
+ * values, although in principle they belong with some stacked value if the
+ * active value is session- or transaction-local.  This is to avoid bloating
+ * stack entries.  We know they are only relevant when source == PGC_S_FILE.
  */
 struct config_generic
 {
@@ -108,104 +146,104 @@ struct config_generic
        enum config_group group;        /* to help organize variables by function */
        const char *short_desc;         /* short desc. of this variable's purpose */
        const char *long_desc;          /* long desc. of this variable's purpose */
-       int                     flags;                  /* flag bits, see below */
+       int                     flags;                  /* flag bits, see guc.h */
        /* variable fields, initialized at runtime: */
        enum config_type vartype;       /* type of variable (set only at startup) */
        int                     status;                 /* status bits, see below */
-       GucSource       reset_source;   /* source of the reset_value */
-       GucSource       tentative_source;               /* source of the tentative_value */
        GucSource       source;                 /* source of the current actual value */
-       GucStack   *stack;                      /* stacked outside-of-transaction states */
+       GucSource       reset_source;   /* source of the reset_value */
+       GucContext      scontext;               /* context that set the current value */
+       GucContext      reset_scontext; /* context that set the reset value */
+       GucStack   *stack;                      /* stacked prior values */
+       void       *extra;                      /* "extra" pointer for current actual value */
+       char       *sourcefile;         /* file current setting is from (NULL if not
+                                                                * set in config file) */
+       int                     sourceline;             /* line in source file */
 };
 
-/* bit values in flags field */
-#define GUC_LIST_INPUT                 0x0001  /* input can be list format */
-#define GUC_LIST_QUOTE                 0x0002  /* double-quote list elements */
-#define GUC_NO_SHOW_ALL                        0x0004  /* exclude from SHOW ALL */
-#define GUC_NO_RESET_ALL               0x0008  /* exclude from RESET ALL */
-#define GUC_REPORT                             0x0010  /* auto-report changes to client */
-#define GUC_NOT_IN_SAMPLE              0x0020  /* not in postgresql.conf.sample */
-#define GUC_DISALLOW_IN_FILE   0x0040  /* can't set in postgresql.conf */
-#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_UNIT_KB                            0x0400  /* value is in 1 kB */
-#define GUC_UNIT_BLOCKS                        0x0800  /* value is in blocks */
-#define GUC_UNIT_MEMORY                        (GUC_UNIT_KB|GUC_UNIT_BLOCKS)
-
-#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                  (GUC_UNIT_MS|GUC_UNIT_S|GUC_UNIT_MIN)
-
 /* bit values in status field */
-#define GUC_HAVE_TENTATIVE     0x0001          /* tentative value is defined */
-#define GUC_HAVE_LOCAL         0x0002          /* a SET LOCAL has been executed */
-#define GUC_HAVE_STACK         0x0004          /* we have stacked prior value(s) */
-#define GUC_IN_CONFFILE                0x0008          /* value shows up in the configuration
-                                                                                  file (is not commented) */
+#define GUC_IS_IN_FILE         0x0001          /* found it in config file */
+/*
+ * Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
+ * Do not assume that its value represents useful information elsewhere.
+ */
+
 
 /* GUC records for specific variable types */
 
 struct config_bool
 {
        struct config_generic gen;
-       /* these fields must be set correctly in initial value: */
-       /* (all but reset_val are constants) */
+       /* constant fields, must be set correctly in initial value: */
        bool       *variable;
        bool            boot_val;
+       GucBoolCheckHook check_hook;
        GucBoolAssignHook assign_hook;
        GucShowHook show_hook;
        /* variable fields, initialized at runtime: */
-       bool            tentative_val;
        bool            reset_val;
+       void       *reset_extra;
 };
 
 struct config_int
 {
        struct config_generic gen;
-       /* these fields must be set correctly in initial value: */
-       /* (all but reset_val are constants) */
+       /* constant fields, must be set correctly in initial value: */
        int                *variable;
        int                     boot_val;
        int                     min;
        int                     max;
+       GucIntCheckHook check_hook;
        GucIntAssignHook assign_hook;
        GucShowHook show_hook;
        /* variable fields, initialized at runtime: */
-       int                     tentative_val;
        int                     reset_val;
+       void       *reset_extra;
 };
 
 struct config_real
 {
        struct config_generic gen;
-       /* these fields must be set correctly in initial value: */
-       /* (all but reset_val are constants) */
+       /* constant fields, must be set correctly in initial value: */
        double     *variable;
        double          boot_val;
        double          min;
        double          max;
+       GucRealCheckHook check_hook;
        GucRealAssignHook assign_hook;
        GucShowHook show_hook;
        /* variable fields, initialized at runtime: */
-       double          tentative_val;
        double          reset_val;
+       void       *reset_extra;
 };
 
 struct config_string
 {
        struct config_generic gen;
-       /* these fields must be set correctly in initial value: */
-       /* (all are constants) */
+       /* constant fields, must be set correctly in initial value: */
        char      **variable;
        const char *boot_val;
+       GucStringCheckHook check_hook;
        GucStringAssignHook assign_hook;
        GucShowHook show_hook;
        /* variable fields, initialized at runtime: */
        char       *reset_val;
-       char       *tentative_val;
+       void       *reset_extra;
+};
+
+struct config_enum
+{
+       struct config_generic gen;
+       /* constant fields, must be set correctly in initial value: */
+       int                *variable;
+       int                     boot_val;
+       const struct config_enum_entry *options;
+       GucEnumCheckHook check_hook;
+       GucEnumAssignHook assign_hook;
+       GucShowHook show_hook;
+       /* variable fields, initialized at runtime: */
+       int                     reset_val;
+       void       *reset_extra;
 };
 
 /* constant tables corresponding to enums above and in guc.h */
@@ -219,4 +257,9 @@ extern struct config_generic **get_guc_variables(void);
 
 extern void build_guc_variables(void);
 
+/* search in enum options */
+extern const char *config_enum_lookup_by_value(struct config_enum * record, int val);
+extern bool config_enum_lookup_by_name(struct config_enum * record,
+                                                  const char *value, int *retval);
+
 #endif   /* GUC_TABLES_H */