public inbox for [email protected]  
help / color / mirror / Atom feed
schema privileges and drop role
4+ messages / 3 participants
[nested] [flat]

* schema privileges and drop role
@ 2024-06-25 00:00 Matt Zagrabelny <[email protected]>
  2024-06-25 00:03 ` Re: schema privileges and drop role Adrian Klaver <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Matt Zagrabelny @ 2024-06-25 00:00 UTC (permalink / raw)
  To: pgsql-general

Greetings,

I have a database that I recently changed the ownership for and now I am
attempting to drop the previous owner of the database:

test_db=# drop ROLE legacy_owner;
ERROR:  role "legacy_owner" cannot be dropped because some objects depend
on it
DETAIL:  privileges for schema public

I don't know where to look to find out what I need to alter to be able to
remove the legacy role and internet searches came up fruitless.

Does anyone have any hints or advice on where to look?

Thanks for the help!

-m


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: schema privileges and drop role
  2024-06-25 00:00 schema privileges and drop role Matt Zagrabelny <[email protected]>
@ 2024-06-25 00:03 ` Adrian Klaver <[email protected]>
  2024-06-25 00:43   ` Re: schema privileges and drop role Matt Zagrabelny <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Adrian Klaver @ 2024-06-25 00:03 UTC (permalink / raw)
  To: Matt Zagrabelny <[email protected]>; pgsql-general

On 6/24/24 17:00, Matt Zagrabelny wrote:
> Greetings,
> 
> I have a database that I recently changed the ownership for and now I am 
> attempting to drop the previous owner of the database:
> 
> test_db=# drop ROLE legacy_owner;
> ERROR:  role "legacy_owner" cannot be dropped because some objects 
> depend on it
> DETAIL:  privileges for schema public
> 
> I don't know where to look to find out what I need to alter to be able 
> to remove the legacy role and internet searches came up fruitless.

Generally best to start with the docs:

https://www.postgresql.org/docs/current/sql-droprole.html

"A role cannot be removed if it is still referenced in any database of 
the cluster; an error will be raised if so. Before dropping the role, 
you must drop all the objects it owns (or reassign their ownership) and 
revoke any privileges the role has been granted on other objects. The 
REASSIGN OWNED and DROP OWNED commands can be useful for this purpose; 
see Section 22.4 for more discussion."

> 
> Does anyone have any hints or advice on where to look?
> 
> Thanks for the help!
> 
> -m

-- 
Adrian Klaver
[email protected]







^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: schema privileges and drop role
  2024-06-25 00:00 schema privileges and drop role Matt Zagrabelny <[email protected]>
  2024-06-25 00:03 ` Re: schema privileges and drop role Adrian Klaver <[email protected]>
@ 2024-06-25 00:43   ` Matt Zagrabelny <[email protected]>
  2024-06-25 01:08     ` Re: schema privileges and drop role Tom Lane <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Matt Zagrabelny @ 2024-06-25 00:43 UTC (permalink / raw)
  To: Adrian Klaver <[email protected]>; +Cc: pgsql-general

Hi Adrian,

Thanks for the reply!

On Mon, Jun 24, 2024 at 7:03 PM Adrian Klaver <[email protected]>
wrote:

> On 6/24/24 17:00, Matt Zagrabelny wrote:
> > Greetings,
> >
> > I have a database that I recently changed the ownership for and now I am
> > attempting to drop the previous owner of the database:
> >
> > test_db=# drop ROLE legacy_owner;
> > ERROR:  role "legacy_owner" cannot be dropped because some objects
> > depend on it
> > DETAIL:  privileges for schema public
> >
> > I don't know where to look to find out what I need to alter to be able
> > to remove the legacy role and internet searches came up fruitless.
>
> Generally best to start with the docs:
>
> https://www.postgresql.org/docs/current/sql-droprole.html
>
> "A role cannot be removed if it is still referenced in any database of
> the cluster; an error will be raised if so. Before dropping the role,
> you must drop all the objects it owns (or reassign their ownership) and
> revoke any privileges the role has been granted on other objects. The
> REASSIGN OWNED and DROP OWNED commands can be useful for this purpose;
> see Section 22.4 for more discussion."
>

Cool. I gave it a try, but came up with the same error:

test_db=# REASSIGN OWNED by legacy_owner TO new_owner;
REASSIGN OWNED
Time: 0.212 ms
test_db=# drop role legacy_owner;
ERROR:  role "legacy_owner" cannot be dropped because some objects depend
on it
DETAIL:  privileges for schema public
test_db=#

I'd still like to see how to list the "privileges for schema public", but I
do appreciate the REASSIGN OWNED command.

Thanks!

-m


>
> >
> > Does anyone have any hints or advice on where to look?
> >
> > Thanks for the help!
> >
> > -m
>
> --
> Adrian Klaver
> [email protected]
>
>


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: schema privileges and drop role
  2024-06-25 00:00 schema privileges and drop role Matt Zagrabelny <[email protected]>
  2024-06-25 00:03 ` Re: schema privileges and drop role Adrian Klaver <[email protected]>
  2024-06-25 00:43   ` Re: schema privileges and drop role Matt Zagrabelny <[email protected]>
@ 2024-06-25 01:08     ` Tom Lane <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2024-06-25 01:08 UTC (permalink / raw)
  To: Matt Zagrabelny <[email protected]>; +Cc: Adrian Klaver <[email protected]>; pgsql-general

Matt Zagrabelny <[email protected]> writes:
> On Mon, Jun 24, 2024 at 7:03 PM Adrian Klaver <[email protected]>
> wrote:
>> "A role cannot be removed if it is still referenced in any database of
>> the cluster; an error will be raised if so. Before dropping the role,
>> you must drop all the objects it owns (or reassign their ownership) and
>> revoke any privileges the role has been granted on other objects. The
>> REASSIGN OWNED and DROP OWNED commands can be useful for this purpose;
>> see Section 22.4 for more discussion."

> Cool. I gave it a try, but came up with the same error:

> test_db=# REASSIGN OWNED by legacy_owner TO new_owner;
> REASSIGN OWNED
> Time: 0.212 ms
> test_db=# drop role legacy_owner;
> ERROR:  role "legacy_owner" cannot be dropped because some objects depend
> on it

You need to do DROP OWNED as well to get rid of those privileges.
REASSIGN OWNED only changes the ownership of ownable objects.

> I'd still like to see how to list the "privileges for schema
> public",

"\dn+ public" in psql would do that.

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2024-06-25 01:08 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-06-25 00:00 schema privileges and drop role Matt Zagrabelny <[email protected]>
2024-06-25 00:03 ` Adrian Klaver <[email protected]>
2024-06-25 00:43   ` Matt Zagrabelny <[email protected]>
2024-06-25 01:08     ` Tom Lane <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox