Re: [GENERAL] dropping role w/dependent objects - Mailing list pgsql-patches

From Alvaro Herrera
Subject Re: [GENERAL] dropping role w/dependent objects
Date
Msg-id 20070514165556.GH4429@alvh.no-ip.org
Whole thread Raw
In response to Re: [GENERAL] dropping role w/dependent objects  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
Tom Lane wrote:
> Alvaro Herrera <alvherre@commandprompt.com> writes:
> > Sample output to the client (note: in this test, MAX_REPORTED_DEPS is
> > set to 10).
> > ...
> > foo=# drop user foo;
> > ERROR:  role "foo" cannot be dropped because some objects depend on it
> > DETAIL:  owner of tablespace foo
> > owner of table a100
> > owner of table a99
> > owner of table a98
> > owner of table a97
> > owner of table a96
> > owner of table a95
> > owner of table a94
> > owner of table a93
> > owner of table a92
> > 5 objects in database bar
> > and other 95 objects reported to the server log
>
> "and 95 other objects", please.
>
> > Whereas the postmaster log gets
>
> Nothing about the objects in database bar?

Applied with these corrections.  I also made it produce a summary of
databases when there are too many, so you can get output like

        owner of tablespace foo
        owner of table qux
        owner of table baz
        owner of table bar
        owner of table foo
        one object in database a60
        and objects in other 3 databases

which avoids a message flood when the user owns objects in too many
databases.

The corresponding server log is

        owner of table foo
        one object in database a60
        one object in database a59
        one object in database alvherre
        5 objects in database bar

I kept the number of reported lines at 100.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

pgsql-patches by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: Concurrent psql patch
Next
From: Gregory Stark
Date:
Subject: Re: Concurrent psql patch