aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/variable.c
diff options
context:
space:
mode:
authorThomas G. Lockhart <lockhart@fourpalms.org>2002-04-22 15:13:53 +0000
committerThomas G. Lockhart <lockhart@fourpalms.org>2002-04-22 15:13:53 +0000
commit3c184d18ef42f972c6e89c0f9d5ba286e98f5430 (patch)
tree966aba2d1354bdb82d0fb9b08d566fa8ce37f235 /src/backend/commands/variable.c
parent58ca6e091ee015571263ba84de79c2e5ee3f324d (diff)
downloadpostgresql-3c184d18ef42f972c6e89c0f9d5ba286e98f5430.tar.gz
postgresql-3c184d18ef42f972c6e89c0f9d5ba286e98f5430.zip
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.
Diffstat (limited to 'src/backend/commands/variable.c')
-rw-r--r--src/backend/commands/variable.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index 0498c734ec1..301a3c86a74 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.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)
Value *s;
Assert(IsA(type->names, List));
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;
@@ -594,7 +595,7 @@ parse_XactIsoLevel(List *args)
Assert(IsA(lfirst(args), A_Const));
/* Should only get one argument from the parser */
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);
value = ((A_Const *) lfirst(args))->val.val.str;
@@ -657,7 +658,7 @@ parse_random_seed(List *args)
Assert(IsA(args, List));
/* Should only get one argument from the parser */
if (lnext(args) != NIL)
- elog(ERROR, "SET SEED does not allow multiple arguments");
+ elog(ERROR, "SET SEED takes only one argument");
p = lfirst(args);
Assert(IsA(p, A_Const));
@@ -720,7 +721,7 @@ parse_client_encoding(List *args)
return reset_client_encoding();
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));
if (((A_Const *) lfirst(args))->val.type != T_String)
@@ -852,15 +853,23 @@ SetPGVariable(const char *name, List *args)
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.
- */
- 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;
+ if ((n->val.type == T_String)
+ || (n->val.type == T_Float))
+ {
+ 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
{