aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/dbcommands.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-08-01 00:15:26 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-08-01 00:15:26 +0000
commitc4cf7fb8146d89293c6667d1fcc295c45da52713 (patch)
tree80526e9728d4a325b79e7d6a76551204605673fa /src/backend/commands/dbcommands.c
parenta063d4b3ec5d74dad4cf65cdd1dd90e88c968d44 (diff)
downloadpostgresql-c4cf7fb8146d89293c6667d1fcc295c45da52713.tar.gz
postgresql-c4cf7fb8146d89293c6667d1fcc295c45da52713.zip
Adjust 'permission denied' messages to be more useful and consistent.
Diffstat (limited to 'src/backend/commands/dbcommands.c')
-rw-r--r--src/backend/commands/dbcommands.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 93701c2a59e..70678b26b08 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.118 2003/07/28 00:09:14 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.119 2003/08/01 00:15:19 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -180,7 +180,7 @@ createdb(const CreatedbStmt *stmt)
if (!superuser() && !have_createdb_privilege())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("permission denied")));
+ errmsg("permission denied to create database")));
}
else
{
@@ -189,7 +189,7 @@ createdb(const CreatedbStmt *stmt)
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("permission denied")));
+ errmsg("must be superuser to create database for another user")));
}
/* don't call this in a transaction block */
@@ -239,7 +239,7 @@ createdb(const CreatedbStmt *stmt)
if (!superuser() && GetUserId() != src_owner)
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("permission to copy \"%s\" denied",
+ errmsg("permission denied to copy database \"%s\"",
dbtemplate)));
}
@@ -481,9 +481,8 @@ dropdb(const char *dbname)
errmsg("database \"%s\" does not exist", dbname)));
if (GetUserId() != db_owner && !superuser())
- ereport(ERROR,
- (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("permission denied")));
+ aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE,
+ dbname);
/*
* Disallow dropping a DB that is marked istemplate. This is just to
@@ -633,13 +632,14 @@ RenameDatabase(const char *oldname, const char *newname)
/* must be owner */
if (!pg_database_ownercheck(HeapTupleGetOid(tup), GetUserId()))
- aclcheck_error(ACLCHECK_NOT_OWNER, oldname);
+ aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE,
+ oldname);
/* must have createdb */
if (!have_createdb_privilege())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("permission denied")));
+ errmsg("permission denied to rename database")));
/* rename */
newtup = heap_copytuple(tup);
@@ -690,9 +690,8 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
if (!(superuser()
|| ((Form_pg_database) GETSTRUCT(tuple))->datdba == GetUserId()))
- ereport(ERROR,
- (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("permission denied")));
+ aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE,
+ stmt->dbname);
MemSet(repl_repl, ' ', sizeof(repl_repl));
repl_repl[Anum_pg_database_datconfig - 1] = 'r';