1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-07 00:36:50 +03:00

Implement enum type for guc parameters, and convert a couple of existing

variables to it. More need to be converted, but I wanted to get this in
before it conflicts with too much...

Other than just centralising the text-to-int conversion for parameters,
this allows the pg_settings view to contain a list of available options
and allows an error hint to show what values are allowed.
This commit is contained in:
Magnus Hagander
2008-03-10 12:55:13 +00:00
parent 23c356ccec
commit 52a8d4f8f7
11 changed files with 440 additions and 237 deletions

View File

@ -7,7 +7,7 @@
*
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.38 2008/01/01 19:45:59 momjian Exp $
* $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.39 2008/03/10 12:55:13 mha Exp $
*
*-------------------------------------------------------------------------
*/
@ -24,7 +24,8 @@ enum config_type
PGC_BOOL,
PGC_INT,
PGC_REAL,
PGC_STRING
PGC_STRING,
PGC_ENUM
};
union config_var_value
@ -33,6 +34,16 @@ union config_var_value
int intval;
double realval;
char *stringval;
int enumval;
};
/*
* Enum values are made up of an array of name-value pairs
*/
struct config_enum_entry
{
const char *name;
int val;
};
/*
@ -210,6 +221,19 @@ struct config_string
char *reset_val;
};
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;
GucEnumAssignHook assign_hook;
GucShowHook show_hook;
/* variable fields, initialized at runtime: */
int reset_val;
};
/* constant tables corresponding to enums above and in guc.h */
extern const char *const config_group_names[];
extern const char *const config_type_names[];