From f35d0d7ee92a86341b77d7a73617113316d1baf7 Mon Sep 17 00:00:00 2001 From: Anastasia Date: Wed, 12 Apr 2017 16:47:45 +0300 Subject: [PATCH] Code cleanup. Delete -W option --- catalog.c | 53 ++++++++++++++++------------------------------------- pgut/pgut.c | 8 +------- pgut/pgut.h | 2 -- 3 files changed, 17 insertions(+), 46 deletions(-) diff --git a/catalog.c b/catalog.c index a332ae57..42b80abc 100644 --- a/catalog.c +++ b/catalog.c @@ -479,58 +479,37 @@ pgBackupWriteIni(pgBackup *backup) static pgBackup * read_backup_from_file(const char *path) { - pgBackup *backup; + pgBackup *backup = pgut_new(pgBackup); char *backup_mode = NULL; char *start_lsn = NULL; char *stop_lsn = NULL; char *status = NULL; char *parent_backup = NULL; - int i; pgut_option options[] = { - {'s', 0, "backup-mode", NULL, SOURCE_FILE_STRICT}, - {'u', 0, "timelineid", NULL, SOURCE_FILE_STRICT}, - {'s', 0, "start-lsn", NULL, SOURCE_FILE_STRICT}, - {'s', 0, "stop-lsn", NULL, SOURCE_FILE_STRICT}, - {'t', 0, "start-time", NULL, SOURCE_FILE_STRICT}, - {'t', 0, "end-time", NULL, SOURCE_FILE_STRICT}, - {'U', 0, "recovery-xid", NULL, SOURCE_FILE_STRICT}, - {'t', 0, "recovery-time", NULL, SOURCE_FILE_STRICT}, - {'I', 0, "data-bytes", NULL, SOURCE_FILE_STRICT}, - {'u', 0, "block-size", NULL, SOURCE_FILE_STRICT}, - {'u', 0, "xlog-block-size", NULL, SOURCE_FILE_STRICT}, - {'u', 0, "checksum_version", NULL, SOURCE_FILE_STRICT}, - {'u', 0, "stream", NULL, SOURCE_FILE_STRICT}, - {'s', 0, "status", NULL, SOURCE_FILE_STRICT}, - {'s', 0, "parent_backup", NULL, SOURCE_FILE_STRICT}, + {'s', 0, "backup-mode", &backup_mode, SOURCE_FILE_STRICT}, + {'u', 0, "timelineid", &backup->tli, SOURCE_FILE_STRICT}, + {'s', 0, "start-lsn", &start_lsn, SOURCE_FILE_STRICT}, + {'s', 0, "stop-lsn", &stop_lsn, SOURCE_FILE_STRICT}, + {'t', 0, "start-time", &backup->start_time, SOURCE_FILE_STRICT}, + {'t', 0, "end-time", &backup->end_time, SOURCE_FILE_STRICT}, + {'U', 0, "recovery-xid", &backup->recovery_xid, SOURCE_FILE_STRICT}, + {'t', 0, "recovery-time", &backup->recovery_time, SOURCE_FILE_STRICT}, + {'I', 0, "data-bytes", &backup->data_bytes, SOURCE_FILE_STRICT}, + {'u', 0, "block-size", &backup->block_size, SOURCE_FILE_STRICT}, + {'u', 0, "xlog-block-size", &backup->wal_block_size, SOURCE_FILE_STRICT}, + {'u', 0, "checksum_version", &backup->checksum_version, SOURCE_FILE_STRICT}, + {'u', 0, "stream", &backup->stream, SOURCE_FILE_STRICT}, + {'s', 0, "status", &status, SOURCE_FILE_STRICT}, + {'s', 0, "parent_backup", &parent_backup, SOURCE_FILE_STRICT}, {0} }; if (access(path, F_OK) != 0) return NULL; - backup = pgut_new(pgBackup); init_backup(backup); - - i = 0; - options[i++].var = &backup_mode; - options[i++].var = &backup->tli; - options[i++].var = &start_lsn; - options[i++].var = &stop_lsn; - options[i++].var = &backup->start_time; - options[i++].var = &backup->end_time; - options[i++].var = &backup->recovery_xid; - options[i++].var = &backup->recovery_time; - options[i++].var = &backup->data_bytes; - options[i++].var = &backup->block_size; - options[i++].var = &backup->wal_block_size; - options[i++].var = &backup->checksum_version; - options[i++].var = &backup->stream; - options[i++].var = &status; - options[i++].var = &parent_backup; - Assert(i == lengthof(options) - 1); - pgut_readopt(path, options, ERROR); if (backup_mode) diff --git a/pgut/pgut.c b/pgut/pgut.c index 01921c97..93d18fed 100644 --- a/pgut/pgut.c +++ b/pgut/pgut.c @@ -35,8 +35,7 @@ const char *username = NULL; char *password = NULL; bool verbose = false; bool quiet = false; - -bool prompt_password = false; +bool prompt_password = true; /* Database connections */ static PGcancel *volatile cancel_conn = NULL; @@ -75,7 +74,6 @@ static pgut_option default_options[] = { 's', 'U', "username" , &username, SOURCE_CMDLINE }, { 'b', 'v', "verbose" , &verbose, SOURCE_CMDLINE }, { 'B', 'w', "no-password" , &prompt_password, SOURCE_CMDLINE }, - { 'b', 'W', "password" , &prompt_password, SOURCE_CMDLINE }, { 0 } }; @@ -882,13 +880,9 @@ PGconn * pgut_connect(const char *dbname) { PGconn *conn; - if (interrupted && !in_cleanup) elog(ERROR, "interrupted"); - if (prompt_password) - prompt_for_password(username); - /* Start the connection. Loop until we have a password if requested by backend. */ for (;;) { diff --git a/pgut/pgut.h b/pgut/pgut.h index 22a7ca28..9402ec91 100644 --- a/pgut/pgut.h +++ b/pgut/pgut.h @@ -86,8 +86,6 @@ extern char *password; extern bool verbose; extern bool quiet; -extern bool prompt_password; - extern bool interrupted; extern void help(bool details);