aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_upgrade/server.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-11-06 19:46:52 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2017-11-06 19:46:52 -0500
commitd0c80c17f1a6d0b93d2ca14fe47d83b131ce9108 (patch)
tree588da68978586a05294d294513aabeea79d58407 /src/bin/pg_upgrade/server.c
parent92d830f4bff643953a09563abaa106af42625207 (diff)
downloadpostgresql-d0c80c17f1a6d0b93d2ca14fe47d83b131ce9108.tar.gz
postgresql-d0c80c17f1a6d0b93d2ca14fe47d83b131ce9108.zip
Fix version numbering foulups exposed by 10.1.
configure computed PG_VERSION_NUM incorrectly. (Coulda sworn I tested that logic back when, but it had an obvious thinko.) pg_upgrade had not been taught about the new dispensation with just one part in the major version number. Both things accidentally failed to fail with 10.0, but with 10.1 we got the wrong results. Per buildfarm.
Diffstat (limited to 'src/bin/pg_upgrade/server.c')
-rw-r--r--src/bin/pg_upgrade/server.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c
index 3e3323a6e8a..a91f18916c7 100644
--- a/src/bin/pg_upgrade/server.c
+++ b/src/bin/pg_upgrade/server.c
@@ -156,8 +156,8 @@ get_major_server_version(ClusterInfo *cluster)
{
FILE *version_fd;
char ver_filename[MAXPGPATH];
- int integer_version = 0;
- int fractional_version = 0;
+ int v1 = 0,
+ v2 = 0;
snprintf(ver_filename, sizeof(ver_filename), "%s/PG_VERSION",
cluster->pgdata);
@@ -165,13 +165,21 @@ get_major_server_version(ClusterInfo *cluster)
pg_fatal("could not open version file: %s\n", ver_filename);
if (fscanf(version_fd, "%63s", cluster->major_version_str) == 0 ||
- sscanf(cluster->major_version_str, "%d.%d", &integer_version,
- &fractional_version) < 1)
+ sscanf(cluster->major_version_str, "%d.%d", &v1, &v2) < 1)
pg_fatal("could not parse PG_VERSION file from %s\n", cluster->pgdata);
fclose(version_fd);
- return (100 * integer_version + fractional_version) * 100;
+ if (v1 < 10)
+ {
+ /* old style, e.g. 9.6.1 */
+ return v1 * 10000 + v2 * 100;
+ }
+ else
+ {
+ /* new style, e.g. 10.1 */
+ return v1 * 10000;
+ }
}