For GUC values, check for partial string matches on 'on' and 'off', but
authorBruce Momjian <bruce@momjian.us>
Sat, 23 Dec 2006 00:52:40 +0000 (00:52 +0000)
committerBruce Momjian <bruce@momjian.us>
Sat, 23 Dec 2006 00:52:40 +0000 (00:52 +0000)
require at least two characters for uniqueness.   This now matches the
behavior of other boolean strings we support, per report from Gurjeet
Singh.

src/backend/utils/misc/guc.c

index d38bc6f932613677891263af13c04c4fe09b9346..6c6ff1fb5a36d7181d7a8826be8f6c8e711c032b 100644 (file)
@@ -10,7 +10,7 @@
  * Written by Peter Eisentraut <peter_e@gmx.net>.
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.362 2006/12/13 05:54:48 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.363 2006/12/23 00:52:40 momjian Exp $
  *
  *--------------------------------------------------------------------
  */
@@ -3575,12 +3575,13 @@ parse_bool(const char *value, bool *result)
                        *result = false;
        }
 
-       else if (pg_strcasecmp(value, "on") == 0)
+       /* 'o' is not unique enough */
+       else if (pg_strncasecmp(value, "on", (len > 2 ? len : 2)) == 0)
        {
                if (result)
                        *result = true;
        }
-       else if (pg_strcasecmp(value, "off") == 0)
+       else if (pg_strncasecmp(value, "off", (len > 2 ? len : 2)) == 0)
        {
                if (result)
                        *result = false;