Commit bbd1e1cc authored by Tom Lane's avatar Tom Lane

Don't assume PQdb() will return a valid result from a failed connection.

parent b1f8a37a
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Implements the basic DB functions used by the archiver. * Implements the basic DB functions used by the archiver.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.58 2004/09/10 20:05:18 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.59 2004/10/01 17:25:55 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -174,12 +174,11 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser) ...@@ -174,12 +174,11 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser)
if (noPwd || badPwd) if (noPwd || badPwd)
{ {
if (badPwd) if (badPwd)
fprintf(stderr, "Password incorrect\n"); fprintf(stderr, "Password incorrect\n");
fprintf(stderr, "Connecting to %s as %s\n", fprintf(stderr, "Connecting to %s as %s\n",
PQdb(AH->connection), newuser); newdb, newuser);
need_pass = true; need_pass = true;
if (password) if (password)
...@@ -189,6 +188,7 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser) ...@@ -189,6 +188,7 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser)
else else
die_horribly(AH, modulename, "could not reconnect to database: %s", die_horribly(AH, modulename, "could not reconnect to database: %s",
PQerrorMessage(newConn)); PQerrorMessage(newConn));
PQfinish(newConn);
} }
} while (need_pass); } while (need_pass);
...@@ -266,7 +266,7 @@ ConnectDatabase(Archive *AHX, ...@@ -266,7 +266,7 @@ ConnectDatabase(Archive *AHX,
/* check to see that the backend connection was successfully made */ /* check to see that the backend connection was successfully made */
if (PQstatus(AH->connection) == CONNECTION_BAD) if (PQstatus(AH->connection) == CONNECTION_BAD)
die_horribly(AH, modulename, "connection to database \"%s\" failed: %s", die_horribly(AH, modulename, "connection to database \"%s\" failed: %s",
PQdb(AH->connection), PQerrorMessage(AH->connection)); dbname, PQerrorMessage(AH->connection));
/* check for version mismatch */ /* check for version mismatch */
_check_database_version(AH, ignoreVersion); _check_database_version(AH, ignoreVersion);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment