Patch attached. I think it as we discussed.
I do not have OpenId, so I am not registered with gerrit, so I think
that I shall not be able to enter your as reviewer. Sorry to be
awkward.
Thank you for your patience with me through all the to-ing and fro-ing
so far.
Terry.
From c7e9585283ef989dc50fc12b90333fe60944f726 Mon Sep 17 00:00:00 2001
From: Terrence Enger <tenger@iseries-guru.com>
Date: Wed, 18 Jul 2012 14:46:11 -0400
Subject: [PATCH] stop some leaked statement handles
Change-Id: I06764e0569ea615e66de6cd5946614c7c538e60e
---
.../source/drivers/odbcbase/OConnection.cxx | 3 ++
.../odbcbase/ODatabaseMetaDataResultSet.cxx | 22 ++++---------------
.../source/inc/odbc/ODatabaseMetaDataResultSet.hxx | 3 +-
3 files changed, 9 insertions(+), 19 deletions(-)
diff --git a/connectivity/source/drivers/odbcbase/OConnection.cxx
b/connectivity/source/drivers/odbcbase/OConnection.cxx
index c7ed89b..8f362d0 100644
--- a/connectivity/source/drivers/odbcbase/OConnection.cxx
+++ b/connectivity/source/drivers/odbcbase/OConnection.cxx
@@ -541,6 +541,9 @@ SQLHANDLE OConnection::createStatementHandle()
// -----------------------------------------------------------------------------
void OConnection::freeStatementHandle(SQLHANDLE& _pHandle)
{
+ if( SQL_NULL_HANDLE == _pHandle )
+ return;
+
::std::map< SQLHANDLE,OConnection*>::iterator aFind = m_aConnections.find(_pHandle);
N3SQLFreeStmt(_pHandle,SQL_RESET_PARAMS);
diff --git a/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx
b/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx
index 953ccc5..7417b68 100644
--- a/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx
+++ b/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx
@@ -66,7 +66,6 @@ ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(OConnection* _pConnection
,m_nCurrentFetchState(0)
,m_bWasNull(sal_True)
,m_bEOF(sal_False)
- ,m_bFreeHandle(sal_False)
{
OSL_ENSURE(m_pConnection,"ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet: No parent
set!");
osl_incrementInterlockedCount( &m_refCount );
@@ -74,6 +73,9 @@ ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(OConnection* _pConnection
m_pRowStatusArray = new SQLUSMALLINT[1]; // the default value
osl_decrementInterlockedCount( &m_refCount );
// allocBuffer();
+
+ if( SQL_NULL_HANDLE == m_aStatementHandle )
+ throw RuntimeException();
}
// -------------------------------------------------------------------------
@@ -93,8 +95,8 @@ void ODatabaseMetaDataResultSet::disposing(void)
OPropertySetHelper::disposing();
::osl::MutexGuard aGuard(m_aMutex);
- if(m_bFreeHandle)
- m_pConnection->freeStatementHandle(m_aStatementHandle);
+
+ m_pConnection->freeStatementHandle(m_aStatementHandle);
m_aStatement = NULL;
m_xMetaData.clear();
@@ -843,7 +845,6 @@ void ODatabaseMetaDataResultSet::openTables(const Any& catalog, const ::rtl::OUS
const ::rtl::OUString& tableNamePattern,
const Sequence< ::rtl::OUString >& types ) throw(SQLException,
RuntimeException)
{
- m_bFreeHandle = sal_True;
::rtl::OString aPKQ,aPKO,aPKN,aCOL;
const ::rtl::OUString *pSchemaPat = NULL;
@@ -891,7 +892,6 @@ void ODatabaseMetaDataResultSet::openTables(const Any& catalog, const ::rtl::OUS
//-----------------------------------------------------------------------------
void ODatabaseMetaDataResultSet::openTablesTypes( ) throw(SQLException, RuntimeException)
{
- m_bFreeHandle = sal_True;
SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
0,0,
0,0,
@@ -908,7 +908,6 @@ void ODatabaseMetaDataResultSet::openTablesTypes( ) throw(SQLException, RuntimeE
// -------------------------------------------------------------------------
void ODatabaseMetaDataResultSet::openCatalogs() throw(SQLException, RuntimeException)
{
- m_bFreeHandle = sal_True;
SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
(SDB_ODBC_CHAR *) SQL_ALL_CATALOGS,SQL_NTS,
(SDB_ODBC_CHAR *) "",SQL_NTS,
@@ -926,7 +925,6 @@ void ODatabaseMetaDataResultSet::openCatalogs() throw(SQLException, RuntimeExcep
// -------------------------------------------------------------------------
void ODatabaseMetaDataResultSet::openSchemas() throw(SQLException, RuntimeException)
{
- m_bFreeHandle = sal_True;
SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
(SDB_ODBC_CHAR *) "",SQL_NTS,
(SDB_ODBC_CHAR *) SQL_ALL_SCHEMAS,SQL_NTS,
@@ -952,7 +950,6 @@ void ODatabaseMetaDataResultSet::openColumnPrivileges( const Any& catalog, cons
else
pSchemaPat = NULL;
- m_bFreeHandle = sal_True;
::rtl::OString aPKQ,aPKO,aPKN,aCOL;
if ( catalog.hasValue() )
@@ -988,7 +985,6 @@ void ODatabaseMetaDataResultSet::openColumns( const Any& catalog,
else
pSchemaPat = NULL;
- m_bFreeHandle = sal_True;
::rtl::OString aPKQ,aPKO,aPKN,aCOL;
if ( catalog.hasValue() )
aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
@@ -1057,7 +1053,6 @@ void ODatabaseMetaDataResultSet::openProcedureColumns( const Any& catalog,
else
pSchemaPat = NULL;
- m_bFreeHandle = sal_True;
::rtl::OString aPKQ,aPKO,aPKN,aCOL;
if ( catalog.hasValue() )
aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
@@ -1092,7 +1087,6 @@ void ODatabaseMetaDataResultSet::openProcedures(const Any& catalog, const
::rtl:
else
pSchemaPat = NULL;
- m_bFreeHandle = sal_True;
::rtl::OString aPKQ,aPKO,aPKN,aCOL;
if ( catalog.hasValue() )
@@ -1137,7 +1131,6 @@ void ODatabaseMetaDataResultSet::openSpecialColumns(sal_Bool _bRowVer,const
Any&
else
pSchemaPat = NULL;
- m_bFreeHandle = sal_True;
::rtl::OString aPKQ,aPKO,aPKN,aCOL;
if ( catalog.hasValue() )
aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
@@ -1176,8 +1169,6 @@ void ODatabaseMetaDataResultSet::openForeignKeys( const Any& catalog, const
::rt
const Any& catalog2, const ::rtl::OUString* schema2,
const ::rtl::OUString* table2) throw(SQLException,
RuntimeException)
{
- m_bFreeHandle = sal_True;
-
::rtl::OString aPKQ,aPKO,aPKN, aFKQ, aFKO, aFKN;
if ( catalog.hasValue() )
aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
@@ -1227,7 +1218,6 @@ void ODatabaseMetaDataResultSet::openPrimaryKeys(const Any& catalog, const
::rtl
else
pSchemaPat = NULL;
- m_bFreeHandle = sal_True;
::rtl::OString aPKQ,aPKO,aPKN,aCOL;
if ( catalog.hasValue() )
@@ -1257,7 +1247,6 @@ void ODatabaseMetaDataResultSet::openTablePrivileges(const Any& catalog,
const :
else
pSchemaPat = NULL;
- m_bFreeHandle = sal_True;
::rtl::OString aPKQ,aPKO,aPKN;
if ( catalog.hasValue() )
@@ -1288,7 +1277,6 @@ void ODatabaseMetaDataResultSet::openIndexInfo( const Any& catalog, const
::rtl:
else
pSchemaPat = NULL;
- m_bFreeHandle = sal_True;
::rtl::OString aPKQ,aPKO,aPKN;
if ( catalog.hasValue() )
diff --git a/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx
b/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx
index e6e7f03..42d0348 100644
--- a/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx
+++ b/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx
@@ -66,7 +66,7 @@ namespace connectivity
::std::map<sal_Int32, ::connectivity::TInt2StringMap > m_aIntValueRange;
::std::map<sal_Int32,SWORD> m_aODBCColumnTypes;
- SQLHANDLE
m_aStatementHandle;
+ SQLHANDLE
m_aStatementHandle; // ... until freed
SQLHANDLE
m_aConnectionHandle;
::com::sun::star::uno::WeakReferenceHelper
m_aStatement;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData>
m_xMetaData;
@@ -79,7 +79,6 @@ namespace connectivity
SQLRETURN m_nCurrentFetchState;
sal_Bool m_bWasNull;
sal_Bool m_bEOF; // after last
record
- sal_Bool m_bFreeHandle;
// set the columncount of the driver
void checkColumnCount();
--
1.7.4.1
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.