Обсуждение: Drop Functions Question Again

Поиск
Список
Период
Сортировка

Drop Functions Question Again

От
"Garcia, Joshua"
Дата:

I know this has been asked by other people in the past, but the archives don’t show that anyone actually answered the question.  Is there any way to drop all the custom-created functions I add to the database in one command? 

 

Thanks again,

Josh

Re: Drop Functions Question Again

От
Tom Lane
Дата:
"Garcia, Joshua" <Joshua.Garcia@xerox.com> writes:
> I know this has been asked by other people in the past, but the archives
> don't show that anyone actually answered the question.  Is there any way
> to drop all the custom-created functions I add to the database in one
> command?

Not per se.  If you search the PG archives, you can find examples of
plpgsql functions that people have written to trawl through the system
catalogs and build DROP commands for all objects meeting some criteria
or other.

Also, as of PG 8.1 you can get a textual list of all objects owned by a
given user by trying to drop the user:

regression=# drop user foo;
ERROR:  role "foo" cannot be dropped because some objects depend on it
DETAIL:  owner of function fooey2(integer,integer)
owner of function fooey(integer,integer)
regression=#

(Don't try this in pre-8.1, you'll end up with a lot of orphaned
objects :-()

For a one-shot problem, the easiest thing might be to capture that in
a text file and then edit it down to the command script you need.  If
you expect to do it often then it'd be worth the trouble to write a
function.

            regards, tom lane