From ab0a37fe0705b23360ba69124a84d224203b3d81 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Fri, 21 Nov 2008 18:49:24 +0000 Subject: [PATCH] Make the enumvals column of pg_settings be text[] instead of just a comma separated string. --- src/backend/utils/misc/guc.c | 28 ++++++++++++++++------------ src/include/catalog/catversion.h | 4 ++-- src/include/catalog/pg_proc.h | 4 ++-- src/include/catalog/pg_type.h | 3 ++- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 2d1babc5ae..40e05ed00c 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -10,7 +10,7 @@ * Written by Peter Eisentraut . * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.479 2008/11/19 02:07:07 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.480 2008/11/21 18:49:24 mha Exp $ * *-------------------------------------------------------------------- */ @@ -168,11 +168,14 @@ static bool assign_maxconnections(int newval, bool doit, GucSource source); static const char *assign_pgstat_temp_directory(const char *newval, bool doit, GucSource source); static char *config_enum_get_options(struct config_enum *record, - const char *prefix, const char *suffix); + const char *prefix, const char *suffix, + const char *separator); /* * Options for enum values defined in this module. + * + * NOTE! Option values may not contain double quotes! */ /* @@ -4427,7 +4430,8 @@ config_enum_lookup_by_name(struct config_enum *record, const char *value, int *r * If suffix is non-NULL, it is added to the end of the string. */ static char * -config_enum_get_options(struct config_enum *record, const char *prefix, const char *suffix) +config_enum_get_options(struct config_enum *record, const char *prefix, + const char *suffix, const char *separator) { const struct config_enum_entry *entry = record->options; int len = 0; @@ -4439,7 +4443,7 @@ config_enum_get_options(struct config_enum *record, const char *prefix, const ch while (entry && entry->name) { if (!entry->hidden) - len += strlen(entry->name) + 2; /* string and ", " */ + len += strlen(entry->name) + strlen(separator); entry++; } @@ -4454,7 +4458,7 @@ config_enum_get_options(struct config_enum *record, const char *prefix, const ch if (!entry->hidden) { strcat(hintmsg, entry->name); - strcat(hintmsg, ", "); + strcat(hintmsg, separator); } entry++; @@ -4469,16 +4473,15 @@ config_enum_get_options(struct config_enum *record, const char *prefix, const ch * to make sure we don't write to invalid memory instead of actually * trying to do something smart with it. */ - if (len > 1) - /* Replace final comma/space */ - hintmsg[len-2] = '\0'; + if (len >= strlen(separator)) + /* Replace final separator */ + hintmsg[len-strlen(separator)] = '\0'; strcat(hintmsg, suffix); return hintmsg; } - /* * Call a GucStringAssignHook function, being careful to free the * "newval" string if the hook ereports. @@ -5044,7 +5047,7 @@ set_config_option(const char *name, const char *value, { if (!config_enum_lookup_by_name(conf, value, &newval)) { - char *hintmsg = config_enum_get_options(conf, "Available values: ", "."); + char *hintmsg = config_enum_get_options(conf, "Available values: ", ".", ", "); ereport(elevel, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), @@ -6249,7 +6252,8 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow) values[10] = NULL; /* enumvals */ - values[11] = config_enum_get_options((struct config_enum *) conf, "", ""); + /* NOTE! enumvals with double quotes in them are not supported! */ + values[11] = config_enum_get_options((struct config_enum *) conf, "{\"", "\"}", "\",\""); /* boot_val */ values[12] = pstrdup(config_enum_lookup_by_value(lconf, lconf->boot_val)); @@ -6385,7 +6389,7 @@ show_all_settings(PG_FUNCTION_ARGS) TupleDescInitEntry(tupdesc, (AttrNumber) 11, "max_val", TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 12, "enumvals", - TEXTOID, -1, 0); + TEXTARRAYOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 13, "boot_val", TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 14, "reset_val", diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index b3a84bd7fd..d479aeacef 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.508 2008/11/15 19:43:46 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.509 2008/11/21 18:49:24 mha Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200811151 +#define CATALOG_VERSION_NO 200811211 #endif diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 56b7f6786a..48850e9551 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.528 2008/11/14 00:51:46 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.529 2008/11/21 18:49:24 mha Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -3166,7 +3166,7 @@ DATA(insert OID = 2077 ( current_setting PGNSP PGUID 12 1 0 0 f f t f s 1 25 "2 DESCR("SHOW X as a function"); DATA(insert OID = 2078 ( set_config PGNSP PGUID 12 1 0 0 f f f f v 3 25 "25 25 16" _null_ _null_ _null_ set_config_by_name _null_ _null_ _null_ )); DESCR("SET X as a function"); -DATA(insert OID = 2084 ( pg_show_all_settings PGNSP PGUID 12 1 1000 0 f f t t s 0 2249 "" "{25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,23}" "{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}" "{name,setting,unit,category,short_desc,extra_desc,context,vartype,source,min_val,max_val,enumvals,boot_val,reset_val,sourcefile,sourceline}" show_all_settings _null_ _null_ _null_ )); +DATA(insert OID = 2084 ( pg_show_all_settings PGNSP PGUID 12 1 1000 0 f f t t s 0 2249 "" "{25,25,25,25,25,25,25,25,25,25,25,1009,25,25,25,23}" "{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}" "{name,setting,unit,category,short_desc,extra_desc,context,vartype,source,min_val,max_val,enumvals,boot_val,reset_val,sourcefile,sourceline}" show_all_settings _null_ _null_ _null_ )); DESCR("SHOW ALL as a function"); DATA(insert OID = 1371 ( pg_lock_status PGNSP PGUID 12 1 1000 0 f f t t v 0 2249 "" "{25,26,26,23,21,25,28,26,26,21,25,23,25,16}" "{o,o,o,o,o,o,o,o,o,o,o,o,o,o}" "{locktype,database,relation,page,tuple,virtualxid,transactionid,classid,objid,objsubid,virtualtransaction,pid,mode,granted}" pg_lock_status _null_ _null_ _null_ )); DESCR("view system lock information"); diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index 45c89630f6..4e69c59102 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.202 2008/11/14 02:09:52 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.203 2008/11/21 18:49:24 mha Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -435,6 +435,7 @@ DATA(insert OID = 1007 ( _int4 PGNSP PGUID -1 f b A f t \054 0 23 0 array_in #define INT4ARRAYOID 1007 DATA(insert OID = 1008 ( _regproc PGNSP PGUID -1 f b A f t \054 0 24 0 array_in array_out array_recv array_send - - - i x f 0 -1 0 _null_ _null_ )); DATA(insert OID = 1009 ( _text PGNSP PGUID -1 f b A f t \054 0 25 0 array_in array_out array_recv array_send - - - i x f 0 -1 0 _null_ _null_ )); +#define TEXTARRAYOID 1009 DATA(insert OID = 1028 ( _oid PGNSP PGUID -1 f b A f t \054 0 26 0 array_in array_out array_recv array_send - - - i x f 0 -1 0 _null_ _null_ )); DATA(insert OID = 1010 ( _tid PGNSP PGUID -1 f b A f t \054 0 27 0 array_in array_out array_recv array_send - - - i x f 0 -1 0 _null_ _null_ )); DATA(insert OID = 1011 ( _xid PGNSP PGUID -1 f b A f t \054 0 28 0 array_in array_out array_recv array_send - - - i x f 0 -1 0 _null_ _null_ )); -- 2.11.0