]> granicus.if.org Git - postgresql/commitdiff
pg_upgrade: preserve the timestamp epoch
authorBruce Momjian <bruce@momjian.us>
Thu, 11 Sep 2014 22:39:46 +0000 (18:39 -0400)
committerBruce Momjian <bruce@momjian.us>
Thu, 11 Sep 2014 22:39:51 +0000 (18:39 -0400)
This is useful for replication tools like Slony and Skytools.  This is a
backpatch of a74a4aa23bb95b590ff01ee564219d2eacea3706.

Report by Sergey Konoplev

Backpatch through 9.3

contrib/pg_upgrade/controldata.c
contrib/pg_upgrade/pg_upgrade.c
contrib/pg_upgrade/pg_upgrade.h

index 13c95a2e2e90c081b3d496c3705c00fb78ccb86a..16f535b37b65693eefece8245ca1bc4f94436eee 100644 (file)
@@ -233,16 +233,20 @@ get_control_data(ClusterInfo *cluster, bool live_check)
                }
                else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
                {
-                       char       *op = strchr(p, '/');
+                       p = strchr(p, ':');
+
+                       if (p == NULL || strlen(p) <= 1)
+                               pg_fatal("%d: controldata retrieval problem\n", __LINE__);
 
-                       if (op == NULL)
-                               op = strchr(p, ':');
+                       p++;                            /* removing ':' char */
+                       cluster->controldata.chkpnt_nxtepoch = str2uint(p);
 
-                       if (op == NULL || strlen(op) <= 1)
+                       p = strchr(p, '/');
+                       if (p == NULL || strlen(p) <= 1)
                                pg_fatal("%d: controldata retrieval problem\n", __LINE__);
 
-                       op++;                           /* removing ':' char */
-                       cluster->controldata.chkpnt_nxtxid = str2uint(op);
+                       p++;                            /* removing '/' char */
+                       cluster->controldata.chkpnt_nxtxid = str2uint(p);
                        got_xid = true;
                }
                else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
index 16ffd5f652a9d155148f1fca9086e9567040b4da..7a18e4e5f8a1d80a10fdf70058ec1b758339719e 100644 (file)
@@ -422,12 +422,16 @@ copy_clog_xlog_xid(void)
        /* copy old commit logs to new data dir */
        copy_subdir_files("pg_clog");
 
-       /* set the next transaction id of the new cluster */
-       prep_status("Setting next transaction ID for new cluster");
+       /* set the next transaction id and epoch of the new cluster */
+       prep_status("Setting next transaction ID and epoch for new cluster");
        exec_prog(UTILITY_LOG_FILE, NULL, true,
                          "\"%s/pg_resetxlog\" -f -x %u \"%s\"",
                          new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
                          new_cluster.pgdata);
+       exec_prog(UTILITY_LOG_FILE, NULL, true,
+                         "\"%s/pg_resetxlog\" -f -e %u \"%s\"",
+                         new_cluster.bindir, old_cluster.controldata.chkpnt_nxtepoch,
+                         new_cluster.pgdata);
        check_ok();
 
        /*
index 5619dc2c8dedcf74275f5d6564498c564d3f8d3b..5dc7895f9f5b1e46c0e9d28f0033a9417e7c7cf2 100644 (file)
@@ -190,6 +190,7 @@ typedef struct
        char            nextxlogfile[25];
        uint32          chkpnt_tli;
        uint32          chkpnt_nxtxid;
+       uint32          chkpnt_nxtepoch;
        uint32          chkpnt_nxtoid;
        uint32          chkpnt_nxtmulti;
        uint32          chkpnt_nxtmxoff;