Re: How was I able to drop a role even though objects depend on it?

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: David Johnston <polobo(at)yahoo(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: How was I able to drop a role even though objects depend on it?
Date: 2013-07-01 17:38:04
Message-ID: 20130701173803.GI3757@eldon.alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

David Johnston wrote:
> Wojciechowski, Robert (GE Transportation) wrote
> > [...] there is a database that shows this connect grant to a user that was
> > known as foo1_userA (oid 3562339547): 3562339547=c/postgres
>
> The main user dependent situation is having said user OWNER on a database
> object. Simply giving a user connect privileges on a database does not make
> the database dependent upon said user and so removing said user remains
> possible.

Dropping a user which is either a database owner or has been granted
CONNECT privileges is supposed to be disallowed:

alvherre=# create user f;
CREATE ROLE
alvherre=# create database f owner f;
CREATE DATABASE
alvherre=# drop role f;
ERROR: role "f" cannot be dropped because some objects depend on it
DETALLE: owner of database f
alvherre=# create role g;
CREATE ROLE
alvherre=# grant connect on database f to g;
GRANT
alvherre=# drop role g;
ERROR: role "g" cannot be dropped because some objects depend on it
DETALLE: privileges for database f

We're supposed to have sufficient locking so that concurrent
transactions don't see problems either (one xact drops the user while
the other creates the database), but maybe there are bugs somewhere.

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message David Johnston 2013-07-01 19:38:45 Re: How was I able to drop a role even though objects depend on it?
Previous Message Magnus Hagander 2013-07-01 17:08:44 Re: one client with multiple ssl cert connections to different databases