Re: How do I find what views depend on a particular table? - Mailing list pgsql-general

From Tom Lane
Subject Re: How do I find what views depend on a particular table?
Date
Msg-id 15008.1061821877@sss.pgh.pa.us
Whole thread Raw
In response to How do I find what views depend on a particular table?  (Justin Tocci <jtocci@tlcusa.com>)
List pgsql-general
Justin Tocci <jtocci@tlcusa.com> writes:
> I've found the pg_depend table, but it doesn't appear to include this info.
> (Or am I missing it?)

You're missing it.

IIRC, the dependency is actually from the view's ON SELECT rule to the
tables (and other objects) mentioned in the rule.  There is also a
dependency from the ON SELECT rule to the view itself.  This latter
dependency is marked INTERNAL, which (a) prevents you from dropping the
ON SELECT rule by itself, and (b) tells a DROP CASCADE that reaches the
rule to cascade up to the view.  See the discussion at
http://developer.postgresql.org/docs/postgres/catalog-pg-depend.html

> Alternately, I would be happy with a way to get the names of objects that
> are dropped when DROP CASCADE is used.

You can do

BEGIN;
DROP foo CASCADE;
ROLLBACK;

and examine the set of NOTICEs emitted by the DROP.  This is perhaps not
very amenable to mechanization :-(

            regards, tom lane

pgsql-general by date:

Previous
From: Carlos
Date:
Subject: Space occupied by an image in a byte field?
Next
From: "Jenny -"
Date:
Subject: LOCK.tag(figuring out granularity of lock)--