]> granicus.if.org Git - postgresql/blobdiff - src/bin/psql/variables.c
psql: fix \connect with URIs and conninfo strings
[postgresql] / src / bin / psql / variables.c
index 1f871d7fa0127b208f25a7b69dd196a31d39e65f..b9a3dfad3316ec0875c4b15d46e917f71c354beb 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * psql - the PostgreSQL interactive terminal
  *
- * Copyright (c) 2000-2014, PostgreSQL Global Development Group
+ * Copyright (c) 2000-2015, PostgreSQL Global Development Group
  *
  * src/bin/psql/variables.c
  */
@@ -79,11 +79,16 @@ GetVariable(VariableSpace space, const char *name)
 }
 
 /*
- * Try to interpret value as boolean value.  Valid values are: true,
- * false, yes, no, on, off, 1, 0; as well as unique prefixes thereof.
+ * Try to interpret "value" as boolean value.
+ *
+ * Valid values are: true, false, yes, no, on, off, 1, 0; as well as unique
+ * prefixes thereof.
+ *
+ * "name" is the name of the variable we're assigning to, to use in error
+ * report if any.  Pass name == NULL to suppress the error report.
  */
 bool
-ParseVariableBool(const char *value)
+ParseVariableBool(const char *value, const char *name)
 {
        size_t          len;
 
@@ -112,7 +117,9 @@ ParseVariableBool(const char *value)
        else
        {
                /* NULL is treated as false, so a non-matching value is 'true' */
-               psql_error("unrecognized Boolean value; assuming \"on\"\n");
+               if (name)
+                       psql_error("unrecognized value \"%s\" for \"%s\"; assuming \"%s\"\n",
+                                          value, name, "on");
                return true;
        }
 }