Why role cannot be dropped because some objects depend on it

南楼画角 提交于 2020-05-17 06:48:06

问题


Database "mydb" is owned by role "mydb_owner".

User "currentuser" tries to delete role "roletodelete" from this database using

revoke all on all tables in schema public,firma1 from "roletodelete" cascade;
revoke all on all sequences in schema public,firma1 from "roletodelete" cascade;
revoke all on database mydb from "roletodelete" cascade;
revoke all on all functions in schema public,firma1 from "roletodelete" cascade;
revoke all on schema public,firma1 from "roletodelete" cascade;
revoke mydb_owner from "roletodelete" cascade;
ALTER DEFAULT PRIVILEGES IN SCHEMA public,firma1 revoke all ON TABLES from "roletodelete";
GRANT "roletodelete" TO "currentuser";
reassign owned by "roletodelete" to mydb_owner;
drop owned by "roletodelete";
drop role "roletodelete";

I ran it as superuser and got

    ERROR: role "roletodelete" cannot be dropped because some objects depend on it
DETAIL:  privileges for default privileges on new relations belonging to role currentuser in schema public
privileges for default privileges on new relations belonging to role currentuser schema firma1

How to create script which is guaranteed to delete role ?

This script already contains:

revoke all on schema public,firma1 from "roletodelete" cascade;

Why postgres complains that privileges for schema public depend on this role if they are revoked ? How to fix this?

There are lot of questions and answers about this like:

Cannot drop PostgreSQL role. Error: `cannot be dropped because some objects depend on it`

PostgreSQL - how to quickly drop a user with existing privileges

https://dba.stackexchange.com/questions/155332/find-objects-linked-to-a-postgresql-role

I put recommendations from them to deletion script above but problem persists.

来源:https://stackoverflow.com/questions/61168608/why-role-cannot-be-dropped-because-some-objects-depend-on-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!