On Wed, Nov 16, 2016 at 10:14 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote: > Robert Haas <robertmhaas@gmail.com> writes: >> On Wed, Nov 16, 2016 at 10:00 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote: >>> The changes in pg_backup_archiver.c would have to be back-patched >>> into all versions supporting --if-exists, so that they don't fail >>> on dump archives produced by patched versions. > >> Even if you patch future minor releases, past minor releases are still >> going to exist out there in the wild for a long, long time. > > Yeah, but it would only matter if you try to use pg_restore --clean --if-exists > with an archive file that happens to contain a view that has this issue. > Such cases would previously have failed anyway, because of precisely > the bug at issue ... and there aren't very many of them, or we'd have > noticed the problem before. So I don't feel *too* bad about this, > I just want to make sure we have a solution available.
Right, OK.
For what it is worth we just run into this problem on our postgres 9.2.17 installation on a hunch we (after reading Tom's initial email replaced the view that caused this by this
create view ... as select * from (...original view definition...) hack_around_pg_dump_versus_rules_bug;
Which caused pg_dump to change its behavior and instead emit create view .... which is what we wanted (because we take filtered down and dependency ordered outputs of pg_dump as the starting point for new patches to the db). But it surprised me mildly that the hack "worked" so I thought I would mention it here. It might just mean that I'm misunderstanding the bug but if there was really a dependency in the original that dependency still exists now.
N/m turns out that using pg_dump -t <viewname> isn't a good way to test if the hack works because than it always does the good thing.