Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bbd1e1c

Browse files
committed
Don't assume PQdb() will return a valid result from a failed connection.
1 parent b1f8a37 commit bbd1e1c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/bin/pg_dump/pg_backup_db.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Implements the basic DB functions used by the archiver.
66
*
77
* IDENTIFICATION
8-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.58 2004/09/10 20:05:18 tgl Exp $
8+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.59 2004/10/01 17:25:55 tgl Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -174,12 +174,11 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser)
174174

175175
if (noPwd || badPwd)
176176
{
177-
178177
if (badPwd)
179178
fprintf(stderr, "Password incorrect\n");
180179

181180
fprintf(stderr, "Connecting to %s as %s\n",
182-
PQdb(AH->connection), newuser);
181+
newdb, newuser);
183182

184183
need_pass = true;
185184
if (password)
@@ -189,6 +188,7 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser)
189188
else
190189
die_horribly(AH, modulename, "could not reconnect to database: %s",
191190
PQerrorMessage(newConn));
191+
PQfinish(newConn);
192192
}
193193
} while (need_pass);
194194

@@ -266,7 +266,7 @@ ConnectDatabase(Archive *AHX,
266266
/* check to see that the backend connection was successfully made */
267267
if (PQstatus(AH->connection) == CONNECTION_BAD)
268268
die_horribly(AH, modulename, "connection to database \"%s\" failed: %s",
269-
PQdb(AH->connection), PQerrorMessage(AH->connection));
269+
dbname, PQerrorMessage(AH->connection));
270270

271271
/* check for version mismatch */
272272
_check_database_version(AH, ignoreVersion);

0 commit comments

Comments
 (0)