Michael Fuhr <mike@fuhr.org> writes:
> On Thu, Jan 06, 2005 at 12:10:26PM -0500, Eric E wrote:
>> I have a question about pg_dump. I am backing up a database using
>> pg_dump in text mode, which works perfectly for me, with one exception.
>> I have a view vwDependentView which references another view,
>> vwIndependentView. However, when I feed my dump script to psql, it is
>> attempting to make vwDependentView first and failing.
> What version of PostgreSQL are you using? pg_dump tends to improve
> with each release; I couldn't duplicate your problem in 8.0.0rc3
> or 7.4.6.
8.0 is the first version in which pg_dump really is capable of avoiding
this sort of problem. In older releases the dump order is basically the
same as the order of original creation of the objects --- so you can
easily confuse it by, for example, doing CREATE OR REPLACE VIEW to
modify a view to reference a table that didn't exist when the view was
first defined.
A workaround that may or may not be worse than the disease is to drop
the dependent view completely and then recreate it. If there's other
stuff that depends on the dependent view this can cascade into a real
PITA :-(
regards, tom lane