Skip to content

Commit a11d8e1

Browse files
committed
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
1 parent b5da1b3 commit a11d8e1

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/bin/pg_resetwal/pg_resetwal.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -458,30 +458,32 @@ main(int argc, char *argv[])
458458
if (minXlogSegNo > newXlogSegNo)
459459
newXlogSegNo = minXlogSegNo;
460460

461+
if (noupdate)
462+
{
463+
PrintNewControlValues();
464+
exit(0);
465+
}
466+
461467
/*
462468
* If we had to guess anything, and -f was not given, just print the
463-
* guessed values and exit. Also print if -n is given.
469+
* guessed values and exit.
464470
*/
465-
if ((guessed && !force) || noupdate)
471+
if (guessed && !force)
466472
{
467473
PrintNewControlValues();
468-
if (!noupdate)
469-
{
470-
printf(_("\nIf these values seem acceptable, use -f to force reset.\n"));
471-
exit(1);
472-
}
473-
else
474-
exit(0);
474+
pg_log_error("not proceeding because control file values were guessed");
475+
pg_log_error_hint("If these values seem acceptable, use -f to force reset.");
476+
exit(1);
475477
}
476478

477479
/*
478480
* Don't reset from a dirty pg_control without -f, either.
479481
*/
480482
if (ControlFile.state != DB_SHUTDOWNED && !force)
481483
{
482-
printf(_("The database server was not shut down cleanly.\n"
483-
"Resetting the write-ahead log might cause data to be lost.\n"
484-
"If you want to proceed anyway, use -f to force reset.\n"));
484+
pg_log_error("database server was not shut down cleanly");
485+
pg_log_error_detail("Resetting the write-ahead log might cause data to be lost.");
486+
pg_log_error_hint("If you want to proceed anyway, use -f to force reset.");
485487
exit(1);
486488
}
487489

0 commit comments

Comments
 (0)