From ff81acdd646c64efcae8b6cf083daff0494f6f82 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 19 Sep 2023 16:06:22 +0200 Subject: [PATCH v2 4/7] pg_resetwal: Use frontend logging API This now causes error messages related to the lack of the -f option to appear on standard error rather than standard output. --- src/bin/pg_resetwal/pg_resetwal.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c index 12e0869251..35876e1c95 100644 --- a/src/bin/pg_resetwal/pg_resetwal.c +++ b/src/bin/pg_resetwal/pg_resetwal.c @@ -458,20 +458,22 @@ main(int argc, char *argv[]) if (minXlogSegNo > newXlogSegNo) newXlogSegNo = minXlogSegNo; + if (noupdate) + { + PrintNewControlValues(); + exit(0); + } + /* * If we had to guess anything, and -f was not given, just print the - * guessed values and exit. Also print if -n is given. + * guessed values and exit. */ - if ((guessed && !force) || noupdate) + if (guessed && !force) { PrintNewControlValues(); - if (!noupdate) - { - printf(_("\nIf these values seem acceptable, use -f to force reset.\n")); - exit(1); - } - else - exit(0); + pg_log_error("not proceeding because control file values were guessed"); + pg_log_error_hint("If these values seem acceptable, use -f to force reset."); + exit(1); } /* @@ -479,9 +481,9 @@ main(int argc, char *argv[]) */ if (ControlFile.state != DB_SHUTDOWNED && !force) { - printf(_("The database server was not shut down cleanly.\n" - "Resetting the write-ahead log might cause data to be lost.\n" - "If you want to proceed anyway, use -f to force reset.\n")); + pg_log_error("database server was not shut down cleanly"); + pg_log_error_detail("Resetting the write-ahead log might cause data to be lost."); + pg_log_error_hint("If you want to proceed anyway, use -f to force reset."); exit(1); } -- 2.42.0