git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b5da1b3)
pg_resetwal: Use frontend logging API
2023年9月28日 09:58:36 +0000 (11:58 +0200)
2023年9月28日 09:58:36 +0000 (11:58 +0200)
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


diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
index 12e0869251cf4fd4c116c0c71663e90901614e83..35876e1c957937eacfab7aeba58e767befd837c9 100644 (file)
--- 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);
}
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /