@@ -1769,46 +1769,49 @@ makeTableDataInfo(TableInfo *tbinfo, bool oids)
17691769static void
17701770buildMatViewRefreshDependencies (Archive * fout )
17711771{
1772- PQExpBuffer query = createPQExpBuffer () ;
1772+ PQExpBuffer query ;
17731773 PGresult * res ;
17741774 int ntups ,
17751775 i ;
17761776 int i_classid ,
17771777 i_objid ,
17781778 i_refobjid ;
17791779
1780+ /* No Mat Views before 9.3. */
1781+ if (fout -> remoteVersion < 90300 )
1782+ return ;
1783+
17801784 /* Make sure we are in proper schema */
17811785 selectSourceSchema (fout , "pg_catalog" );
17821786
1783- if (fout -> remoteVersion >= 90300 )
1784- {
1785- appendPQExpBuffer (query , "with recursive w as "
1786- "( "
1787- "select d1.objid, d2.refobjid, c2.relkind as refrelkind "
1788- "from pg_depend d1 "
1789- "join pg_class c1 on c1.oid = d1.objid "
1790- "and c1.relkind = 'm' "
1791- "join pg_rewrite r1 on r1.ev_class = d1.objid "
1792- "join pg_depend d2 on d2.classid = 'pg_rewrite'::regclass "
1793- "and d2.objid = r1.oid "
1794- "and d2.refobjid <> d1.objid "
1795- "join pg_class c2 on c2.oid = d2.refobjid "
1796- "and c2.relkind in ('m','v') "
1797- "where d1.classid = 'pg_class'::regclass "
1798- "union "
1799- "select w.objid, d3.refobjid, c3.relkind "
1800- "from w "
1801- "join pg_rewrite r3 on r3.ev_class = w.refobjid "
1802- "join pg_depend d3 on d3.classid = 'pg_rewrite'::regclass "
1803- "and d3.objid = r3.oid "
1804- "and d3.refobjid <> w.refobjid "
1805- "join pg_class c3 on c3.oid = d3.refobjid "
1806- "and c3.relkind in ('m','v') "
1807- ") "
1808- "select 'pg_class'::regclass::oid as classid, objid, refobjid "
1809- "from w "
1810- "where refrelkind = 'm'" );
1811- }
1787+ query = createPQExpBuffer ();
1788+
1789+ appendPQExpBuffer (query , "with recursive w as "
1790+ "( "
1791+ "select d1.objid, d2.refobjid, c2.relkind as refrelkind "
1792+ "from pg_depend d1 "
1793+ "join pg_class c1 on c1.oid = d1.objid "
1794+ "and c1.relkind = 'm' "
1795+ "join pg_rewrite r1 on r1.ev_class = d1.objid "
1796+ "join pg_depend d2 on d2.classid = 'pg_rewrite'::regclass "
1797+ "and d2.objid = r1.oid "
1798+ "and d2.refobjid <> d1.objid "
1799+ "join pg_class c2 on c2.oid = d2.refobjid "
1800+ "and c2.relkind in ('m','v') "
1801+ "where d1.classid = 'pg_class'::regclass "
1802+ "union "
1803+ "select w.objid, d3.refobjid, c3.relkind "
1804+ "from w "
1805+ "join pg_rewrite r3 on r3.ev_class = w.refobjid "
1806+ "join pg_depend d3 on d3.classid = 'pg_rewrite'::regclass "
1807+ "and d3.objid = r3.oid "
1808+ "and d3.refobjid <> w.refobjid "
1809+ "join pg_class c3 on c3.oid = d3.refobjid "
1810+ "and c3.relkind in ('m','v') "
1811+ ") "
1812+ "select 'pg_class'::regclass::oid as classid, objid, refobjid "
1813+ "from w "
1814+ "where refrelkind = 'm'" );
18121815
18131816 res = ExecuteSqlQuery (fout , query -> data , PGRES_TUPLES_OK );
18141817
0 commit comments