|
15 | 15 | *
|
16 | 16 | *
|
17 | 17 | * IDENTIFICATION
|
18 |
| - * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.162 2005/06/28 05:08:53 tgl Exp $ |
| 18 | + * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.163 2005/06/29 20:34:13 tgl Exp $ |
19 | 19 | *
|
20 | 20 | *-------------------------------------------------------------------------
|
21 | 21 | */
|
@@ -194,8 +194,8 @@ createdb(const CreatedbStmt *stmt)
|
194 | 194 |
|
195 | 195 | if (is_member_of_role(GetUserId(), datdba))
|
196 | 196 | {
|
197 |
| - /* creating database for self: can be superuser or createdb */ |
198 |
| - if (!superuser() && !have_createdb_privilege()) |
| 197 | + /* creating database for self: createdb is required */ |
| 198 | + if (!have_createdb_privilege()) |
199 | 199 | ereport(ERROR,
|
200 | 200 | (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
201 | 201 | errmsg("permission denied to create database")));
|
@@ -759,7 +759,7 @@ RenameDatabase(const char *oldname, const char *newname)
|
759 | 759 | oldname);
|
760 | 760 |
|
761 | 761 | /* must have createdb rights */
|
762 |
| - if (!superuser() && !have_createdb_privilege()) |
| 762 | + if (!have_createdb_privilege()) |
763 | 763 | ereport(ERROR,
|
764 | 764 | (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
765 | 765 | errmsg("permission denied to rename database")));
|
@@ -1044,6 +1044,10 @@ have_createdb_privilege(void)
|
1044 | 1044 | bool result = false;
|
1045 | 1045 | HeapTuple utup;
|
1046 | 1046 |
|
| 1047 | + /* Superusers can always do everything */ |
| 1048 | + if (superuser()) |
| 1049 | + return true; |
| 1050 | + |
1047 | 1051 | utup = SearchSysCache(AUTHOID,
|
1048 | 1052 | ObjectIdGetDatum(GetUserId()),
|
1049 | 1053 | 0, 0, 0);
|
|
0 commit comments