@@ -46,7 +46,7 @@ static void prepare_new_cluster(void);
4646static void prepare_new_databases (void );
4747static void create_new_objects (void );
4848static void copy_clog_xlog_xid (void );
49- static void set_frozenxids (void );
49+ static void set_frozenxids (bool minmxid_only );
5050static void setup (char * argv0 ,bool * live_check );
5151static void cleanup (void );
5252
@@ -250,8 +250,8 @@ prepare_new_cluster(void)
250250/*
251251 * We do freeze after analyze so pg_statistic is also frozen. template0 is
252252 * not frozen here, but data rows were frozen by initdb, and we set its
253- * datfrozenxid andrelfrozenxids later to match the new xid counter
254- * later.
253+ * datfrozenxid, relfrozenxids, andrelminmxid later to match the new xid
254+ *counter later.
255255 */
256256prep_status ("Freezing all rows on the new cluster" );
257257exec_prog (UTILITY_LOG_FILE ,NULL , true,
@@ -273,7 +273,7 @@ prepare_new_databases(void)
273273 * set.
274274 */
275275
276- set_frozenxids ();
276+ set_frozenxids (false );
277277
278278prep_status ("Restoring global objects in the new cluster" );
279279
@@ -356,6 +356,13 @@ create_new_objects(void)
356356end_progress_output ();
357357check_ok ();
358358
359+ /*
360+ * We don't have minmxids for databases or relations in pre-9.3
361+ * clusters, so set those after we have restores the schemas.
362+ */
363+ if (GET_MAJOR_VERSION (old_cluster .major_version )< 903 )
364+ set_frozenxids (true);
365+
359366/* regenerate now that we have objects in the databases */
360367get_db_and_rel_infos (& new_cluster );
361368
@@ -489,15 +496,15 @@ copy_clog_xlog_xid(void)
489496/*
490497 *set_frozenxids()
491498 *
492- *We have frozen all xids, so set relfrozenxid and datfrozenxid
493- *to be the old cluster's xid counter, which we just set in the new
494- *cluster. User-table frozenxidvalues will be set by pg_dump
495- *--binary-upgrade, but objects not set by the pg_dump must have
496- *proper frozen counters.
499+ *We have frozen all xids, so setdatfrozenxid, relfrozenxid, and
500+ *relminmxid to be the old cluster's xid counter, which we just set
501+ *in the new cluster. User-table frozenxidand minmxid values will
502+ *be set by pg_dump --binary-upgrade, but objects not set by the pg_dump
503+ *must have proper frozen counters.
497504 */
498505static
499506void
500- set_frozenxids (void )
507+ set_frozenxids (bool minmxid_only )
501508{
502509int dbnum ;
503510PGconn * conn ,
@@ -507,15 +514,25 @@ set_frozenxids(void)
507514int i_datname ;
508515int i_datallowconn ;
509516
510- prep_status ("Setting frozenxid counters in new cluster" );
517+ if (!minmxid_only )
518+ prep_status ("Setting frozenxid and minmxid counters in new cluster" );
519+ else
520+ prep_status ("Setting minmxid counter in new cluster" );
511521
512522conn_template1 = connectToServer (& new_cluster ,"template1" );
513523
514- /* set pg_database.datfrozenxid */
524+ if (!minmxid_only )
525+ /* set pg_database.datfrozenxid */
526+ PQclear (executeQueryOrDie (conn_template1 ,
527+ "UPDATE pg_catalog.pg_database "
528+ "SETdatfrozenxid = '%u'" ,
529+ old_cluster .controldata .chkpnt_nxtxid ));
530+
531+ /* set pg_database.datminmxid */
515532PQclear (executeQueryOrDie (conn_template1 ,
516533"UPDATE pg_catalog.pg_database "
517- "SETdatfrozenxid = '%u'" ,
518- old_cluster .controldata .chkpnt_nxtxid ));
534+ "SETdatminmxid = '%u'" ,
535+ old_cluster .controldata .chkpnt_nxtmulti ));
519536
520537/* get database names */
521538dbres = executeQueryOrDie (conn_template1 ,
@@ -533,10 +550,10 @@ set_frozenxids(void)
533550
534551/*
535552 * We must update databases where datallowconn = false, e.g.
536- * template0, because autovacuum increments their datfrozenxids and
537- * relfrozenxids even if autovacuum is turned off, and even though all
538- * the data rows are already frozen To enable this, we temporarily
539- * change datallowconn.
553+ * template0, because autovacuum increments their datfrozenxids,
554+ * relfrozenxids, and relminmxid even if autovacuum is turned off,
555+ *and even though all the data rows are already frozen To enable
556+ *this, we temporarily change datallowconn.
540557 */
541558if (strcmp (datallowconn ,"f" )== 0 )
542559PQclear (executeQueryOrDie (conn_template1 ,
@@ -546,13 +563,22 @@ set_frozenxids(void)
546563
547564conn = connectToServer (& new_cluster ,datname );
548565
549- /* set pg_class.relfrozenxid */
566+ if (!minmxid_only )
567+ /* set pg_class.relfrozenxid */
568+ PQclear (executeQueryOrDie (conn ,
569+ "UPDATEpg_catalog.pg_class "
570+ "SETrelfrozenxid = '%u' "
571+ /* only heap, materialized view, and TOAST are vacuumed */
572+ "WHERErelkind IN ('r', 'm', 't')" ,
573+ old_cluster .controldata .chkpnt_nxtxid ));
574+
575+ /* set pg_class.relminmxid */
550576PQclear (executeQueryOrDie (conn ,
551577"UPDATEpg_catalog.pg_class "
552- "SETrelfrozenxid = '%u' "
578+ "SETrelminmxid = '%u' "
553579/* only heap, materialized view, and TOAST are vacuumed */
554580"WHERErelkind IN ('r', 'm', 't')" ,
555- old_cluster .controldata .chkpnt_nxtxid ));
581+ old_cluster .controldata .chkpnt_nxtmulti ));
556582PQfinish (conn );
557583
558584/* Reset datallowconn flag */