Unix Technical Forum

ALTER DATABASE ... RENAME: permission denied for superuser

This is a discussion on ALTER DATABASE ... RENAME: permission denied for superuser within the pgsql Bugs forums, part of the PostgreSQL category; --> Docs say: Only the database owner or a superuser can rename a database; non-superuser owners must also have the ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Bugs

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 09:38 AM
Alexander M. Pravking
 
Posts: n/a
Default ALTER DATABASE ... RENAME: permission denied for superuser

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@~=# SELECT usesuper, usecreatedb from pg_user where usename = 'fduch';
usesuper | usecreatedb
----------+-------------
t | f
(1 row)

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

At last:
fduch@~=# ALTER USER fduch CREATEDB ;
ALTER USER
fduch@~=# ALTER DATABASE test RENAME TO work;
ALTER DATABASE
fduch@~=# ALTER DATABASE work OWNER TO stat;
ALTER DATABASE
fduch@~=# 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

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 09:38 AM
Tom Lane
 
Posts: n/a
Default Re: ALTER DATABASE ... RENAME: permission denied for superuser

"Alexander M. Pravking" <fduch@antar.bryansk.ru> writes:
> 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:


Yeah, the test in RenameDatabase is only looking at createdb and not at
superuserness. Seems like a bug to me --- or does anyone want to argue
that the code behavior is correct and the docs are wrong?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 09:38 AM
Bruce Momjian
 
Posts: n/a
Default Re: ALTER DATABASE ... RENAME: permission denied for superuser


Tom has fixed this bug and backpatched it back to 7.4.X.

---------------------------------------------------------------------------

Alexander M. Pravking wrote:
> 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@~=# SELECT usesuper, usecreatedb from pg_user where usename = 'fduch';
> usesuper | usecreatedb
> ----------+-------------
> t | f
> (1 row)
>
> fduch@~=# CREATE DATABASE test owner stat;
> CREATE DATABASE
> fduch@~=# ALTER DATABASE test RENAME TO work;
> ERROR: permission denied to rename database
> fduch@~=# ALTER DATABASE test OWNER TO fduch ;
> ALTER DATABASE
> fduch@~=# ALTER DATABASE test RENAME TO work;
> ERROR: permission denied to rename database
>
> At last:
> fduch@~=# ALTER USER fduch CREATEDB ;
> ALTER USER
> fduch@~=# ALTER DATABASE test RENAME TO work;
> ALTER DATABASE
> fduch@~=# ALTER DATABASE work OWNER TO stat;
> ALTER DATABASE
> fduch@~=# 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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>


--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:37 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com