Re: [GENERAL] dropping role w/dependent objects

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Ed L(dot)" <pgsql(at)bluepolka(dot)net>, Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-patches(at)postgreSQL(dot)org
Subject: Re: [GENERAL] dropping role w/dependent objects
Date: 2007-05-14 16:55:56
Message-ID: 20070514165556.GH4429@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Tom Lane wrote:
> Alvaro Herrera <alvherre(at)commandprompt(dot)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

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Gregory Stark 2007-05-14 17:26:42 Re: Concurrent psql patch
Previous Message Jim C. Nasby 2007-05-14 16:55:07 Re: Concurrent psql patch