Skip site navigation (1) Skip section navigation (2)

Re: where-used function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Kevin Duffy" <KD(at)wrinvestments(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: where-used function
Date: 2008-12-29 18:44:24
Message-ID: 10676.1230576264@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-sql
"Kevin Duffy" <KD(at)wrinvestments(dot)com> writes:
> It would be very helpful, if I had a where-used function.  This
> function, given an object name, would determine
> if the object exists in the database ( i.e. is it a table or a view)
> and then, most important, what other objects are dependant on the
> object.

The traditional manual way to do the latter is

	begin;
	drop <object>;
	... read the error message about what the drop would cascade to ...
	rollback;

If you feel like getting down-and-dirty with the implementation you
could troll the contents of pg_depend for yourself.  I think it would
be kind of painful to do without writing some C code though, because
a lot of useful operations like getObjectDescription() aren't exposed
at the SQL level.

			regards, tom lane

In response to

pgsql-sql by date

Next:From: George PavlovDate: 2008-12-29 20:30:48
Subject: Re: Object create date
Previous:From: Alvaro HerreraDate: 2008-12-29 18:38:10
Subject: Re: Object create date

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group