Skip to content
Snippets Groups Projects
Commit 3c184d18 authored by Thomas G. Lockhart's avatar Thomas G. Lockhart
Browse files

Convert GUC parameters back to strings if input as integers.

Change elog(ERROR) messages to say that a variable takes one parameter,
 rather than saying that it does not take multiple parameters.
parent 58ca6e09
Branches
Tags
No related merge requests found
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.64 2002/04/22 14:34:27 thomas Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.65 2002/04/22 15:13:53 thomas Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -287,7 +287,8 @@ parse_datestyle(List *args) ...@@ -287,7 +287,8 @@ parse_datestyle(List *args)
Value *s; Value *s;
Assert(IsA(type->names, List)); Assert(IsA(type->names, List));
s = (Value *) lfirst(type->names); s = (Value *) lfirst(type->names);
elog(ERROR, "SET DATESTYLE does not allow input of type %s", s->val.str); elog(ERROR, "SET DATESTYLE does not allow input of type %s"
"\n\tUse an untyped string instead", s->val.str);
} }
value = v->val.str; value = v->val.str;
...@@ -594,7 +595,7 @@ parse_XactIsoLevel(List *args) ...@@ -594,7 +595,7 @@ parse_XactIsoLevel(List *args)
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 */
if (lnext(args) != NIL) if (lnext(args) != NIL)
elog(ERROR, "SET TRANSACTION ISOLATION LEVEL does not allow multiple arguments"); elog(ERROR, "SET TRANSACTION ISOLATION LEVEL takes only one argument");
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;
...@@ -657,7 +658,7 @@ parse_random_seed(List *args) ...@@ -657,7 +658,7 @@ 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 */
if (lnext(args) != NIL) if (lnext(args) != NIL)
elog(ERROR, "SET SEED does not allow multiple arguments"); elog(ERROR, "SET SEED takes only one argument");
p = lfirst(args); p = lfirst(args);
Assert(IsA(p, A_Const)); Assert(IsA(p, A_Const));
...@@ -720,7 +721,7 @@ parse_client_encoding(List *args) ...@@ -720,7 +721,7 @@ parse_client_encoding(List *args)
return reset_client_encoding(); return reset_client_encoding();
if (lnext(args) != NIL) if (lnext(args) != NIL)
elog(ERROR, "SET CLIENT ENCODING does not allow multiple arguments"); elog(ERROR, "SET CLIENT ENCODING takes only one argument");
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)
...@@ -852,16 +853,24 @@ SetPGVariable(const char *name, List *args) ...@@ -852,16 +853,24 @@ SetPGVariable(const char *name, List *args)
elog(ERROR, "SET %s takes only one argument", name); 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 ((n->val.type == T_String)
* but for now we just reject the parameter. || (n->val.type == T_Float))
*/ {
if ((n->val.type != T_String)
&& (n->val.type != T_Float))
elog(ERROR, "SET requires a string argument for this parameter"
"\n\tInternal coding error: report to thomas@fourpalms.org");
value = n->val.val.str; value = n->val.val.str;
} }
else if (n->val.type == T_Integer)
{
/* We should convert back to a string. */
value = DatumGetCString(DirectFunctionCall1(int4out, Int32GetDatum(n->val.val.ival)));
}
else
{
elog(ERROR, "SET %s accepts a string argument for this parameter"
"\n\tInternal coding error: report to thomas@fourpalms.org",
name);
value = NULL;
}
}
else else
{ {
value = NULL; value = NULL;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment