1010 * Written by Peter Eisentraut <peter_e@gmx.net>.
1111 *
1212 * IDENTIFICATION
13- * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.479 2008/11/19 02:07:07 tgl Exp $
13+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.480 2008/11/21 18:49:24 mha Exp $
1414 *
1515 *--------------------------------------------------------------------
1616 */
@@ -168,11 +168,14 @@ static bool assign_maxconnections(int newval, bool doit, GucSource source);
168168static const char * assign_pgstat_temp_directory (const char * newval , bool doit , GucSource source );
169169
170170static char * config_enum_get_options (struct config_enum * record ,
171- const char * prefix , const char * suffix );
171+ const char * prefix , const char * suffix ,
172+ const char * separator );
172173
173174
174175/*
175176 * Options for enum values defined in this module.
177+ *
178+ * NOTE! Option values may not contain double quotes!
176179 */
177180
178181/*
@@ -4427,7 +4430,8 @@ config_enum_lookup_by_name(struct config_enum *record, const char *value, int *r
44274430 * If suffix is non-NULL, it is added to the end of the string.
44284431 */
44294432static char *
4430- config_enum_get_options (struct config_enum * record , const char * prefix , const char * suffix )
4433+ config_enum_get_options (struct config_enum * record , const char * prefix ,
4434+ const char * suffix , const char * separator )
44314435{
44324436 const struct config_enum_entry * entry = record -> options ;
44334437 int len = 0 ;
@@ -4439,7 +4443,7 @@ config_enum_get_options(struct config_enum *record, const char *prefix, const ch
44394443 while (entry && entry -> name )
44404444 {
44414445 if (!entry -> hidden )
4442- len += strlen (entry -> name ) + 2 ; /* string and ", " */
4446+ len += strlen (entry -> name ) + strlen ( separator );
44434447
44444448 entry ++ ;
44454449 }
@@ -4454,7 +4458,7 @@ config_enum_get_options(struct config_enum *record, const char *prefix, const ch
44544458 if (!entry -> hidden )
44554459 {
44564460 strcat (hintmsg , entry -> name );
4457- strcat (hintmsg , ", " );
4461+ strcat (hintmsg , separator );
44584462 }
44594463
44604464 entry ++ ;
@@ -4469,16 +4473,15 @@ config_enum_get_options(struct config_enum *record, const char *prefix, const ch
44694473 * to make sure we don't write to invalid memory instead of actually
44704474 * trying to do something smart with it.
44714475 */
4472- if (len > 1 )
4473- /* Replace final comma/space */
4474- hintmsg [len - 2 ] = '\0' ;
4476+ if (len >= strlen ( separator ) )
4477+ /* Replace final separator */
4478+ hintmsg [len - strlen ( separator ) ] = '\0' ;
44754479
44764480 strcat (hintmsg , suffix );
44774481
44784482 return hintmsg ;
44794483}
44804484
4481-
44824485/*
44834486 * Call a GucStringAssignHook function, being careful to free the
44844487 * "newval" string if the hook ereports.
@@ -5044,7 +5047,7 @@ set_config_option(const char *name, const char *value,
50445047 {
50455048 if (!config_enum_lookup_by_name (conf , value , & newval ))
50465049 {
5047- char * hintmsg = config_enum_get_options (conf , "Available values: " , "." );
5050+ char * hintmsg = config_enum_get_options (conf , "Available values: " , "." , ", " );
50485051
50495052 ereport (elevel ,
50505053 (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
@@ -6249,7 +6252,8 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
62496252 values [10 ] = NULL ;
62506253
62516254 /* enumvals */
6252- values [11 ] = config_enum_get_options ((struct config_enum * ) conf , "" , "" );
6255+ /* NOTE! enumvals with double quotes in them are not supported! */
6256+ values [11 ] = config_enum_get_options ((struct config_enum * ) conf , "{\"" , "\"}" , "\",\"" );
62536257
62546258 /* boot_val */
62556259 values [12 ] = pstrdup (config_enum_lookup_by_value (lconf , lconf -> boot_val ));
@@ -6385,7 +6389,7 @@ show_all_settings(PG_FUNCTION_ARGS)
63856389 TupleDescInitEntry (tupdesc , (AttrNumber ) 11 , "max_val" ,
63866390 TEXTOID , -1 , 0 );
63876391 TupleDescInitEntry (tupdesc , (AttrNumber ) 12 , "enumvals" ,
6388- TEXTOID , -1 , 0 );
6392+ TEXTARRAYOID , -1 , 0 );
63896393 TupleDescInitEntry (tupdesc , (AttrNumber ) 13 , "boot_val" ,
63906394 TEXTOID , -1 , 0 );
63916395 TupleDescInitEntry (tupdesc , (AttrNumber ) 14 , "reset_val" ,
0 commit comments