pg_upgrade: make get_major_server_version() err msg consistent
authorBruce Momjian <[email protected]>
Thu, 19 Mar 2020 19:20:55 +0000 (15:20 -0400)
committerBruce Momjian <[email protected]>
Thu, 19 Mar 2020 19:20:55 +0000 (15:20 -0400)
This patch fixes the error message in get_major_server_version() to be
"could not parse version file", and uses the full file path name, rather
than just the data directory path.

Also, commit 4109bb5de4 added the cause of the failure to the  "could
not open" error message, and improved quoting.  This patch backpatches
the "could not open" cause to PG 12, where it was first widely used, and
backpatches the quoting fix in that patch to all supported releases.

Reported-by: Tom Lane
Discussion: https://postgr.es/m/[email protected]

Author: Dagfinn Ilmari MannsÃ¥ker

Backpatch-through: 9.5

src/bin/pg_upgrade/server.c

index da3aefca829c3f0ef473b22fc15226256d691d6e..c59da91f9df3289ce1bdcdd3039efc1bcbf0f086 100644 (file)
@@ -164,12 +164,12 @@ get_major_server_version(ClusterInfo *cluster)
    snprintf(ver_filename, sizeof(ver_filename), "%s/PG_VERSION",
             cluster->pgdata);
    if ((version_fd = fopen(ver_filename, "r")) == NULL)
-       pg_fatal("could not open version file: %s\n", ver_filename);
+       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) != 2)
-       pg_fatal("could not get version from %s\n", cluster->pgdata);
+       pg_fatal("could not parse version file \"%s\"\n", ver_filename);
 
    fclose(version_fd);