aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/dbcommands.c20
-rw-r--r--src/backend/commands/functioncmds.c33
-rw-r--r--src/backend/commands/user.c22
3 files changed, 32 insertions, 43 deletions
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 34b6da99df9..f6274803622 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.197 2007/08/01 22:45:08 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.198 2007/09/03 18:46:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -886,7 +886,7 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
char repl_null[Natts_pg_database];
char repl_repl[Natts_pg_database];
- valuestr = flatten_set_variable_args(stmt->variable, stmt->value);
+ valuestr = ExtractSetVariableArgs(stmt->setstmt);
/*
* Get the old tuple. We don't need a lock on the database per se,
@@ -910,12 +910,12 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE,
stmt->dbname);
- MemSet(repl_repl, ' ', sizeof(repl_repl));
+ memset(repl_repl, ' ', sizeof(repl_repl));
repl_repl[Anum_pg_database_datconfig - 1] = 'r';
- if (strcmp(stmt->variable, "all") == 0 && valuestr == NULL)
+ if (stmt->setstmt->kind == VAR_RESET_ALL)
{
- /* RESET ALL */
+ /* RESET ALL, so just set datconfig to null */
repl_null[Anum_pg_database_datconfig - 1] = 'n';
repl_val[Anum_pg_database_datconfig - 1] = (Datum) 0;
}
@@ -927,15 +927,16 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
repl_null[Anum_pg_database_datconfig - 1] = ' ';
+ /* Extract old value of datconfig */
datum = heap_getattr(tuple, Anum_pg_database_datconfig,
RelationGetDescr(rel), &isnull);
-
a = isnull ? NULL : DatumGetArrayTypeP(datum);
+ /* Update (valuestr is NULL in RESET cases) */
if (valuestr)
- a = GUCArrayAdd(a, stmt->variable, valuestr);
+ a = GUCArrayAdd(a, stmt->setstmt->name, valuestr);
else
- a = GUCArrayDelete(a, stmt->variable);
+ a = GUCArrayDelete(a, stmt->setstmt->name);
if (a)
repl_val[Anum_pg_database_datconfig - 1] = PointerGetDatum(a);
@@ -943,7 +944,8 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
repl_null[Anum_pg_database_datconfig - 1] = 'n';
}
- newtuple = heap_modifytuple(tuple, RelationGetDescr(rel), repl_val, repl_null, repl_repl);
+ newtuple = heap_modifytuple(tuple, RelationGetDescr(rel),
+ repl_val, repl_null, repl_repl);
simple_heap_update(rel, &tuple->t_self, newtuple);
/* Update indexes */
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index a6768ab83c2..9e5d0b1095b 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.84 2007/09/03 00:39:15 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.85 2007/09/03 18:46:29 tgl Exp $
*
* DESCRIPTION
* These routines take the parse tree and pick out the
@@ -354,7 +354,7 @@ interpret_func_volatility(DefElem *defel)
}
/*
- * Update a proconfig value according to a list of SET and RESET items.
+ * Update a proconfig value according to a list of VariableSetStmt items.
*
* The input and result may be NULL to signify a null entry.
*/
@@ -365,33 +365,20 @@ update_proconfig_value(ArrayType *a, List *set_items)
foreach(l, set_items)
{
- Node *sitem = (Node *) lfirst(l);
+ VariableSetStmt *sstmt = (VariableSetStmt *) lfirst(l);
- if (IsA(sitem, VariableSetStmt))
+ Assert(IsA(sstmt, VariableSetStmt));
+ if (sstmt->kind == VAR_RESET_ALL)
+ a = NULL;
+ else
{
- VariableSetStmt *sstmt = (VariableSetStmt *) sitem;
-
- if (sstmt->args)
- {
- char *valuestr;
+ char *valuestr = ExtractSetVariableArgs(sstmt);
- valuestr = flatten_set_variable_args(sstmt->name, sstmt->args);
+ if (valuestr)
a = GUCArrayAdd(a, sstmt->name, valuestr);
- }
- else /* SET TO DEFAULT */
+ else /* RESET */
a = GUCArrayDelete(a, sstmt->name);
}
- else if (IsA(sitem, VariableResetStmt))
- {
- VariableResetStmt *rstmt = (VariableResetStmt *) sitem;
-
- if (strcmp(rstmt->name, "all") == 0)
- a = NULL; /* RESET ALL */
- else
- a = GUCArrayDelete(a, rstmt->name);
- }
- else
- elog(ERROR, "unexpected node type: %d", nodeTag(sitem));
}
return a;
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index cbbc31ca6f0..ccf34178a07 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.176 2007/02/01 19:10:26 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.177 2007/09/03 18:46:30 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -721,9 +721,8 @@ AlterRoleSet(AlterRoleSetStmt *stmt)
Datum repl_val[Natts_pg_authid];
char repl_null[Natts_pg_authid];
char repl_repl[Natts_pg_authid];
- int i;
- valuestr = flatten_set_variable_args(stmt->variable, stmt->value);
+ valuestr = ExtractSetVariableArgs(stmt->setstmt);
rel = heap_open(AuthIdRelationId, RowExclusiveLock);
oldtuple = SearchSysCache(AUTHNAME,
@@ -754,14 +753,14 @@ AlterRoleSet(AlterRoleSetStmt *stmt)
errmsg("permission denied")));
}
- for (i = 0; i < Natts_pg_authid; i++)
- repl_repl[i] = ' ';
-
+ memset(repl_repl, ' ', sizeof(repl_repl));
repl_repl[Anum_pg_authid_rolconfig - 1] = 'r';
- if (strcmp(stmt->variable, "all") == 0 && valuestr == NULL)
+
+ if (stmt->setstmt->kind == VAR_RESET_ALL)
{
- /* RESET ALL */
+ /* RESET ALL, so just set rolconfig to null */
repl_null[Anum_pg_authid_rolconfig - 1] = 'n';
+ repl_val[Anum_pg_authid_rolconfig - 1] = (Datum) 0;
}
else
{
@@ -771,15 +770,16 @@ AlterRoleSet(AlterRoleSetStmt *stmt)
repl_null[Anum_pg_authid_rolconfig - 1] = ' ';
+ /* Extract old value of rolconfig */
datum = SysCacheGetAttr(AUTHNAME, oldtuple,
Anum_pg_authid_rolconfig, &isnull);
-
array = isnull ? NULL : DatumGetArrayTypeP(datum);
+ /* Update (valuestr is NULL in RESET cases) */
if (valuestr)
- array = GUCArrayAdd(array, stmt->variable, valuestr);
+ array = GUCArrayAdd(array, stmt->setstmt->name, valuestr);
else
- array = GUCArrayDelete(array, stmt->variable);
+ array = GUCArrayDelete(array, stmt->setstmt->name);
if (array)
repl_val[Anum_pg_authid_rolconfig - 1] = PointerGetDatum(array);