Make the enumvals column of pg_settings be text[] instead of just
authorMagnus Hagander <[email protected]>
Fri, 21 Nov 2008 18:49:24 +0000 (18:49 +0000)
committerMagnus Hagander <[email protected]>
Fri, 21 Nov 2008 18:49:24 +0000 (18:49 +0000)
a comma separated string.

src/backend/utils/misc/guc.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.h
src/include/catalog/pg_type.h

index 5045d67875bc3d6e7d793cbdf15a14a08b299ef9..c806fbe489d4ceecc99a58f025aaa8b7431d304e 100644 (file)
@@ -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",
index 76b174749a115fb8378935c3b0126a252ac70b7e..4cf2d1078d21988b9ef87f02a4ae0e29d261c833 100644 (file)
@@ -53,6 +53,6 @@
  */
 
 /*                                                     yyyymmddN */
-#define CATALOG_VERSION_NO     200811151
+#define CATALOG_VERSION_NO     200811211
 
 #endif
index 5c79ee2f4af649f31dfd162de496f32ce40a285c..bb2bdcedc0893aae1375655baf70ef225fcbdb1e 100644 (file)
@@ -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");
index 9589a8e840777c9643dee5f8d0575bbe45166e29..4194e66cd2a6795c6e060d703ce2d3816e094e54 100644 (file)
@@ -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_ ));