"Joel Burton" <joel@joelburton.com> writes:
> During some debugging of a database tonight, I wrote this function that
> calls a view, examines its source, and recursively tracks down all the
> source tables.
A few comments:
> if rec.relkind = ''r'' then return '''';
Probably be better to punt whenever relkind <> 'v', instead.
> def := ev_action from pg_rewrite where ev_Class=rec.oid;
Will tend to fail if view has rules other than select (insert, delete,
update). You'd better restrict the ev_type field too.
Also, I'd suggest making the internal recursion pass table oid not name;
will be a lot easier to adapt to 7.3, wherein relname is not unique.
(Although there may be better ways to do the whole thing in 7.3,
anyway --- need to review Rod Taylor's pg_depend patch again, but
probably some form of that will get in there.)
regards, tom lane