summaryrefslogtreecommitdiff
path: root/src/backend/commands/dbcommands.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2010-03-25 14:46:06 +0000
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2010-03-25 14:46:06 +0000
commitb60e3ddc2e911e57af6ac5b0f2cfa7dd58bf5006 (patch)
treeaa2a1a919e3fb7e243c9551d405f3cece1bffd0e /src/backend/commands/dbcommands.c
parent26ef5e9b2a6e3b91f0e42689d150c53491fcd4fc (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 1e870b975e5..d766f333b89 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.124.2.2 2005/03/12 21:12:18 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.124.2.3 2010/03/25 14:46:04 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -721,9 +721,30 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
if (strcmp(stmt->variable, "all") == 0 && valuestr == NULL)
{
- /* RESET ALL */
- 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
{