From cd917ffb9a43e9e4699c2a89d495ee02a8701034 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 19 Jun 2019 21:49:03 +0200 Subject: [PATCH] pg_upgrade: Improve error messages Make wording more accurate and add strerror() information. Discussion: https://www.postgresql.org/message-id/24c8bd05-aed1-6301-919d-8acbabdb8c24@2ndquadrant.com --- src/bin/pg_upgrade/exec.c | 4 ++-- src/bin/pg_upgrade/option.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c index 043373f9a5..0363309328 100644 --- a/src/bin/pg_upgrade/exec.c +++ b/src/bin/pg_upgrade/exec.c @@ -146,7 +146,7 @@ exec_prog(const char *log_file, const char *opt_log_file, #endif if (log == NULL) - pg_fatal("could not write to log file \"%s\"\n", log_file); + pg_fatal("could not open log file \"%s\": %m\n", log_file); #ifdef WIN32 /* Are we printing "command:" before its output? */ @@ -201,7 +201,7 @@ exec_prog(const char *log_file, const char *opt_log_file, * log these commands to a third file, but that just adds complexity. */ if ((log = fopen(log_file, "a")) == NULL) - pg_fatal("could not write to log file \"%s\"\n", log_file); + pg_fatal("could not write to log file \"%s\": %m\n", log_file); fprintf(log, "\n\n"); fclose(log); #endif diff --git a/src/bin/pg_upgrade/option.c b/src/bin/pg_upgrade/option.c index 873d1d07e4..73f395f2a3 100644 --- a/src/bin/pg_upgrade/option.c +++ b/src/bin/pg_upgrade/option.c @@ -217,7 +217,7 @@ parseCommandLine(int argc, char *argv[]) } if ((log_opts.internal = fopen_priv(INTERNAL_LOG_FILE, "a")) == NULL) - pg_fatal("could not write to log file \"%s\"\n", INTERNAL_LOG_FILE); + pg_fatal("could not open log file \"%s\": %m\n", INTERNAL_LOG_FILE); if (log_opts.verbose) pg_log(PG_REPORT, "Running in verbose mode\n"); @@ -226,7 +226,7 @@ parseCommandLine(int argc, char *argv[]) for (filename = output_files; *filename != NULL; filename++) { if ((fp = fopen_priv(*filename, "a")) == NULL) - pg_fatal("could not write to log file \"%s\"\n", *filename); + pg_fatal("could not write to log file \"%s\": %m\n", *filename); /* Start with newline because we might be appending to a file. */ fprintf(fp, "\n" -- 2.40.0