Обсуждение: where-used function
Hello All:
Hope everyone is enjoying a peaceful holiday season.
I am using this quite time between the holidays to get my dev and production environment back into sync.
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.
A database I worked with years ago, distributed by a marketing company in the NorthWest USA, had such a function.
As I remember that function was buggy.
Does anybody know if a where-used function exists for the wonderful database known as Postgres?
Many Thanks
Kevin Duffy
"Kevin Duffy" <KD@wrinvestments.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