pg_upgrade: preserve freeze info for postgres/template1 dbs
authorBruce Momjian
Thu, 12 Feb 2015 02:02:07 +0000 (21:02 -0500)
committerBruce Momjian
Thu, 12 Feb 2015 02:02:36 +0000 (21:02 -0500)
pg_database.datfrozenxid and pg_database.datminmxid were not preserved
for the 'postgres' and 'template1' databases.  This could cause missing
clog file errors on access to user tables and indexes after upgrades in
these databases.

Backpatch through 9.0

src/bin/pg_dump/pg_dumpall.c

index 0f1de59fd0c32e0f2c7b9b09a8a0b5ea722328b6..19467a4fecc2a29ba7505241a85cbea87af38253 100644 (file)
@@ -1398,17 +1398,17 @@ dumpCreateDB(PGconn *conn)
                appendStringLiteralConn(buf, dbname, conn);
                appendPQExpBufferStr(buf, ";\n");
            }
+       }
 
-           if (binary_upgrade)
-           {
-               appendPQExpBufferStr(buf, "-- For binary upgrade, set datfrozenxid and datminmxid.\n");
-               appendPQExpBuffer(buf, "UPDATE pg_catalog.pg_database "
-                                 "SET datfrozenxid = '%u', datminmxid = '%u' "
-                                 "WHERE datname = ",
-                                 dbfrozenxid, dbminmxid);
-               appendStringLiteralConn(buf, dbname, conn);
-               appendPQExpBufferStr(buf, ";\n");
-           }
+       if (binary_upgrade)
+       {
+           appendPQExpBufferStr(buf, "-- For binary upgrade, set datfrozenxid and datminmxid.\n");
+           appendPQExpBuffer(buf, "UPDATE pg_catalog.pg_database "
+                             "SET datfrozenxid = '%u', datminmxid = '%u' "
+                             "WHERE datname = ",
+                             dbfrozenxid, dbminmxid);
+           appendStringLiteralConn(buf, dbname, conn);
+           appendPQExpBufferStr(buf, ";\n");
        }
 
        if (!skip_acls &&