aboutsummaryrefslogtreecommitdiff
path: root/src/include/utils/guc_tables.h
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2004-05-26 15:07:41 +0000
committerBruce Momjian <bruce@momjian.us>2004-05-26 15:07:41 +0000
commit3dc37cd8d6f6fd392c6965dfb0c4fd6b9232b8dd (patch)
tree06ca541c7b84faff5336b1ae0b6bfaa34d71e9a4 /src/include/utils/guc_tables.h
parentcfbfdc557d166ec559668d18d9769544f3c4fbbc (diff)
downloadpostgresql-3dc37cd8d6f6fd392c6965dfb0c4fd6b9232b8dd.tar.gz
postgresql-3dc37cd8d6f6fd392c6965dfb0c4fd6b9232b8dd.zip
The patch adresses the TODO list item "Allow external interfaces to
extend the GUC variable set". Plugin modules like the pl<lang> modules needs a way to declare configuration parameters. The postmaster has no knowledge of such modules when it reads the postgresql.conf file. Rather than allowing totally unknown configuration parameters, the concept of a variable "class" is introduced. Variables that belongs to a declared classes will create a placeholder value of string type and will not generate an error. When a module is loaded, it will declare variables for such a class and make those variables "consume" any placeholders that has been defined. Finally, the module will generate warnings for unrecognized placeholders defined for its class. More detail: The design is outlined after the suggestions made by Tom Lane and Joe Conway in this thread: http://archives.postgresql.org/pgsql-hackers/2004-02/msg00229.php A new string variable 'custom_variable_classes' is introduced. This variable is a comma separated string of identifiers. Each identifier denots a 'class' that will allow its members to be added without error. This variable must be defined in postmaster.conf. The lexer (guc_file.l) is changed so that it can accept a qualified name in the form <ID>.<ID> as the name of a variable. I also changed so that the 'custom_variable_classes', if found, is added first of all variables in order to remove the order of declaration issue. The guc_variables table is made more dynamic. It is originally created with 20% slack and can grow dynamically. A capacity is introduced to avoid resizing every time a new variable is added. guc_variables and num_guc_variables becomes static (hidden). The GucInfoMain now uses the new function get_guc_variables() and GetNumConfigOptions instead or using the guc_variables directly. The find_option() function, when passed a missing name, will check if the name is qualified. If the name is qualified and if the qualifier denotes a class included in the 'custom_variable_classes', a placeholder variable will be created. Such a placeholder will not participate in a list operation but will otherwise function as a normal string variable. Define<type>GucVariable() functions will be added, one for each variable type. They are inteded to be used by add-on modules like the pl<lang> mappings. Example: extern void DefineCustomBoolVariable( const char* name, const char* short_desc, const char* long_desc, bool* valueAddr, GucContext context, GucBoolAssignHook assign_hook, GucShowHook show_hook); (I created typedefs for the assign-hook and show-hook functions). A call to these functions will define a new GUC-variable. If a placeholder exists it will be replaced but it's value will be used in place of the default value. The valueAddr is assumed ot point at a default value when the define function is called. The only constraint that is imposed on a Custom variable is that its name is qualified. Finally, a function: void EmittWarningsOnPlacholders(const char* className) was added. This function should be called when a module has completed its variable definitions. At that time, no placeholders should remain for the class that the module uses. If they do, elog(INFO, ...) messages will be issued to inform the user that unrecognized variables are present. Thomas Hallgren
Diffstat (limited to 'src/include/utils/guc_tables.h')
-rw-r--r--src/include/utils/guc_tables.h27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/include/utils/guc_tables.h b/src/include/utils/guc_tables.h
index 1b99bf8159d..62d2d571b29 100644
--- a/src/include/utils/guc_tables.h
+++ b/src/include/utils/guc_tables.h
@@ -7,7 +7,7 @@
*
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.10 2004/04/05 03:02:11 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.11 2004/05/26 15:07:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -51,7 +51,8 @@ enum config_group
COMPAT_OPTIONS_PREVIOUS,
COMPAT_OPTIONS_CLIENT,
DEVELOPER_OPTIONS,
- COMPILE_OPTIONS
+ COMPILE_OPTIONS,
+ CUSTOM_OPTIONS
};
/*
@@ -98,6 +99,7 @@ struct config_generic
#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 a custom variable */
/* bit values in status field */
#define GUC_HAVE_TENTATIVE 0x0001 /* tentative value is defined */
@@ -113,8 +115,8 @@ struct config_bool
/* (all but reset_val are constants) */
bool *variable;
bool reset_val;
- bool (*assign_hook) (bool newval, bool doit, GucSource source);
- const char *(*show_hook) (void);
+ GucBoolAssignHook assign_hook;
+ GucShowHook show_hook;
/* variable fields, initialized at runtime: */
bool session_val;
bool tentative_val;
@@ -129,8 +131,8 @@ struct config_int
int reset_val;
int min;
int max;
- bool (*assign_hook) (int newval, bool doit, GucSource source);
- const char *(*show_hook) (void);
+ GucIntAssignHook assign_hook;
+ GucShowHook show_hook;
/* variable fields, initialized at runtime: */
int session_val;
int tentative_val;
@@ -145,8 +147,8 @@ struct config_real
double reset_val;
double min;
double max;
- bool (*assign_hook) (double newval, bool doit, GucSource source);
- const char *(*show_hook) (void);
+ GucRealAssignHook assign_hook;
+ GucShowHook show_hook;
/* variable fields, initialized at runtime: */
double session_val;
double tentative_val;
@@ -159,8 +161,8 @@ struct config_string
/* (all are constants) */
char **variable;
const char *boot_val;
- const char *(*assign_hook) (const char *newval, bool doit, GucSource source);
- const char *(*show_hook) (void);
+ GucStringAssignHook assign_hook;
+ GucShowHook show_hook;
/* variable fields, initialized at runtime: */
char *reset_val;
char *session_val;
@@ -173,9 +175,8 @@ extern const char *const config_type_names[];
extern const char *const GucContext_Names[];
extern const char *const GucSource_Names[];
-/* the current set of variables */
-extern struct config_generic **guc_variables;
-extern int num_guc_variables;
+/* get the current set of variables */
+extern struct config_generic **get_guc_variables(void);
extern void build_guc_variables(void);