From 87b904eeaf82dbd402d5f764de8cd2b209cd17ba Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Sat, 27 May 2017 22:24:24 -0400 Subject: [PATCH 1/2] pg_upgrade: Fix "%s server/cluster" wording --- src/bin/pg_upgrade/check.c | 16 ++++++++++++---- src/bin/pg_upgrade/controldata.c | 9 ++++++--- src/bin/pg_upgrade/info.c | 6 +++++- src/bin/pg_upgrade/option.c | 6 ++++-- src/bin/pg_upgrade/pg_upgrade.h | 2 -- src/bin/pg_upgrade/server.c | 19 ++++++++++++++----- 6 files changed, 41 insertions(+), 17 deletions(-) diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c index 8b9e81eb40..9df4270b3c 100644 --- a/src/bin/pg_upgrade/check.c +++ b/src/bin/pg_upgrade/check.c @@ -768,8 +768,12 @@ check_for_prepared_transactions(ClusterInfo *cluster) "FROM pg_catalog.pg_prepared_xacts"); if (PQntuples(res) != 0) - pg_fatal("The %s cluster contains prepared transactions\n", - CLUSTER_NAME(cluster)); + { + if (cluster == &old_cluster) + pg_fatal("The source cluster contains prepared transactions\n"); + else + pg_fatal("The target cluster contains prepared transactions\n"); + } PQclear(res); @@ -1080,8 +1084,12 @@ check_for_pg_role_prefix(ClusterInfo *cluster) "WHERE rolname ~ '^pg_'"); if (PQntuples(res) != 0) - pg_fatal("The %s cluster contains roles starting with 'pg_'\n", - CLUSTER_NAME(cluster)); + { + if (cluster == &old_cluster) + pg_fatal("The source cluster contains roles starting with 'pg_'\n"); + else + pg_fatal("The target cluster contains roles starting with 'pg_'\n"); + } PQclear(res); diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c index 519256851c..abebb15a94 100644 --- a/src/bin/pg_upgrade/controldata.c +++ b/src/bin/pg_upgrade/controldata.c @@ -474,9 +474,12 @@ get_control_data(ClusterInfo *cluster, bool live_check) cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER) || !got_date_is_int || !got_data_checksum_version) { - pg_log(PG_REPORT, - "The %s cluster lacks some required control information:\n", - CLUSTER_NAME(cluster)); + if (cluster == &old_cluster) + pg_log(PG_REPORT, + "The source cluster lacks some required control information:\n"); + else + pg_log(PG_REPORT, + "The target cluster lacks some required control information:\n"); if (!got_xid) pg_log(PG_REPORT, " checkpoint next XID\n"); diff --git a/src/bin/pg_upgrade/info.c b/src/bin/pg_upgrade/info.c index ab6328eef5..669524c74a 100644 --- a/src/bin/pg_upgrade/info.c +++ b/src/bin/pg_upgrade/info.c @@ -320,7 +320,11 @@ get_db_and_rel_infos(ClusterInfo *cluster) for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++) get_rel_infos(cluster, &cluster->dbarr.dbs[dbnum]); - pg_log(PG_VERBOSE, "\n%s databases:\n", CLUSTER_NAME(cluster)); + if (cluster == &old_cluster) + pg_log(PG_VERBOSE, "\nsource databases:\n"); + else + pg_log(PG_VERBOSE, "\ntarget databases:\n"); + if (log_opts.verbose) print_db_infos(&cluster->dbarr); } diff --git a/src/bin/pg_upgrade/option.c b/src/bin/pg_upgrade/option.c index 5a556e7b30..1406c5b46f 100644 --- a/src/bin/pg_upgrade/option.c +++ b/src/bin/pg_upgrade/option.c @@ -405,8 +405,10 @@ adjust_data_dir(ClusterInfo *cluster) /* Must be a configuration directory, so find the real data directory. */ - prep_status("Finding the real data directory for the %s cluster", - CLUSTER_NAME(cluster)); + if (cluster == &old_cluster) + prep_status("Finding the real data directory for the source cluster"); + else + prep_status("Finding the real data directory for the target cluster"); /* * We don't have a data directory yet, so we can't check the PG version, diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h index 8fbf8acd7e..d8a95387c4 100644 --- a/src/bin/pg_upgrade/pg_upgrade.h +++ b/src/bin/pg_upgrade/pg_upgrade.h @@ -94,8 +94,6 @@ extern char *output_files[]; #define ECHO_BLANK "." #endif -#define CLUSTER_NAME(cluster) ((cluster) == &old_cluster ? "old" : \ - (cluster) == &new_cluster ? "new" : "none") /* OID system catalog preservation added during PG 9.0 development */ #define TABLE_SPACE_SUBDIRS_CAT_VER 201001111 diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c index 87a98983e2..a6458b5707 100644 --- a/src/bin/pg_upgrade/server.c +++ b/src/bin/pg_upgrade/server.c @@ -285,9 +285,14 @@ start_postmaster(ClusterInfo *cluster, bool throw_error) PQerrorMessage(conn)); if (conn) PQfinish(conn); - pg_fatal("could not connect to %s postmaster started with the command:\n" - "%s\n", - CLUSTER_NAME(cluster), cmd); + if (cluster == &old_cluster) + pg_fatal("could not connect to source postmaster started with the command:\n" + "%s\n", + cmd); + else + pg_fatal("could not connect to target postmaster started with the command:\n" + "%s\n", + cmd); } PQfinish(conn); @@ -297,8 +302,12 @@ start_postmaster(ClusterInfo *cluster, bool throw_error) * running. */ if (!pg_ctl_return) - pg_fatal("pg_ctl failed to start the %s server, or connection failed\n", - CLUSTER_NAME(cluster)); + { + if (cluster == &old_cluster) + pg_fatal("pg_ctl failed to start the source server, or connection failed\n"); + else + pg_fatal("pg_ctl failed to start the target server, or connection failed\n"); + } return true; } -- 2.11.0