1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-09 13:09:39 +03:00

Convert variable name to canonical spelling before checking for matches

in GUCArrayAdd/GUCArrayDelete.  This prevents the multiple-entry bug
exhibited by Frank Lupo 28-Jan-2003.
This commit is contained in:
Tom Lane
2003-01-28 18:04:13 +00:00
parent 93c3f36d22
commit c95ed02c49

View File

@@ -5,7 +5,7 @@
* command, configuration file, and command line options.
* See src/backend/utils/misc/README for more information.
*
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.99.2.3 2003/01/28 03:44:09 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.99.2.4 2003/01/28 18:04:13 tgl Exp $
*
* Copyright 2000 by PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>.
@@ -2802,6 +2802,7 @@ ProcessGUCArray(ArrayType *array, GucSource source)
ArrayType *
GUCArrayAdd(ArrayType *array, const char *name, const char *value)
{
const char *varname;
Datum datum;
char *newval;
ArrayType *a;
@@ -2814,6 +2815,10 @@ GUCArrayAdd(ArrayType *array, const char *name, const char *value)
superuser() ? PGC_SUSET : PGC_USERSET,
PGC_S_SESSION, false, false);
/* convert name to canonical spelling, so we can use plain strcmp */
(void) GetConfigOptionByName(name, &varname);
name = varname;
newval = palloc(strlen(name) + 1 + strlen(value) + 1);
sprintf(newval, "%s=%s", name, value);
datum = DirectFunctionCall1(textin, CStringGetDatum(newval));
@@ -2877,6 +2882,7 @@ GUCArrayAdd(ArrayType *array, const char *name, const char *value)
ArrayType *
GUCArrayDelete(ArrayType *array, const char *name)
{
const char *varname;
ArrayType *newarray;
int i;
int index;
@@ -2888,6 +2894,10 @@ GUCArrayDelete(ArrayType *array, const char *name)
superuser() ? PGC_SUSET : PGC_USERSET,
PGC_S_SESSION, false, false);
/* convert name to canonical spelling, so we can use plain strcmp */
(void) GetConfigOptionByName(name, &varname);
name = varname;
/* if array is currently null, then surely nothing to delete */
if (!array)
return NULL;