Commit c0276244 authored by Tom Lane's avatar Tom Lane

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.
parent 7af352d0
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* command, configuration file, and command line options. * command, configuration file, and command line options.
* See src/backend/utils/misc/README for more information. * See src/backend/utils/misc/README for more information.
* *
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.112 2003/01/27 23:55:38 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.113 2003/01/28 18:04:02 tgl Exp $
* *
* Copyright 2000 by PostgreSQL Global Development Group * Copyright 2000 by PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>. * Written by Peter Eisentraut <peter_e@gmx.net>.
...@@ -2834,6 +2834,7 @@ ProcessGUCArray(ArrayType *array, GucSource source) ...@@ -2834,6 +2834,7 @@ ProcessGUCArray(ArrayType *array, GucSource source)
ArrayType * ArrayType *
GUCArrayAdd(ArrayType *array, const char *name, const char *value) GUCArrayAdd(ArrayType *array, const char *name, const char *value)
{ {
const char *varname;
Datum datum; Datum datum;
char *newval; char *newval;
ArrayType *a; ArrayType *a;
...@@ -2846,6 +2847,10 @@ GUCArrayAdd(ArrayType *array, const char *name, const char *value) ...@@ -2846,6 +2847,10 @@ GUCArrayAdd(ArrayType *array, const char *name, const char *value)
superuser() ? PGC_SUSET : PGC_USERSET, superuser() ? PGC_SUSET : PGC_USERSET,
PGC_S_SESSION, false, false); 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); newval = palloc(strlen(name) + 1 + strlen(value) + 1);
sprintf(newval, "%s=%s", name, value); sprintf(newval, "%s=%s", name, value);
datum = DirectFunctionCall1(textin, CStringGetDatum(newval)); datum = DirectFunctionCall1(textin, CStringGetDatum(newval));
...@@ -2909,6 +2914,7 @@ GUCArrayAdd(ArrayType *array, const char *name, const char *value) ...@@ -2909,6 +2914,7 @@ GUCArrayAdd(ArrayType *array, const char *name, const char *value)
ArrayType * ArrayType *
GUCArrayDelete(ArrayType *array, const char *name) GUCArrayDelete(ArrayType *array, const char *name)
{ {
const char *varname;
ArrayType *newarray; ArrayType *newarray;
int i; int i;
int index; int index;
...@@ -2920,6 +2926,10 @@ GUCArrayDelete(ArrayType *array, const char *name) ...@@ -2920,6 +2926,10 @@ GUCArrayDelete(ArrayType *array, const char *name)
superuser() ? PGC_SUSET : PGC_USERSET, superuser() ? PGC_SUSET : PGC_USERSET,
PGC_S_SESSION, false, false); 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 is currently null, then surely nothing to delete */
if (!array) if (!array)
return NULL; return NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment