diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2023-09-28 11:58:36 +0200 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2023-09-28 11:58:36 +0200 |
commit | a11d8e10f226c5a2072c1640bd1d70403ae4c4fa (patch) | |
tree | eec712f7067b9832b22f2a238bd50005760b8793 /src | |
parent | b5da1b3a939a8a7ece408131e6503be7a422e491 (diff) | |
download | postgresql-a11d8e10f226c5a2072c1640bd1d70403ae4c4fa.tar.gz postgresql-a11d8e10f226c5a2072c1640bd1d70403ae4c4fa.zip |
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.
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://www.postgresql.org/message-id/flat/0f3ab4a1-ae80-56e8-3426-6b4a02507687@eisentraut.org
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pg_resetwal/pg_resetwal.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c index 12e0869251c..35876e1c957 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); } |