summaryrefslogtreecommitdiff
path: root/src/backend/commands/user.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2005-12-23 16:46:39 +0000
committerPeter Eisentraut <peter_e@gmx.net>2005-12-23 16:46:39 +0000
commit98b3c3c450b9c3133f28375dc15c9c9b9bedd820 (patch)
treea9f5a785300731439ebae12fbca1e7ed7d222b32 /src/backend/commands/user.c
parentdcc7da8d5e0854b4a17d3929c722b1afacafcef2 (diff)
Allow CREATE/ALTER ROLE PASSWORD NULL to allow restoring the default state
of having no password.
Diffstat (limited to 'src/backend/commands/user.c')
-rw-r--r--src/backend/commands/user.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 381ebe24adf..0ffcc215017 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.166 2005/11/22 18:17:09 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.167 2005/12/23 16:46:39 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -225,7 +225,7 @@ CreateRole(CreateRoleStmt *stmt)
defel->defname);
}
- if (dpassword)
+ if (dpassword && dpassword->arg)
password = strVal(dpassword->arg);
if (dissuper)
issuper = intVal(dissuper->arg) != 0;
@@ -517,7 +517,7 @@ AlterRole(AlterRoleStmt *stmt)
defel->defname);
}
- if (dpassword)
+ if (dpassword && dpassword->arg)
password = strVal(dpassword->arg);
if (dissuper)
issuper = intVal(dissuper->arg);
@@ -573,7 +573,7 @@ AlterRole(AlterRoleStmt *stmt)
!dconnlimit &&
!rolemembers &&
!validUntil &&
- password &&
+ dpassword &&
roleid == GetUserId()))
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
@@ -651,6 +651,13 @@ AlterRole(AlterRoleStmt *stmt)
new_record_repl[Anum_pg_authid_rolpassword - 1] = 'r';
}
+ /* unset password */
+ if (dpassword && dpassword->arg == NULL)
+ {
+ new_record_repl[Anum_pg_authid_rolpassword - 1] = 'r';
+ new_record_nulls[Anum_pg_authid_rolpassword - 1] = 'n';
+ }
+
/* valid until */
if (validUntil)
{