diff options
Diffstat (limited to 'src/bin/pg_rewind/pg_rewind.c')
-rw-r--r-- | src/bin/pg_rewind/pg_rewind.c | 54 |
1 files changed, 22 insertions, 32 deletions
diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0922032e231..2ca4dd29afe 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -165,10 +165,6 @@ main(int argc, char **argv) { switch (c) { - case '?': - fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); - exit(1); - case 'c': restore_wal = true; break; @@ -213,34 +209,39 @@ main(int argc, char **argv) case 5: config_file = pg_strdup(optarg); break; + + default: + /* getopt_long already emitted a complaint */ + pg_log_error_hint("Try \"%s --help\" for more information.", progname); + exit(1); } } if (datadir_source == NULL && connstr_source == NULL) { pg_log_error("no source specified (--source-pgdata or --source-server)"); - fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); + pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } if (datadir_source != NULL && connstr_source != NULL) { pg_log_error("only one of --source-pgdata or --source-server can be specified"); - fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); + pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } if (datadir_target == NULL) { pg_log_error("no target data directory specified (--target-pgdata)"); - fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); + pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } if (writerecoveryconf && connstr_source == NULL) { pg_log_error("no source server information (--source-server) specified for --write-recovery-conf"); - fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); + pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } @@ -248,7 +249,7 @@ main(int argc, char **argv) { pg_log_error("too many command-line arguments (first is \"%s\")", argv[optind]); - fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); + pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } @@ -262,8 +263,8 @@ main(int argc, char **argv) if (geteuid() == 0) { pg_log_error("cannot be executed by \"root\""); - fprintf(stderr, _("You must run %s as the PostgreSQL superuser.\n"), - progname); + pg_log_error_hint("You must run %s as the PostgreSQL superuser.", + progname); exit(1); } #endif @@ -272,11 +273,8 @@ main(int argc, char **argv) /* Set mask based on PGDATA permissions */ if (!GetDataDirectoryCreatePerm(datadir_target)) - { - pg_log_error("could not read permissions of directory \"%s\": %m", - datadir_target); - exit(1); - } + pg_fatal("could not read permissions of directory \"%s\": %m", + datadir_target); umask(pg_mode_mask); @@ -1041,16 +1039,11 @@ getRestoreCommand(const char *argv0) strlcpy(full_path, progname, sizeof(full_path)); if (rc == -1) - pg_log_error("The program \"%s\" is needed by %s but was not found in the\n" - "same directory as \"%s\".\n" - "Check your installation.", - "postgres", progname, full_path); + pg_fatal("program \"%s\" is needed by %s but was not found in the same directory as \"%s\"", + "postgres", progname, full_path); else - pg_log_error("The program \"%s\" was found by \"%s\"\n" - "but was not the same version as %s.\n" - "Check your installation.", - "postgres", full_path, progname); - exit(1); + pg_fatal("program \"%s\" was found by \"%s\" but was not the same version as %s", + "postgres", full_path, progname); } /* @@ -1116,14 +1109,10 @@ ensureCleanShutdown(const char *argv0) strlcpy(full_path, progname, sizeof(full_path)); if (ret == -1) - pg_fatal("The program \"%s\" is needed by %s but was not found in the\n" - "same directory as \"%s\".\n" - "Check your installation.", + pg_fatal("program \"%s\" is needed by %s but was not found in the same directory as \"%s\"", "postgres", progname, full_path); else - pg_fatal("The program \"%s\" was found by \"%s\"\n" - "but was not the same version as %s.\n" - "Check your installation.", + pg_fatal("program \"%s\" was found by \"%s\" but was not the same version as %s", "postgres", full_path, progname); } @@ -1165,7 +1154,8 @@ ensureCleanShutdown(const char *argv0) if (system(postgres_cmd->data) != 0) { pg_log_error("postgres single-user mode in target cluster failed"); - pg_fatal("Command was: %s", postgres_cmd->data); + pg_log_error_detail("Command was: %s", postgres_cmd->data); + exit(1); } destroyPQExpBuffer(postgres_cmd); |