From 58ca6e091ee015571263ba84de79c2e5ee3f324d Mon Sep 17 00:00:00 2001 From: "Thomas G. Lockhart" Date: Mon, 22 Apr 2002 14:34:27 +0000 Subject: [PATCH] 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. --- src/backend/commands/variable.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c index 504f9c56b6..0498c734ec 100644 --- a/src/backend/commands/variable.c +++ b/src/backend/commands/variable.c @@ -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.