aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq++/pgconnection.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces/libpq++/pgconnection.cc')
-rw-r--r--src/interfaces/libpq++/pgconnection.cc20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/interfaces/libpq++/pgconnection.cc b/src/interfaces/libpq++/pgconnection.cc
index 321d41f0304..80b45685dcb 100644
--- a/src/interfaces/libpq++/pgconnection.cc
+++ b/src/interfaces/libpq++/pgconnection.cc
@@ -10,7 +10,7 @@
* Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgconnection.cc,v 1.9 2000/04/22 22:39:15 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/pgconnection.cc,v 1.10 2000/07/27 19:44:01 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -46,16 +46,32 @@ PgConnection::~PgConnection()
// Close the connection only if needed
// This feature will most probably be used by the derived classes that
// need not close the connection after they are destructed.
- if ( pgCloseConnection ) {
+ CloseConnection();
+}
+
+
+// PgConnection::CloseConnection()
+// close down the connection if there is one
+void PgConnection::CloseConnection()
+{
+ // if the connection is open, close it first
+ if ( pgCloseConnection ) {
if(pgResult) PQclear(pgResult);
+ pgResult=NULL;
if(pgConn) PQfinish(pgConn);
+ pgConn=NULL;
+ pgCloseConnection=0;
}
}
+
// PgConnection::connect
// establish a connection to a backend
ConnStatusType PgConnection::Connect(const char* conninfo)
{
+ // if the connection is open, close it first
+ CloseConnection();
+
// Connect to the database
pgConn = PQconnectdb(conninfo);