diff options
Diffstat (limited to 'src/bin/scripts/common.c')
-rw-r--r-- | src/bin/scripts/common.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c index dfe9a52be43..6903fa6e033 100644 --- a/src/bin/scripts/common.c +++ b/src/bin/scripts/common.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.26 2007/04/09 18:21:22 mha Exp $ + * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.27 2007/07/08 19:07:38 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -100,7 +100,7 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport, { PGconn *conn; char *password = NULL; - bool need_pass = false; + bool new_pass; if (require_password) password = simple_prompt("Password: ", 100, false); @@ -111,7 +111,7 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport, */ do { - need_pass = false; + new_pass = false; conn = PQsetdbLogin(pghost, pgport, NULL, NULL, dbname, pguser, password); if (!conn) @@ -122,16 +122,15 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport, } if (PQstatus(conn) == CONNECTION_BAD && - strcmp(PQerrorMessage(conn), PQnoPasswordSupplied) == 0 && + PQconnectionUsedPassword(conn) && + password == NULL && !feof(stdin)) { PQfinish(conn); - need_pass = true; - free(password); - password = NULL; password = simple_prompt("Password: ", 100, false); + new_pass = true; } - } while (need_pass); + } while (new_pass); if (password) free(password); |