From 08729b4e8aa3a27bf9b43a2dae6b962405f63222 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Thu, 25 Mar 2010 14:44:51 +0000 Subject: Prevent ALTER USER f RESET ALL from removing the settings that were put there by a superuser -- "ALTER USER f RESET setting" already disallows removing such a setting. Apply the same treatment to ALTER DATABASE d RESET ALL when run by a database owner that's not superuser. --- src/backend/commands/dbcommands.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'src/backend/commands/dbcommands.c') diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 1ea84fdbb2d..cbc485f928e 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.225 2009/06/11 14:48:55 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.225.2.1 2010/03/25 14:44:51 alvherre Exp $ * *------------------------------------------------------------------------- */ @@ -1454,9 +1454,30 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt) if (stmt->setstmt->kind == VAR_RESET_ALL) { - /* RESET ALL, so just set datconfig to null */ - repl_null[Anum_pg_database_datconfig - 1] = true; - repl_val[Anum_pg_database_datconfig - 1] = (Datum) 0; + ArrayType *new = NULL; + Datum datum; + bool isnull; + + /* + * in RESET ALL, request GUC to reset the settings array; if none + * left, we can set datconfig to null; otherwise use the returned + * array + */ + datum = heap_getattr(tuple, Anum_pg_database_datconfig, + RelationGetDescr(rel), &isnull); + if (!isnull) + new = GUCArrayReset(DatumGetArrayTypeP(datum)); + if (new) + { + repl_val[Anum_pg_database_datconfig - 1] = PointerGetDatum(new); + repl_repl[Anum_pg_database_datconfig - 1] = true; + repl_null[Anum_pg_database_datconfig - 1] = false; + } + else + { + repl_null[Anum_pg_database_datconfig - 1] = true; + repl_val[Anum_pg_database_datconfig - 1] = (Datum) 0; + } } else { -- cgit v1.2.3