diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-09-03 18:46:30 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-09-03 18:46:30 +0000 |
commit | e7889b83b7059e776f0a3d76bbbdd98687f4592c (patch) | |
tree | e0b51d43d089c38a1debbe9d9d15499e68a548dd /src/backend/commands/dbcommands.c | |
parent | dd4594e332a86b563801b6bbed0a7d256dcd7e43 (diff) | |
download | postgresql-e7889b83b7059e776f0a3d76bbbdd98687f4592c.tar.gz postgresql-e7889b83b7059e776f0a3d76bbbdd98687f4592c.zip |
Support SET FROM CURRENT in CREATE/ALTER FUNCTION, ALTER DATABASE, ALTER ROLE.
(Actually, it works as a plain statement too, but I didn't document that
because it seems a bit useless.) Unify VariableResetStmt with
VariableSetStmt, and clean up some ancient cruft in the representation of
same.
Diffstat (limited to 'src/backend/commands/dbcommands.c')
-rw-r--r-- | src/backend/commands/dbcommands.c | 20 |
1 files changed, 11 insertions, 9 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 */ |