From: AC Gomez <antklc(at)gmail(dot)com>
To: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject:
Date: 2021-11-22 22:21:12
Message-ID: CABtmK-hdmKiuXZ+hYFBF_YC=KfZZB2tAp8ammt1tDnfXRrD-5g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Postgres 9.6. We're attempting to delete some old users from a DB.

Log into DB as masteruser.

Run this block of commands (the_schema=public, and it's the only schema in
this particular DB):

REVOKE ALL PRIVILEGES ON DATABASE the_database FROM old_role;
REVOKE USAGE ON SCHEMA the_schema FROM old_role;
REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA the_schema FROM old_role;
REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA the_schema FROM old_role;

Here we actually had to create a loop to revoke one function at a time
while avoiding system functions on which this single command fails:
REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA the_schema FROM old_role;

REVOKE ALL PRIVILEGES ON SCHEMA the_schema FROM old_role;
ALTER DEFAULT PRIVILEGES IN SCHEMA the_schema REVOKE ALL ON SEQUENCES FROM
old_role;
ALTER DEFAULT PRIVILEGES IN SCHEMA the_schema REVOKE ALL ON TABLES FROM
old_role;
ALTER DEFAULT PRIVILEGES IN SCHEMA the_schema REVOKE ALL ON FUNCTIONS FROM
old_role;

REASSIGN OWNED BY old_role TO masteruser;
DROP OWNED BY old_role;
DROP USER old_role;

The consensus online is that these are the steps to be taken to
successfully remove roles, yet we get this error below:

ERROR: role "old_role" cannot be dropped because some objects depend on it
DETAIL: privileges for database the_database 96 objects in database
the_database SQL state: 2BP01

What is it that we could be missing here?

Thanks for any help!

Responses

  • Re: at 2021-11-22 22:35:13 from Tom Lane

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2021-11-22 22:35:13 Re:
Previous Message Tom Lane 2021-11-22 16:47:44 Re: insert column monetary type ver 2