Header And Logo

PostgreSQL
| The world's most advanced open source database.

guc_tables.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * guc_tables.h
00004  *      Declarations of tables used by GUC.
00005  *
00006  * See src/backend/utils/misc/README for design notes.
00007  *
00008  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00009  *
00010  *    src/include/utils/guc_tables.h
00011  *
00012  *-------------------------------------------------------------------------
00013  */
00014 #ifndef GUC_TABLES_H
00015 #define GUC_TABLES_H 1
00016 
00017 #include "utils/guc.h"
00018 
00019 /*
00020  * GUC supports these types of variables:
00021  */
00022 enum config_type
00023 {
00024     PGC_BOOL,
00025     PGC_INT,
00026     PGC_REAL,
00027     PGC_STRING,
00028     PGC_ENUM
00029 };
00030 
00031 union config_var_val
00032 {
00033     bool        boolval;
00034     int         intval;
00035     double      realval;
00036     char       *stringval;
00037     int         enumval;
00038 };
00039 
00040 /*
00041  * The actual value of a GUC variable can include a malloc'd opaque struct
00042  * "extra", which is created by its check_hook and used by its assign_hook.
00043  */
00044 typedef struct config_var_value
00045 {
00046     union config_var_val val;
00047     void       *extra;
00048 } config_var_value;
00049 
00050 /*
00051  * Groupings to help organize all the run-time options for display
00052  */
00053 enum config_group
00054 {
00055     UNGROUPED,
00056     FILE_LOCATIONS,
00057     CONN_AUTH,
00058     CONN_AUTH_SETTINGS,
00059     CONN_AUTH_SECURITY,
00060     RESOURCES,
00061     RESOURCES_MEM,
00062     RESOURCES_DISK,
00063     RESOURCES_KERNEL,
00064     RESOURCES_VACUUM_DELAY,
00065     RESOURCES_BGWRITER,
00066     RESOURCES_ASYNCHRONOUS,
00067     WAL,
00068     WAL_SETTINGS,
00069     WAL_CHECKPOINTS,
00070     WAL_ARCHIVING,
00071     REPLICATION,
00072     REPLICATION_SENDING,
00073     REPLICATION_MASTER,
00074     REPLICATION_STANDBY,
00075     QUERY_TUNING,
00076     QUERY_TUNING_METHOD,
00077     QUERY_TUNING_COST,
00078     QUERY_TUNING_GEQO,
00079     QUERY_TUNING_OTHER,
00080     LOGGING,
00081     LOGGING_WHERE,
00082     LOGGING_WHEN,
00083     LOGGING_WHAT,
00084     STATS,
00085     STATS_MONITORING,
00086     STATS_COLLECTOR,
00087     AUTOVACUUM,
00088     CLIENT_CONN,
00089     CLIENT_CONN_STATEMENT,
00090     CLIENT_CONN_LOCALE,
00091     CLIENT_CONN_OTHER,
00092     LOCK_MANAGEMENT,
00093     COMPAT_OPTIONS,
00094     COMPAT_OPTIONS_PREVIOUS,
00095     COMPAT_OPTIONS_CLIENT,
00096     ERROR_HANDLING_OPTIONS,
00097     PRESET_OPTIONS,
00098     CUSTOM_OPTIONS,
00099     DEVELOPER_OPTIONS
00100 };
00101 
00102 /*
00103  * Stack entry for saving the state a variable had prior to an uncommitted
00104  * transactional change
00105  */
00106 typedef enum
00107 {
00108     /* This is almost GucAction, but we need a fourth state for SET+LOCAL */
00109     GUC_SAVE,                   /* entry caused by function SET option */
00110     GUC_SET,                    /* entry caused by plain SET command */
00111     GUC_LOCAL,                  /* entry caused by SET LOCAL command */
00112     GUC_SET_LOCAL               /* entry caused by SET then SET LOCAL */
00113 } GucStackState;
00114 
00115 typedef struct guc_stack
00116 {
00117     struct guc_stack *prev;     /* previous stack item, if any */
00118     int         nest_level;     /* nesting depth at which we made entry */
00119     GucStackState state;        /* see enum above */
00120     GucSource   source;         /* source of the prior value */
00121     /* masked value's source must be PGC_S_SESSION, so no need to store it */
00122     GucContext  scontext;       /* context that set the prior value */
00123     GucContext  masked_scontext;    /* context that set the masked value */
00124     config_var_value prior;     /* previous value of variable */
00125     config_var_value masked;    /* SET value in a GUC_SET_LOCAL entry */
00126 } GucStack;
00127 
00128 /*
00129  * Generic fields applicable to all types of variables
00130  *
00131  * The short description should be less than 80 chars in length. Some
00132  * applications may use the long description as well, and will append
00133  * it to the short description. (separated by a newline or '. ')
00134  *
00135  * Note that sourcefile/sourceline are kept here, and not pushed into stacked
00136  * values, although in principle they belong with some stacked value if the
00137  * active value is session- or transaction-local.  This is to avoid bloating
00138  * stack entries.  We know they are only relevant when source == PGC_S_FILE.
00139  */
00140 struct config_generic
00141 {
00142     /* constant fields, must be set correctly in initial value: */
00143     const char *name;           /* name of variable - MUST BE FIRST */
00144     GucContext  context;        /* context required to set the variable */
00145     enum config_group group;    /* to help organize variables by function */
00146     const char *short_desc;     /* short desc. of this variable's purpose */
00147     const char *long_desc;      /* long desc. of this variable's purpose */
00148     int         flags;          /* flag bits, see guc.h */
00149     /* variable fields, initialized at runtime: */
00150     enum config_type vartype;   /* type of variable (set only at startup) */
00151     int         status;         /* status bits, see below */
00152     GucSource   source;         /* source of the current actual value */
00153     GucSource   reset_source;   /* source of the reset_value */
00154     GucContext  scontext;       /* context that set the current value */
00155     GucContext  reset_scontext; /* context that set the reset value */
00156     GucStack   *stack;          /* stacked prior values */
00157     void       *extra;          /* "extra" pointer for current actual value */
00158     char       *sourcefile;     /* file current setting is from (NULL if not
00159                                  * set in config file) */
00160     int         sourceline;     /* line in source file */
00161 };
00162 
00163 /* bit values in status field */
00164 #define GUC_IS_IN_FILE      0x0001      /* found it in config file */
00165 /*
00166  * Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
00167  * Do not assume that its value represents useful information elsewhere.
00168  */
00169 
00170 
00171 /* GUC records for specific variable types */
00172 
00173 struct config_bool
00174 {
00175     struct config_generic gen;
00176     /* constant fields, must be set correctly in initial value: */
00177     bool       *variable;
00178     bool        boot_val;
00179     GucBoolCheckHook check_hook;
00180     GucBoolAssignHook assign_hook;
00181     GucShowHook show_hook;
00182     /* variable fields, initialized at runtime: */
00183     bool        reset_val;
00184     void       *reset_extra;
00185 };
00186 
00187 struct config_int
00188 {
00189     struct config_generic gen;
00190     /* constant fields, must be set correctly in initial value: */
00191     int        *variable;
00192     int         boot_val;
00193     int         min;
00194     int         max;
00195     GucIntCheckHook check_hook;
00196     GucIntAssignHook assign_hook;
00197     GucShowHook show_hook;
00198     /* variable fields, initialized at runtime: */
00199     int         reset_val;
00200     void       *reset_extra;
00201 };
00202 
00203 struct config_real
00204 {
00205     struct config_generic gen;
00206     /* constant fields, must be set correctly in initial value: */
00207     double     *variable;
00208     double      boot_val;
00209     double      min;
00210     double      max;
00211     GucRealCheckHook check_hook;
00212     GucRealAssignHook assign_hook;
00213     GucShowHook show_hook;
00214     /* variable fields, initialized at runtime: */
00215     double      reset_val;
00216     void       *reset_extra;
00217 };
00218 
00219 struct config_string
00220 {
00221     struct config_generic gen;
00222     /* constant fields, must be set correctly in initial value: */
00223     char      **variable;
00224     const char *boot_val;
00225     GucStringCheckHook check_hook;
00226     GucStringAssignHook assign_hook;
00227     GucShowHook show_hook;
00228     /* variable fields, initialized at runtime: */
00229     char       *reset_val;
00230     void       *reset_extra;
00231 };
00232 
00233 struct config_enum
00234 {
00235     struct config_generic gen;
00236     /* constant fields, must be set correctly in initial value: */
00237     int        *variable;
00238     int         boot_val;
00239     const struct config_enum_entry *options;
00240     GucEnumCheckHook check_hook;
00241     GucEnumAssignHook assign_hook;
00242     GucShowHook show_hook;
00243     /* variable fields, initialized at runtime: */
00244     int         reset_val;
00245     void       *reset_extra;
00246 };
00247 
00248 /* constant tables corresponding to enums above and in guc.h */
00249 extern const char *const config_group_names[];
00250 extern const char *const config_type_names[];
00251 extern const char *const GucContext_Names[];
00252 extern const char *const GucSource_Names[];
00253 
00254 /* get the current set of variables */
00255 extern struct config_generic **get_guc_variables(void);
00256 
00257 extern void build_guc_variables(void);
00258 
00259 /* search in enum options */
00260 extern const char *config_enum_lookup_by_value(struct config_enum * record, int val);
00261 extern bool config_enum_lookup_by_name(struct config_enum * record,
00262                            const char *value, int *retval);
00263 
00264 
00265 #endif   /* GUC_TABLES_H */