diff options
author | Bruce Momjian <bruce@momjian.us> | 2018-01-08 22:43:51 -0500 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2018-01-08 22:43:51 -0500 |
commit | 1776c817c7ef452fb47d915d1b550cd73a318944 (patch) | |
tree | 4e53b59260e65d63f3b935f63299912e7a576994 /src/bin/pg_upgrade/exec.c | |
parent | 83fe2708d66889ed9ef6bdb922d27bba4b0d4f81 (diff) |
pg_upgrade: prevent check on live cluster from generating error
Previously an inaccurate but harmless error was generated when running
--check on a live server before reporting the servers as compatible.
The fix is to split error reporting and exit control in the exec_prog()
API.
Reported-by: Daniel Westermann
Backpatch-through: 10
Diffstat (limited to 'src/bin/pg_upgrade/exec.c')
-rw-r--r-- | src/bin/pg_upgrade/exec.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c index 65e621d6eae..45fb914c0c8 100644 --- a/src/bin/pg_upgrade/exec.c +++ b/src/bin/pg_upgrade/exec.c @@ -71,16 +71,14 @@ get_bin_version(ClusterInfo *cluster) * and attempts to execute that command. If the command executes * successfully, exec_prog() returns true. * - * If the command fails, an error message is saved to the specified log_file. - * If throw_error is true, this raises a PG_FATAL error and pg_upgrade - * terminates; otherwise it is just reported as PG_REPORT and exec_prog() - * returns false. + * If the command fails, an error message is optionally written to the specified + * log_file, and the program optionally exits. * * The code requires it be called first from the primary thread on Windows. */ bool exec_prog(const char *log_file, const char *opt_log_file, - bool throw_error, const char *fmt,...) + bool report_error, bool exit_on_error, const char *fmt,...) { int result = 0; int written; @@ -173,7 +171,7 @@ exec_prog(const char *log_file, const char *opt_log_file, #endif result = system(cmd); - if (result != 0) + if (result != 0 && report_error) { /* we might be in on a progress status line, so go to the next line */ report_status(PG_REPORT, "\n*failure*"); @@ -181,12 +179,12 @@ exec_prog(const char *log_file, const char *opt_log_file, pg_log(PG_VERBOSE, "There were problems executing \"%s\"\n", cmd); if (opt_log_file) - pg_log(throw_error ? PG_FATAL : PG_REPORT, + pg_log(exit_on_error ? PG_FATAL : PG_REPORT, "Consult the last few lines of \"%s\" or \"%s\" for\n" "the probable cause of the failure.\n", log_file, opt_log_file); else - pg_log(throw_error ? PG_FATAL : PG_REPORT, + pg_log(exit_on_error ? PG_FATAL : PG_REPORT, "Consult the last few lines of \"%s\" for\n" "the probable cause of the failure.\n", log_file); |