Fix bug in dumping prior releases due to MV REFRESH dependency checking.

Reports and suggested patches from Fujii Masao and Andrew Dunstan.

Andrew Dunstan
This commit is contained in:
Kevin Grittner 2013-03-13 20:20:32 -05:00
parent ed3ddf918b
commit a18b72adcd

View File

@ -1769,7 +1769,7 @@ makeTableDataInfo(TableInfo *tbinfo, bool oids)
static void static void
buildMatViewRefreshDependencies(Archive *fout) buildMatViewRefreshDependencies(Archive *fout)
{ {
PQExpBuffer query = createPQExpBuffer(); PQExpBuffer query;
PGresult *res; PGresult *res;
int ntups, int ntups,
i; i;
@ -1777,11 +1777,15 @@ buildMatViewRefreshDependencies(Archive *fout)
i_objid, i_objid,
i_refobjid; i_refobjid;
/* No Mat Views before 9.3. */
if (fout->remoteVersion < 90300)
return;
/* Make sure we are in proper schema */ /* Make sure we are in proper schema */
selectSourceSchema(fout, "pg_catalog"); selectSourceSchema(fout, "pg_catalog");
if (fout->remoteVersion >= 90300) query = createPQExpBuffer();
{
appendPQExpBuffer(query, "with recursive w as " appendPQExpBuffer(query, "with recursive w as "
"( " "( "
"select d1.objid, d2.refobjid, c2.relkind as refrelkind " "select d1.objid, d2.refobjid, c2.relkind as refrelkind "
@ -1808,7 +1812,6 @@ buildMatViewRefreshDependencies(Archive *fout)
"select 'pg_class'::regclass::oid as classid, objid, refobjid " "select 'pg_class'::regclass::oid as classid, objid, refobjid "
"from w " "from w "
"where refrelkind = 'm'"); "where refrelkind = 'm'");
}
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);