diff options
author | Tom Lane | 2022-07-12 19:17:44 +0000 |
---|---|---|
committer | Tom Lane | 2022-07-12 19:17:44 +0000 |
commit | 7652353d87a6753627a6b6b36d7acd68475ea7c7 (patch) | |
tree | 94bd184f423b5fded9d3e2d700568e16353fb12e /src/bin/pg_upgrade/version.c | |
parent | eea9fa9b250f4044aa35d537f234c7d44fa9db3d (diff) |
Remove trailing newlines in pg_upgrade's message strings.
pg_upgrade does not use common/logging.c, which is unfortunate
but changing it to do so seems like more work than is justified.
However, we really need to make it work more like common/logging.c
in one respect: the latter expects supplied message strings to not
end with a newline, instead adding one internally. As it stands,
pg_upgrade's logging facilities expect a caller-supplied newline
in some cases and not others, which is already an invitation to bugs,
but the inconsistency with our other frontend code makes it worse.
There are already several places with missing or extra newlines,
and it's inevitable that there won't be more if we let this stand.
Hence, run around and get rid of all trailing newlines in message
strings, and add an Assert that there's not one, similar to the
existing Assert in common/logging.c. Adjust the logging functions
to supply a newline at the right places.
(Some of these strings also have a *leading* newline, which would
be a good thing to get rid of too; but this patch doesn't attempt
that.)
There are some consequent minor changes in output. The ones that
aren't outright bug fixes are generally removal of extra blank
lines that the original coding intentionally inserted. It didn't
seem worth being bug-compatible with that.
Patch by me, reviewed by Kyotaro Horiguchi and Peter Eisentraut
Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/bin/pg_upgrade/version.c')
-rw-r--r-- | src/bin/pg_upgrade/version.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c index c694558c3d6..d2636ba857f 100644 --- a/src/bin/pg_upgrade/version.c +++ b/src/bin/pg_upgrade/version.c @@ -113,7 +113,7 @@ check_for_data_types_usage(ClusterInfo *cluster, { found = true; if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) - pg_fatal("could not open file \"%s\": %s\n", output_path, + pg_fatal("could not open file \"%s\": %s", output_path, strerror(errno)); if (!db_used) { @@ -187,14 +187,14 @@ old_9_3_check_for_line_data_type_usage(ClusterInfo *cluster) if (check_for_data_type_usage(cluster, "pg_catalog.line", output_path)) { - pg_log(PG_REPORT, "fatal\n"); + pg_log(PG_REPORT, "fatal"); pg_fatal("Your installation contains the \"line\" data type in user tables.\n" "This data type changed its internal and input/output format\n" "between your old and new versions so this\n" "cluster cannot currently be upgraded. You can\n" "drop the problem columns and restart the upgrade.\n" "A list of the problem columns is in the file:\n" - " %s\n\n", output_path); + " %s", output_path); } else check_ok(); @@ -225,13 +225,13 @@ old_9_6_check_for_unknown_data_type_usage(ClusterInfo *cluster) if (check_for_data_type_usage(cluster, "pg_catalog.unknown", output_path)) { - pg_log(PG_REPORT, "fatal\n"); + pg_log(PG_REPORT, "fatal"); pg_fatal("Your installation contains the \"unknown\" data type in user tables.\n" "This data type is no longer allowed in tables, so this\n" "cluster cannot currently be upgraded. You can\n" "drop the problem columns and restart the upgrade.\n" "A list of the problem columns is in the file:\n" - " %s\n\n", output_path); + " %s", output_path); } else check_ok(); @@ -285,7 +285,7 @@ old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode) if (!check_mode) { if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) - pg_fatal("could not open file \"%s\": %s\n", output_path, + pg_fatal("could not open file \"%s\": %s", output_path, strerror(errno)); if (!db_used) { @@ -334,7 +334,7 @@ old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode) "Your installation contains hash indexes. These indexes have different\n" "internal formats between your old and new clusters, so they must be\n" "reindexed with the REINDEX command. After upgrading, you will be given\n" - "REINDEX instructions.\n\n"); + "REINDEX instructions."); else pg_log(PG_WARNING, "\n" "Your installation contains hash indexes. These indexes have different\n" @@ -342,7 +342,7 @@ old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode) "reindexed with the REINDEX command. The file\n" " %s\n" "when executed by psql by the database superuser will recreate all invalid\n" - "indexes; until then, none of these indexes will be used.\n\n", + "indexes; until then, none of these indexes will be used.", output_path); } else @@ -369,13 +369,13 @@ old_11_check_for_sql_identifier_data_type_usage(ClusterInfo *cluster) if (check_for_data_type_usage(cluster, "information_schema.sql_identifier", output_path)) { - pg_log(PG_REPORT, "fatal\n"); + pg_log(PG_REPORT, "fatal"); pg_fatal("Your installation contains the \"sql_identifier\" data type in user tables.\n" "The on-disk format for this data type has changed, so this\n" "cluster cannot currently be upgraded. You can\n" "drop the problem columns and restart the upgrade.\n" "A list of the problem columns is in the file:\n" - " %s\n\n", output_path); + " %s", output_path); } else check_ok(); @@ -420,7 +420,7 @@ report_extension_updates(ClusterInfo *cluster) found = true; if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) - pg_fatal("could not open file \"%s\": %s\n", output_path, + pg_fatal("could not open file \"%s\": %s", output_path, strerror(errno)); if (!db_used) { @@ -452,7 +452,7 @@ report_extension_updates(ClusterInfo *cluster) "with the ALTER EXTENSION command. The file\n" " %s\n" "when executed by psql by the database superuser will update\n" - "these extensions.\n\n", + "these extensions.", output_path); } else |