pg_upgrade; change major version comparisons to use <=, not <
authorBruce Momjian <[email protected]>
Tue, 6 Oct 2020 16:12:09 +0000 (12:12 -0400)
committerBruce Momjian <[email protected]>
Tue, 6 Oct 2020 16:12:09 +0000 (12:12 -0400)
This makes checking for older major versions more consistent.

Backpatch-through: 9.5

src/bin/pg_upgrade/check.c
src/bin/pg_upgrade/controldata.c
src/bin/pg_upgrade/exec.c
src/bin/pg_upgrade/function.c
src/bin/pg_upgrade/pg_upgrade.c
src/bin/pg_upgrade/server.c

index 2f7aa632c52b5a049b15a3b7f5b548beaed231e0..89f3b0d63cc35ecc14a3266f9309a2ed0ff99e43 100644 (file)
@@ -275,7 +275,7 @@ check_cluster_versions(void)
     * upgrades
     */
 
-   if (GET_MAJOR_VERSION(old_cluster.major_version) < 804)
+   if (GET_MAJOR_VERSION(old_cluster.major_version) <= 803)
        pg_fatal("This utility can only upgrade from PostgreSQL version 8.4 and later.\n");
 
    /* Only current PG version is supported as a target */
@@ -312,7 +312,7 @@ check_cluster_compatibility(bool live_check)
    check_control_data(&old_cluster.controldata, &new_cluster.controldata);
 
    /* We read the real port number for PG >= 9.1 */
-   if (live_check && GET_MAJOR_VERSION(old_cluster.major_version) < 901 &&
+   if (live_check && GET_MAJOR_VERSION(old_cluster.major_version) <= 900 &&
        old_cluster.port == DEF_PGUPORT)
        pg_fatal("When checking a pre-PG 9.1 live old server, "
                 "you must specify the old server's port number.\n");
@@ -520,7 +520,7 @@ create_script_for_cluster_analyze(char **analyze_script_file_name)
    fprintf(script, "\"%s/vacuumdb\" %s--all --analyze-in-stages\n",
            new_cluster.bindir, user_specification.data);
    /* Did we copy the free space files? */
-   if (GET_MAJOR_VERSION(old_cluster.major_version) < 804)
+   if (GET_MAJOR_VERSION(old_cluster.major_version) <= 803)
        fprintf(script, "\"%s/vacuumdb\" %s--all\n", new_cluster.bindir,
                user_specification.data);
 
index 00d71e3a8a7c8739a813fcc6f63799037edc780e..39bcaa8fe1a2b7c0d4358fef1fe74016b65dc38c 100644 (file)
@@ -180,7 +180,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
    }
 
    /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
-   if (GET_MAJOR_VERSION(cluster->bin_version) < 1000)
+   if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
        resetwal_bin = "pg_resetxlog\" -n";
    else
        resetwal_bin = "pg_resetwal\" -n";
index b31cda8fec60eccb46774f9908a286e1c548e2c0..bdff13bb688fe4851e4f63a8132cfa25b2b012b9 100644 (file)
@@ -341,13 +341,13 @@ check_data_dir(ClusterInfo *cluster)
    check_single_dir(pg_data, "pg_twophase");
 
    /* pg_xlog has been renamed to pg_wal in v10 */
-   if (GET_MAJOR_VERSION(cluster->major_version) < 1000)
+   if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
        check_single_dir(pg_data, "pg_xlog");
    else
        check_single_dir(pg_data, "pg_wal");
 
    /* pg_clog has been renamed to pg_xact in v10 */
-   if (GET_MAJOR_VERSION(cluster->major_version) < 1000)
+   if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
        check_single_dir(pg_data, "pg_clog");
    else
        check_single_dir(pg_data, "pg_xact");
@@ -387,7 +387,7 @@ check_bin_dir(ClusterInfo *cluster)
    get_bin_version(cluster);
 
    /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
-   if (GET_MAJOR_VERSION(cluster->bin_version) < 1000)
+   if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
        validate_exec(cluster->bindir, "pg_resetxlog");
    else
        validate_exec(cluster->bindir, "pg_resetwal");
index d163cb2dde71219379dbfc78b5221aad56783158..e0bc368e1e1687a2bc5030af215630dc90154f74 100644 (file)
@@ -90,7 +90,7 @@ get_loadable_libraries(void)
         * http://archives.postgresql.org/pgsql-hackers/2012-03/msg01101.php
         * http://archives.postgresql.org/pgsql-bugs/2012-05/msg00206.php
         */
-       if (GET_MAJOR_VERSION(old_cluster.major_version) < 901)
+       if (GET_MAJOR_VERSION(old_cluster.major_version) <= 900)
        {
            PGresult   *res;
 
@@ -218,7 +218,7 @@ check_loadable_libraries(void)
             * library name "plpython" in an old PG <= 9.1 cluster must look
             * for "plpython2" in the new cluster.
             */
-           if (GET_MAJOR_VERSION(old_cluster.major_version) < 901 &&
+           if (GET_MAJOR_VERSION(old_cluster.major_version) <= 900 &&
                strcmp(lib, "$libdir/plpython") == 0)
            {
                lib = "$libdir/plpython2";
index 70194eb0964f9f127b18afeb0cb8a01425af5e71..1bc86e4205de43502805583cf817d2a3735c44df 100644 (file)
@@ -407,7 +407,7 @@ create_new_objects(void)
     * We don't have minmxids for databases or relations in pre-9.3 clusters,
     * so set those after we have restored the schema.
     */
-   if (GET_MAJOR_VERSION(old_cluster.major_version) < 903)
+   if (GET_MAJOR_VERSION(old_cluster.major_version) <= 902)
        set_frozenxids(true);
 
    /* update new_cluster info now that we have objects in the databases */
@@ -466,9 +466,9 @@ copy_xact_xlog_xid(void)
     * Copy old commit logs to new data dir. pg_clog has been renamed to
     * pg_xact in post-10 clusters.
     */
-   copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) < 1000 ?
+   copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
                      "pg_clog" : "pg_xact",
-                     GET_MAJOR_VERSION(new_cluster.major_version) < 1000 ?
+                     GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
                      "pg_clog" : "pg_xact");
 
    /* set the next transaction id and epoch of the new cluster */
index 7db3c1d51f2e241768b7c13afeac41840e7b24f8..713509f54062a273536b51c54778234bc3b82970 100644 (file)
@@ -220,7 +220,7 @@ start_postmaster(ClusterInfo *cluster, bool report_and_exit_on_error)
        snprintf(socket_string + strlen(socket_string),
                 sizeof(socket_string) - strlen(socket_string),
                 " -c %s='%s'",
-                (GET_MAJOR_VERSION(cluster->major_version) < 903) ?
+                (GET_MAJOR_VERSION(cluster->major_version) <= 902) ?
                 "unix_socket_directory" : "unix_socket_directories",
                 cluster->sockdir);
 #endif