On Wed, Feb 26, 2020 at 06:32:00PM +0000, Dagfinn Ilmari Mannsåker wrote: > Tom Lane <t...@sss.pgh.pa.us> writes: > > > Michael Paquier <mich...@paquier.xyz> writes: > >> On Wed, Feb 26, 2020 at 10:06:38AM +0100, Magnus Hagander wrote: > >>> +1, seems like that would be a regression in value. > > > >> Having more generic messages is less work for translators, we have > >> PG_VERSION in the file name, and that's more complicated to translate > >> in both French and Japanese. No idea about other languages. > > > > Just looking at the committed diff, it seems painfully obvious that these > > two messages were written by different people who weren't talking to each > > other. Why aren't they more alike? Given > > > > pg_fatal("could not open version file \"%s\": %m\n", ver_filename); > > > > (which seems fine to me), I think the second ought to be > > > > pg_fatal("could not parse version file \"%s\"\n", ver_filename); > > Good point. Patch attached.
Patch applied, and other adjustments: 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. Because some of the branches are different, I am attaching the applied multi-version patch. -- Bruce Momjian <br...@momjian.us> https://momjian.us EnterpriseDB https://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Ancient Roman grave inscription +
9.5: diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c index da3aefca82..c59da91f9d 100644 --- a/src/bin/pg_upgrade/server.c +++ b/src/bin/pg_upgrade/server.c @@ -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); 9.6: diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c index 1cd606a847..862a50c254 100644 --- a/src/bin/pg_upgrade/server.c +++ b/src/bin/pg_upgrade/server.c @@ -165,12 +165,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); 10: diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c index 5563a5020b..abcb4b176b 100644 --- a/src/bin/pg_upgrade/server.c +++ b/src/bin/pg_upgrade/server.c @@ -165,11 +165,11 @@ 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", &v1, &v2) < 1) - pg_fatal("could not parse PG_VERSION file from %s\n", cluster->pgdata); + pg_fatal("could not parse version file \"%s\"\n", ver_filename); fclose(version_fd); 11: diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c index fccc21836a..d2391137a8 100644 --- a/src/bin/pg_upgrade/server.c +++ b/src/bin/pg_upgrade/server.c @@ -165,11 +165,11 @@ 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", &v1, &v2) < 1) - pg_fatal("could not parse PG_VERSION file from %s\n", cluster->pgdata); + pg_fatal("could not parse version file \"%s\"\n", ver_filename); fclose(version_fd); 12: diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c index 6ad4b14e16..0b5967c49b 100644 --- a/src/bin/pg_upgrade/server.c +++ b/src/bin/pg_upgrade/server.c @@ -165,11 +165,11 @@ 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\": %m\n", ver_filename); if (fscanf(version_fd, "%63s", cluster->major_version_str) == 0 || sscanf(cluster->major_version_str, "%d.%d", &v1, &v2) < 1) - pg_fatal("could not parse PG_VERSION file from %s\n", cluster->pgdata); + pg_fatal("could not parse version file \"%s\"\n", ver_filename); fclose(version_fd); head: diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c index be604d3351..f669bb4e8a 100644 --- a/src/bin/pg_upgrade/server.c +++ b/src/bin/pg_upgrade/server.c @@ -168,7 +168,7 @@ get_major_server_version(ClusterInfo *cluster) if (fscanf(version_fd, "%63s", cluster->major_version_str) == 0 || sscanf(cluster->major_version_str, "%d.%d", &v1, &v2) < 1) - pg_fatal("could not parse PG_VERSION file from \"%s\"\n", cluster->pgdata); + pg_fatal("could not parse version file \"%s\"\n", ver_filename); fclose(version_fd);