summaryrefslogtreecommitdiff
path: root/src/backend/commands/dbcommands.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2010-03-25 14:45:06 +0000
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2010-03-25 14:45:06 +0000
commite429448f33843f4b9bffe1243efb1158343e267b (patch)
treebb7b7fff9f9f5e38c05e40bf6c600b8d4e1ff7d5 /src/backend/commands/dbcommands.c
parente1eb7c81192bec3735eed3228202b400f31c8010 (diff)
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.
Diffstat (limited to 'src/backend/commands/dbcommands.c')
-rw-r--r--src/backend/commands/dbcommands.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index df86095b1a1..f7bf94883af 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.204.2.4 2008/10/09 10:34:22 heikki Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.204.2.5 2010/03/25 14:45:06 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -982,9 +982,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] = 'n';
- 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] = 'r';
+ repl_null[Anum_pg_database_datconfig - 1] = ' ';
+ }
+ else
+ {
+ repl_null[Anum_pg_database_datconfig - 1] = 'n';
+ repl_val[Anum_pg_database_datconfig - 1] = (Datum) 0;
+ }
}
else
{