Skip site navigation (1) Skip section navigation (2)

ALTER DATABASE ... RENAME: permission denied for superuser

From: "Alexander M(dot) Pravking" <fduch(at)antar(dot)bryansk(dot)ru>
To: pgsql-bugs(at)postgresql(dot)org
Subject: ALTER DATABASE ... RENAME: permission denied for superuser
Date: 2005-03-10 10:43:07
Message-ID: 20050310104307.GA24145@dyatel.antar.bryansk.ru (view raw or flat)
Thread:
Lists: pgsql-bugs
Docs say: Only the database owner or a superuser can rename a database;
non-superuser owners must also have the CREATEDB privilege.

Looks like a superuser must have CREATEDB too:

fduch(at)~=# SELECT usesuper, usecreatedb from pg_user where usename = 'fduch';
 usesuper | usecreatedb
----------+-------------
 t        | f
(1 row)

fduch(at)~=# CREATE DATABASE test owner stat;
CREATE DATABASE
fduch(at)~=# ALTER DATABASE test RENAME TO work;
ERROR:  permission denied to rename database
fduch(at)~=# ALTER DATABASE test OWNER TO fduch ;
ALTER DATABASE
fduch(at)~=# ALTER DATABASE test RENAME TO work;
ERROR:  permission denied to rename database

At last:
fduch(at)~=# ALTER USER fduch CREATEDB ;
ALTER USER
fduch(at)~=# ALTER DATABASE test RENAME TO work;
ALTER DATABASE
fduch(at)~=# ALTER DATABASE work OWNER TO stat;
ALTER DATABASE
fduch(at)~=# ALTER DATABASE work RENAME TO test;
ALTER DATABASE

PostgreSQL 8.0.1 on i386-portbld-freebsd5.3, compiled by GCC cc (GCC) 3.4.2 [FreeBSD] 20040728


-- 
Fduch M. Pravking

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2005-03-10 15:15:08
Subject: Re: ALTER DATABASE ... RENAME: permission denied for superuser
Previous:From: Henk van den ToornDate: 2005-03-10 09:38:32
Subject: BUG #1533: "*OLD*" relation not recognized in CREATE RULE

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group