Date: Thursday, March 23, 2006 @ 00:10:59
Author: marc
Path: /cvsroot/carob/odbsequoia/src
Modified: connect.cpp (1.18 -> 1.19) connect.hpp (1.8 -> 1.9) env.cpp (1.7
-> 1.8)
Implemented SQLDisconnect()
-------------+
connect.cpp | 27 +++++++++++++++++++++++++++
connect.hpp | 13 ++++++++++++-
env.cpp | 2 ++
3 files changed, 41 insertions(+), 1 deletion(-)
Index: odbsequoia/src/connect.cpp
diff -u odbsequoia/src/connect.cpp:1.18 odbsequoia/src/connect.cpp:1.19
--- odbsequoia/src/connect.cpp:1.18 Wed Mar 22 18:50:50 2006
+++ odbsequoia/src/connect.cpp Thu Mar 23 00:10:59 2006
@@ -153,6 +153,8 @@
SQLRETURN
ODBCConnection::AllocStmt(SQLHANDLE * OutputHandle)
{
+ // FIXME: leaking here when the application forgets
+ // to call SQLFreeHandle(STMT, newstmt)
ODBCStatement * newstmt = new ODBCStatement(*this);
newstmt->carob_stmt = carob_conn->createStatement();
newstmt->state = S1;
@@ -160,6 +162,31 @@
return SQL_SUCCESS;
}
+SQLRETURN
+SQLDisconnect(SQLHDBC ConnectionHandle)
+{
+ ODBCConnection * self_p = static_cast<ODBCConnection *>(ConnectionHandle);
+ self_p->clear_diags();
+
+ _PROTECT_SQLRETURN(self_p, disconnect());
+}
+
+SQLRETURN
+ODBCConnection::disconnect()
+{
+ // TODO actually implement the spec, checking current state etc.
+
+ // Warning: for the moment we are also called by the destructor,
+ // and so need to consider already closed or never connected carob
+ // connections.
+ if (carob_conn) {
+ delete carob_conn;
+ carob_conn = 0;
+ }
+
+ return SQL_SUCCESS;
+}
+
/*
Index: odbsequoia/src/connect.hpp
diff -u odbsequoia/src/connect.hpp:1.8 odbsequoia/src/connect.hpp:1.9
--- odbsequoia/src/connect.hpp:1.8 Mon Jan 23 13:00:44 2006
+++ odbsequoia/src/connect.hpp Thu Mar 23 00:10:59 2006
@@ -34,7 +34,10 @@
class ODBCConnection : public ODBCItem
{
public:
- ODBCConnection(const ODBCEnv& creator) : ODBCItem(creator) { } ;
+ ODBCConnection(const ODBCEnv& creator)
+ : ODBCItem(creator),
+ carob_conn(0)
+ { } ;
CarobNS::Connection* carob_conn;
// TODO: rely on ConnectionParameters instead
std::wstring serverhost;
@@ -47,6 +50,14 @@
connectw(SQLWCHAR *sqlwdsn, SQLSMALLINT dsnlen,
SQLWCHAR *user, SQLSMALLINT userlen, SQLWCHAR *pass, SQLSMALLINT
passlen);
+ SQLRETURN
+ disconnect();
+
+ ~ODBCConnection()
+ {
+ disconnect();
+ }
+
};
Index: odbsequoia/src/env.cpp
diff -u odbsequoia/src/env.cpp:1.7 odbsequoia/src/env.cpp:1.8
--- odbsequoia/src/env.cpp:1.7 Tue Jan 17 16:36:54 2006
+++ odbsequoia/src/env.cpp Thu Mar 23 00:10:59 2006
@@ -58,6 +58,8 @@
SQLRETURN
ODBCEnv::AllocConnect(SQLHANDLE * OutputHandle)
{
+ // FIXME: leaking here when the application forgets
+ // to call SQLFreeHandle(DBC, newconn)
ODBCConnection *newconn = new ODBCConnection(*this);
*OutputHandle = newconn;
return SQL_SUCCESS;
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits