1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-21 12:05:57 +03:00

Check for multiple arguments on parameters which do not allow them.

The last version caught this with an assert because I wasn't sure whether
 we should elog(ERROR) or just loop through the parameters.
This commit is contained in:
Thomas G. Lockhart 2002-04-22 14:34:27 +00:00
parent 8d2441e55c
commit 58ca6e091e

View File

@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * 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(args, List));
Assert(IsA(lfirst(args), A_Const)); Assert(IsA(lfirst(args), A_Const));
/* Should only get one argument from the parser */ /* 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); Assert(((A_Const *) lfirst(args))->val.type = T_String);
value = ((A_Const *) lfirst(args))->val.val.str; value = ((A_Const *) lfirst(args))->val.val.str;
@ -655,7 +656,8 @@ parse_random_seed(List *args)
Assert(IsA(args, List)); Assert(IsA(args, List));
/* Should only get one argument from the parser */ /* 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); p = lfirst(args);
Assert(IsA(p, A_Const)); Assert(IsA(p, A_Const));
@ -717,6 +719,9 @@ parse_client_encoding(List *args)
if (args == NULL) if (args == NULL)
return reset_client_encoding(); return reset_client_encoding();
if (lnext(args) != NIL)
elog(ERROR, "SET CLIENT ENCODING does not allow multiple arguments");
Assert(IsA(lfirst(args), A_Const)); Assert(IsA(lfirst(args), A_Const));
if (((A_Const *) lfirst(args))->val.type != T_String) if (((A_Const *) lfirst(args))->val.type != T_String)
{ {
@ -844,7 +849,8 @@ SetPGVariable(const char *name, List *args)
/* Ensure one argument only... */ /* Ensure one argument only... */
if (lnext(args) != NIL) 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); n = (A_Const *) lfirst(args);
/* If this is a T_Integer, then we should convert back to a string /* If this is a T_Integer, then we should convert back to a string
* but for now we just reject the parameter. * but for now we just reject the parameter.