Skip to content

Commit ab0a37f

Browse files
committed
Make the enumvals column of pg_settings be text[] instead of just
a comma separated string.
1 parent 47d6d64 commit ab0a37f

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

src/backend/utils/misc/guc.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
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);
168168
static const char *assign_pgstat_temp_directory(const char *newval, bool doit, GucSource source);
169169

170170
static 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
*/
44294432
static 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",

src/include/catalog/catversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
40-
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.508 2008/11/15 19:43:46 tgl Exp $
40+
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.509 2008/11/21 18:49:24 mha Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 200811151
56+
#define CATALOG_VERSION_NO 200811211
5757

5858
#endif

src/include/catalog/pg_proc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.528 2008/11/14 00:51:46 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.529 2008/11/21 18:49:24 mha Exp $
1111
*
1212
* NOTES
1313
* 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
31663166
DESCR("SHOW X as a function");
31673167
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_ ));
31683168
DESCR("SET X as a function");
3169-
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_ ));
3169+
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_ ));
31703170
DESCR("SHOW ALL as a function");
31713171
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_ ));
31723172
DESCR("view system lock information");

src/include/catalog/pg_type.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.202 2008/11/14 02:09:52 tgl Exp $
11+
* $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.203 2008/11/21 18:49:24 mha Exp $
1212
*
1313
* NOTES
1414
* 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
435435
#define INT4ARRAYOID 1007
436436
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_ ));
437437
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_ ));
438+
#define TEXTARRAYOID 1009
438439
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_ ));
439440
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_ ));
440441
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_ ));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy