]> granicus.if.org Git - postgresql/commitdiff
Check for multiple arguments on parameters which do not allow them.
authorThomas G. Lockhart <lockhart@fourpalms.org>
Mon, 22 Apr 2002 14:34:27 +0000 (14:34 +0000)
committerThomas G. Lockhart <lockhart@fourpalms.org>
Mon, 22 Apr 2002 14:34:27 +0000 (14:34 +0000)
 The last version caught this with an assert because I wasn't sure whether
 we should elog(ERROR) or just loop through the parameters.

src/backend/commands/variable.c

index 504f9c56b6f006028cf09e6b15750cf996b07e43..0498c734ec16cf8588b52db9c9aaa180560895dd 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.63 2002/04/21 21:35:17 thomas Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.64 2002/04/22 14:34:27 thomas Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -593,7 +593,8 @@ parse_XactIsoLevel(List *args)
        Assert(IsA(args, List));
        Assert(IsA(lfirst(args), A_Const));
        /* Should only get one argument from the parser */
-       Assert(lnext(args) == NIL);
+       if (lnext(args) != NIL)
+               elog(ERROR, "SET TRANSACTION ISOLATION LEVEL does not allow multiple arguments");
 
        Assert(((A_Const *) lfirst(args))->val.type = T_String);
        value = ((A_Const *) lfirst(args))->val.val.str;
@@ -655,7 +656,8 @@ parse_random_seed(List *args)
 
        Assert(IsA(args, List));
        /* Should only get one argument from the parser */
-       Assert(lnext(args) == NIL);
+       if (lnext(args) != NIL)
+               elog(ERROR, "SET SEED does not allow multiple arguments");
 
        p = lfirst(args);
        Assert(IsA(p, A_Const));
@@ -717,6 +719,9 @@ parse_client_encoding(List *args)
        if (args == NULL)
                return reset_client_encoding();
 
+       if (lnext(args) != NIL)
+               elog(ERROR, "SET CLIENT ENCODING does not allow multiple arguments");
+
        Assert(IsA(lfirst(args), A_Const));
        if (((A_Const *) lfirst(args))->val.type != T_String)
        {
@@ -844,7 +849,8 @@ SetPGVariable(const char *name, List *args)
 
                        /* Ensure one argument only... */
                        if (lnext(args) != NIL)
-                               elog(ERROR, "SET takes only one argument for this parameter");
+                               elog(ERROR, "SET %s takes only one argument", name);
+
                        n = (A_Const *) lfirst(args);
                        /* If this is a T_Integer, then we should convert back to a string
                         * but for now we just reject the parameter.