Re: How to drop user if objects depend on it

From: "Andrus" <kobruleht2(at)hot(dot)ee>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Thom Brown" <thom(at)linux(dot)com>, "Adrian Klaver" <adrian(dot)klaver(at)aklaver(dot)com>, "pgsql-general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to drop user if objects depend on it
Date: 2015-10-07 18:11:55
Message-ID: F49269F121004488BF81FC50D75174E9@dell2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>A little further review shows that DROP OWNED is the way to get rid of
>leftover privileges. So in general you need to do REASSIGN OWNED to move
>the ownership of objects, then DROP OWNED to get rid of privileges granted
>on non-owned objects, before you can drop a role.

I tried this in database mydb using script below but still got error

ERROR: role "vantaa" cannot be dropped because some objects depend on it
DETAIL: privileges for database mydb

How to drop role?

Andrus.

set local role admin; -- admin is not superuser but is member of
mydb_owner
CREATE ROLE vantaa;
grant mydb_owner to vantaa;

revoke all on all tables in schema public,firma1 from vantaa cascade;
revoke all on all sequences in schema public,firma1 from vantaa cascade;
revoke all on database mydb from vantaa cascade;
revoke all on all functions in schema public,firma1 from vantaa cascade;
revoke all on schema public,firma1 from vantaa cascade;
revoke mydb_owner from vantaa cascade;
ALTER ROLE vantaa inherit NOCREATEROLE NOCREATEDB NOLOGIN;

grant all on all tables in schema public,firma1 to vantaa;
grant all on all sequences in schema public,firma1 to vantaa;
grant all on database mydb to vantaa;
grant all on schema public,firma1 to vantaa;
ALTER DEFAULT PRIVILEGES IN SCHEMA public,firma1 GRANT all ON TABLES TO
vantaa;
revoke all on kasutaja,kaspriv,logifail from vantaa cascade;
grant select on kaspriv,kasutaja to vantaa;
grant update (eesnimi, nimi,email,amet,islocked,telefon,language,vabakuup)
on kasutaja to vantaa;
grant insert on logifail to vantaa;

GRANT vantaa TO admin;
reassign owned by vantaa to mydb_owner;
drop owned by vantaa;
drop user vantaa;

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Sargent 2015-10-07 18:12:48 Re: using postgresql for session
Previous Message Jim Nasby 2015-10-07 18:01:41 Re: md5(large_object_id)