[Libreoffice-commits] core.git: connectivity/source
Noel Grandin
noel at peralex.com
Thu Jun 9 09:46:14 UTC 2016
connectivity/source/cpool/ZDriverWrapper.cxx | 11 -
connectivity/source/cpool/ZDriverWrapper.hxx | 4
connectivity/source/cpool/ZPoolCollection.cxx | 14 -
connectivity/source/cpool/ZPoolCollection.hxx | 3
connectivity/source/drivers/dbase/DResultSet.cxx | 4
connectivity/source/drivers/file/FPreparedStatement.cxx | 6
connectivity/source/drivers/file/FResultSet.cxx | 48 ++---
connectivity/source/drivers/file/FStatement.cxx | 27 ---
connectivity/source/drivers/jdbc/JStatement.cxx | 19 --
connectivity/source/drivers/jdbc/PreparedStatement.cxx | 2
connectivity/source/drivers/mork/MPreparedStatement.cxx | 2
connectivity/source/drivers/mork/MStatement.cxx | 7
connectivity/source/drivers/mork/MStatement.hxx | 4
connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx | 81 +++++-----
connectivity/source/drivers/odbc/OPreparedStatement.cxx | 10 -
connectivity/source/drivers/odbc/OStatement.cxx | 18 --
connectivity/source/inc/file/FResultSet.hxx | 2
connectivity/source/inc/file/FStatement.hxx | 6
connectivity/source/inc/java/sql/JStatement.hxx | 2
connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx | 2
connectivity/source/inc/odbc/OStatement.hxx | 4
21 files changed, 118 insertions(+), 158 deletions(-)
New commits:
commit aaebe3c45d3ceac7aba19ad8fd5b1cb621e337b3
Author: Noel Grandin <noel at peralex.com>
Date: Wed Jun 8 11:29:19 2016 +0200
remove some manual ref-counting in connectivity
Change-Id: I0d00b4566c13817b296f237e993f4ce63ef0c664
Reviewed-on: https://gerrit.libreoffice.org/26053
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
diff --git a/connectivity/source/cpool/ZDriverWrapper.cxx b/connectivity/source/cpool/ZDriverWrapper.cxx
index eaf2762..d9df6fc 100644
--- a/connectivity/source/cpool/ZDriverWrapper.cxx
+++ b/connectivity/source/cpool/ZDriverWrapper.cxx
@@ -34,10 +34,7 @@ namespace connectivity
:m_pConnectionPool(_pPool)
{
OSL_ENSURE(_rxAggregateDriver.is(), "ODriverWrapper::ODriverWrapper: invalid aggregate!");
- OSL_ENSURE(m_pConnectionPool, "ODriverWrapper::ODriverWrapper: invalid connection pool!");
-
- if (m_pConnectionPool)
- m_pConnectionPool->acquire();
+ OSL_ENSURE(m_pConnectionPool.is(), "ODriverWrapper::ODriverWrapper: invalid connection pool!");
osl_atomic_increment( &m_refCount );
if (_rxAggregateDriver.is())
@@ -61,10 +58,6 @@ namespace connectivity
{
if (m_xDriverAggregate.is())
m_xDriverAggregate->setDelegator(nullptr);
-
- if (m_pConnectionPool)
- m_pConnectionPool->release();
- m_pConnectionPool = nullptr;
}
@@ -78,7 +71,7 @@ namespace connectivity
Reference< XConnection > SAL_CALL ODriverWrapper::connect( const OUString& url, const Sequence< PropertyValue >& info ) throw (SQLException, RuntimeException, std::exception)
{
Reference< XConnection > xConnection;
- if (m_pConnectionPool)
+ if (m_pConnectionPool.is())
// route this through the pool
xConnection = m_pConnectionPool->getConnectionWithInfo( url, info );
else if (m_xDriver.is())
diff --git a/connectivity/source/cpool/ZDriverWrapper.hxx b/connectivity/source/cpool/ZDriverWrapper.hxx
index baac4ce..da0d39e 100644
--- a/connectivity/source/cpool/ZDriverWrapper.hxx
+++ b/connectivity/source/cpool/ZDriverWrapper.hxx
@@ -23,6 +23,7 @@
#include <com/sun/star/sdbc/XDriver.hpp>
#include <cppuhelper/implbase.hxx>
#include <osl/mutex.hxx>
+#include <rtl/ref.hxx>
#include <com/sun/star/uno/XAggregation.hpp>
@@ -41,7 +42,8 @@ namespace connectivity
m_xDriverAggregate;
css::uno::Reference< css::sdbc::XDriver >
m_xDriver;
- OConnectionPool* m_pConnectionPool;
+ rtl::Reference<OConnectionPool>
+ m_pConnectionPool;
public:
/** creates a new wrapper for a driver
diff --git a/connectivity/source/cpool/ZPoolCollection.cxx b/connectivity/source/cpool/ZPoolCollection.cxx
index f145757..4e4c1e3 100644
--- a/connectivity/source/cpool/ZPoolCollection.cxx
+++ b/connectivity/source/cpool/ZPoolCollection.cxx
@@ -284,11 +284,9 @@ void OPoolCollection::clearConnectionPools(bool _bDispose)
while(aIter != m_aPools.end())
{
aIter->second->clear(_bDispose);
- aIter->second->release();
- OUString sKeyValue = aIter->first;
++aIter;
- m_aPools.erase(sKeyValue);
}
+ m_aPools.clear();
}
OConnectionPool* OPoolCollection::getConnectionPool(const OUString& _sImplName,
@@ -298,16 +296,15 @@ OConnectionPool* OPoolCollection::getConnectionPool(const OUString& _sImplName,
OConnectionPool *pRet = nullptr;
OConnectionPools::const_iterator aFind = m_aPools.find(_sImplName);
if (aFind != m_aPools.end())
- pRet = aFind->second;
+ pRet = aFind->second.get();
else if (_xDriver.is() && _xDriverNode.is())
{
Reference<XPropertySet> xProp(_xDriverNode,UNO_QUERY);
if(xProp.is())
xProp->addPropertyChangeListener(getEnableNodeName(),this);
OConnectionPool* pConnectionPool = new OConnectionPool(_xDriver,_xDriverNode,m_xProxyFactory);
- pConnectionPool->acquire();
aFind = m_aPools.insert(OConnectionPools::value_type(_sImplName,pConnectionPool)).first;
- pRet = aFind->second;
+ pRet = aFind->second.get();
}
OSL_ENSURE(pRet, "Could not query DriverManager from ConnectionPool!");
@@ -456,10 +453,8 @@ void SAL_CALL OPoolCollection::propertyChange( const css::beans::PropertyChangeE
for(;aIter != m_aPools.end();++aIter)
{
aIter->second->clear(false);
- aIter->second->release();
}
m_aPools.clear();
- m_aPools = OConnectionPools();
}
}
else if(evt.Source.is())
@@ -484,10 +479,9 @@ void SAL_CALL OPoolCollection::propertyChange( const css::beans::PropertyChangeE
// 2nd clear the connectionpool
OConnectionPools::iterator aFind = m_aPools.find(sThisDriverName);
- if(aFind != m_aPools.end() && aFind->second)
+ if(aFind != m_aPools.end())
{
aFind->second->clear(false);
- aFind->second->release();
m_aPools.erase(aFind);
}
}
diff --git a/connectivity/source/cpool/ZPoolCollection.hxx b/connectivity/source/cpool/ZPoolCollection.hxx
index 865e6b0..ff31c6c 100644
--- a/connectivity/source/cpool/ZPoolCollection.hxx
+++ b/connectivity/source/cpool/ZPoolCollection.hxx
@@ -39,6 +39,7 @@
#include <com/sun/star/reflection/XProxyFactory.hpp>
#include <comphelper/stl_types.hxx>
#include <osl/mutex.hxx>
+#include <rtl/ref.hxx>
namespace connectivity
{
@@ -59,7 +60,7 @@ namespace connectivity
typedef ::comphelper::OInterfaceCompare< css::sdbc::XDriver > ODriverCompare;
- typedef std::map<OUString, OConnectionPool*> OConnectionPools;
+ typedef std::map<OUString, rtl::Reference<OConnectionPool>> OConnectionPools;
typedef std::map<
css::uno::Reference< css::sdbc::XDriver >,
diff --git a/connectivity/source/drivers/dbase/DResultSet.cxx b/connectivity/source/drivers/dbase/DResultSet.cxx
index 71b638a..a93fde6 100644
--- a/connectivity/source/drivers/dbase/DResultSet.cxx
+++ b/connectivity/source/drivers/dbase/DResultSet.cxx
@@ -94,14 +94,14 @@ sal_Bool SAL_CALL ODbaseResultSet::moveToBookmark( const Any& bookmark ) throw(
m_bRowDeleted = m_bRowInserted = m_bRowUpdated = false;
- return m_pTable && Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),true);
+ return m_pTable.is() && Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),true);
}
sal_Bool SAL_CALL ODbaseResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException, std::exception)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
- if(!m_pTable)
+ if(!m_pTable.is())
return false;
diff --git a/connectivity/source/drivers/file/FPreparedStatement.cxx b/connectivity/source/drivers/file/FPreparedStatement.cxx
index bf8e38b..20bb0ee 100644
--- a/connectivity/source/drivers/file/FPreparedStatement.cxx
+++ b/connectivity/source/drivers/file/FPreparedStatement.cxx
@@ -134,8 +134,8 @@ Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) thr
if(!m_xMetaData.is())
- m_xMetaData = new OResultSetMetaData(m_aSQLIterator.getSelectColumns(),m_aSQLIterator.getTables().begin()->first,m_pTable);
- return m_xMetaData;
+ m_xMetaData = new OResultSetMetaData(m_aSQLIterator.getSelectColumns(),m_aSQLIterator.getTables().begin()->first,m_pTable.get());
+ return m_xMetaData.get();
}
@@ -191,7 +191,7 @@ Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQ
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
- return Reference< XConnection >(m_pConnection);
+ return Reference< XConnection >(m_pConnection.get());
}
diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx
index 0a5ffb0..f50835c 100644
--- a/connectivity/source/drivers/file/FResultSet.cxx
+++ b/connectivity/source/drivers/file/FResultSet.cxx
@@ -80,7 +80,6 @@ OResultSet::OResultSet(OStatement_Base* pStmt,OSQLParseTreeIterator& _aSQLIte
,m_aSkipDeletedSet(this)
,m_pFileSet(nullptr)
,m_pSortIndex(nullptr)
- ,m_pTable(nullptr)
,m_pParseTree(pStmt->getParseTree())
,m_pSQLAnalyzer(nullptr)
,m_aSQLIterator(_aSQLIterator)
@@ -147,14 +146,10 @@ void OResultSet::disposing()
m_xParamColumns = nullptr;
m_xColsIdx.clear();
- Reference<XComponent> xComp = m_pTable;
+ Reference<XComponent> xComp = m_pTable.get();
if ( xComp.is() )
xComp->removeEventListener(this);
- if(m_pTable)
- {
- m_pTable->release();
- m_pTable = nullptr;
- }
+ m_pTable.clear();
m_pFileSet = nullptr;
DELETEZ(m_pSortIndex);
@@ -301,7 +296,7 @@ Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLEx
if(!m_xMetaData.is())
- m_xMetaData = new OResultSetMetaData(m_xColumns,m_aSQLIterator.getTables().begin()->first,m_pTable);
+ m_xMetaData = new OResultSetMetaData(m_xColumns,m_aSQLIterator.getTables().begin()->first,m_pTable.get());
return m_xMetaData;
}
@@ -414,7 +409,7 @@ sal_Bool SAL_CALL OResultSet::first( ) throw(SQLException, RuntimeException, st
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
- return m_pTable && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::FIRST,1,true);
+ return m_pTable.is() && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::FIRST,1,true);
}
@@ -423,28 +418,28 @@ sal_Bool SAL_CALL OResultSet::last( ) throw(SQLException, RuntimeException, std
// here I know definitely that I stand on the last record
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
- return m_pTable && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::LAST,1,true);
+ return m_pTable.is() && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::LAST,1,true);
}
sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException, std::exception)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
- return m_pTable && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::ABSOLUTE1,row,true);
+ return m_pTable.is() && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::ABSOLUTE1,row,true);
}
sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException, std::exception)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
- return m_pTable && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::RELATIVE1,row,true);
+ return m_pTable.is() && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::RELATIVE1,row,true);
}
sal_Bool SAL_CALL OResultSet::previous( ) throw(SQLException, RuntimeException, std::exception)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
- return m_pTable && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::PRIOR,0,true);
+ return m_pTable.is() && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::PRIOR,0,true);
}
Reference< XInterface > SAL_CALL OResultSet::getStatement( ) throw(SQLException, RuntimeException, std::exception)
@@ -498,7 +493,7 @@ sal_Bool SAL_CALL OResultSet::next( ) throw(SQLException, RuntimeException, std
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
- return m_pTable && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::NEXT,1,true);
+ return m_pTable.is() && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::NEXT,1,true);
}
@@ -530,7 +525,7 @@ void SAL_CALL OResultSet::insertRow( ) throw(SQLException, RuntimeException, st
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
- if(!m_bInserted || !m_pTable)
+ if(!m_bInserted || !m_pTable.is())
throwFunctionSequenceException(*this);
// we know that we append new rows at the end
@@ -553,7 +548,7 @@ void SAL_CALL OResultSet::updateRow( ) throw(SQLException, RuntimeException, st
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
- if(!m_pTable || m_pTable->isReadOnly())
+ if(!m_pTable.is() || m_pTable->isReadOnly())
lcl_throwError(STR_TABLE_READONLY,*this);
m_bRowUpdated = m_pTable->UpdateRow(*m_aInsertRow, m_aRow,m_xColsIdx);
@@ -567,8 +562,7 @@ void SAL_CALL OResultSet::deleteRow() throw(SQLException, RuntimeException, std:
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-
- if(!m_pTable || m_pTable->isReadOnly())
+ if(!m_pTable.is() || m_pTable->isReadOnly())
lcl_throwError(STR_TABLE_READONLY,*this);
if (m_bShowDeleted)
lcl_throwError(STR_DELETE_ROW,*this);
@@ -613,7 +607,7 @@ void SAL_CALL OResultSet::moveToInsertRow( ) throw(SQLException, RuntimeExcepti
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
- if(!m_pTable || m_pTable->isReadOnly())
+ if(!m_pTable.is() || m_pTable->isReadOnly())
lcl_throwError(STR_TABLE_READONLY,*this);
m_bInserted = true;
@@ -777,7 +771,7 @@ bool OResultSet::ExecuteRow(IResultSetHelper::Movement eFirstCursorPosition,
IResultSetHelper::Movement eCursorPosition = eFirstCursorPosition;
sal_Int32 nOffset = nFirstOffset;
- if (!m_pTable)
+ if (!m_pTable.is())
return false;
const OSQLColumns & rTableCols = *(m_pTable->getTableColumns());
@@ -791,7 +785,7 @@ again:
return false;
}
- if (!m_pTable || !m_pTable->seekRow(eCursorPosition, nOffset, m_nFilePos))
+ if (!m_pTable.is() || !m_pTable->seekRow(eCursorPosition, nOffset, m_nFilePos))
{
return false;
}
@@ -1180,7 +1174,7 @@ void OResultSet::sortRows()
bool OResultSet::OpenImpl()
{
OSL_ENSURE(m_pSQLAnalyzer,"No analyzer set with setSqlAnalyzer!");
- if(!m_pTable)
+ if(!m_pTable.is())
{
const OSQLTables& rTabs = m_aSQLIterator.getTables();
if (rTabs.empty() || !rTabs.begin()->second.is())
@@ -1570,8 +1564,7 @@ void OResultSet::doTableSpecials(const OSQLTable& _xTable)
{
Reference<css::lang::XUnoTunnel> xTunnel(_xTable, UNO_QUERY_THROW);
m_pTable = reinterpret_cast< OFileTable* >(xTunnel->getSomething(OFileTable::getUnoTunnelImplementationId()));
- assert(m_pTable);
- m_pTable->acquire();
+ assert(m_pTable.is());
}
void OResultSet::clearInsertRow()
@@ -1624,11 +1617,10 @@ bool OResultSet::isRowDeleted() const
void SAL_CALL OResultSet::disposing( const EventObject& Source ) throw (RuntimeException, std::exception)
{
- Reference<XPropertySet> xProp = m_pTable;
- if(m_pTable && Source.Source == xProp)
+ Reference<XPropertySet> xProp = m_pTable.get();
+ if(m_pTable.is() && Source.Source == xProp)
{
- m_pTable->release();
- m_pTable = nullptr;
+ m_pTable.clear();
}
}
diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx
index 287c4fb..002f5fd 100644
--- a/connectivity/source/drivers/file/FStatement.cxx
+++ b/connectivity/source/drivers/file/FStatement.cxx
@@ -60,7 +60,6 @@ OStatement_Base::OStatement_Base(OConnection* _pConnection )
,m_pConnection(_pConnection)
,m_pParseTree(nullptr)
,m_pSQLAnalyzer(nullptr)
- ,m_pTable(nullptr)
,m_nMaxFieldSize(0)
,m_nMaxRows(0)
,m_nQueryTimeOut(0)
@@ -70,8 +69,6 @@ OStatement_Base::OStatement_Base(OConnection* _pConnection )
,m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE)
,m_bEscapeProcessing(true)
{
- m_pConnection->acquire();
-
sal_Int32 nAttrib = 0;
registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME), PROPERTY_ID_CURSORNAME, nAttrib,&m_aCursorName, ::cppu::UnoType<OUString>::get());
@@ -121,17 +118,9 @@ void OStatement_BASE2::disposing()
m_aSQLIterator.dispose();
- if(m_pTable)
- {
- m_pTable->release();
- m_pTable = nullptr;
- }
+ m_pTable.clear();
- if (m_pConnection)
- {
- m_pConnection->release();
- m_pConnection = nullptr;
- }
+ m_pConnection.clear();
dispose_ChildImpl();
@@ -279,7 +268,7 @@ Reference< XResultSet > SAL_CALL OStatement::executeQuery( const OUString& sql )
Reference< XConnection > SAL_CALL OStatement::getConnection( ) throw(SQLException, RuntimeException, std::exception)
{
- return Reference< XConnection >(m_pConnection);
+ return Reference< XConnection >(m_pConnection.get());
}
sal_Int32 SAL_CALL OStatement::executeUpdate( const OUString& sql ) throw(SQLException, RuntimeException, std::exception)
@@ -321,7 +310,7 @@ Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeExcep
OSQLAnalyzer* OStatement_Base::createAnalyzer()
{
- return new OSQLAnalyzer(m_pConnection);
+ return new OSQLAnalyzer(m_pConnection.get());
}
void OStatement_Base::anylizeSQL()
@@ -424,14 +413,10 @@ void OStatement_Base::construct(const OUString& sql) throw(SQLException, Runtim
Reference< css::lang::XUnoTunnel> xTunnel(rTabs.begin()->second,UNO_QUERY);
if(xTunnel.is())
{
- if(m_pTable)
- m_pTable->release();
m_pTable = reinterpret_cast<OFileTable*>(xTunnel->getSomething(OFileTable::getUnoTunnelImplementationId()));
- if(m_pTable)
- m_pTable->acquire();
}
- OSL_ENSURE(m_pTable,"No table!");
- if ( m_pTable )
+ OSL_ENSURE(m_pTable.is(),"No table!");
+ if ( m_pTable.is() )
m_xColNames = m_pTable->getColumns();
Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY);
// set the binding of the resultrow
diff --git a/connectivity/source/drivers/jdbc/JStatement.cxx b/connectivity/source/drivers/jdbc/JStatement.cxx
index 004d61d..533641d 100644
--- a/connectivity/source/drivers/jdbc/JStatement.cxx
+++ b/connectivity/source/drivers/jdbc/JStatement.cxx
@@ -68,7 +68,6 @@ java_sql_Statement_Base::java_sql_Statement_Base( JNIEnv * pEnv, java_sql_Connec
,m_nResultSetType(ResultSetType::FORWARD_ONLY)
,m_bEscapeProcessing(true)
{
- m_pConnection->acquire();
}
@@ -88,9 +87,7 @@ void SAL_CALL OStatement_BASE2::disposing()
}
::comphelper::disposeComponent(m_xGeneratedStatement);
- if (m_pConnection)
- m_pConnection->release();
- m_pConnection = nullptr;
+ m_pConnection.clear();
dispose_ChildImpl();
java_sql_Statement_Base::disposing();
@@ -120,7 +117,7 @@ void SAL_CALL OStatement_BASE2::release() throw()
Any SAL_CALL java_sql_Statement_Base::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
{
- if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() && rType == cppu::UnoType<XGeneratedResultSet>::get())
+ if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() && rType == cppu::UnoType<XGeneratedResultSet>::get())
return Any();
Any aRet( java_sql_Statement_BASE::queryInterface(rType) );
return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType);
@@ -133,7 +130,7 @@ Sequence< Type > SAL_CALL java_sql_Statement_Base::getTypes( ) throw(RuntimeExc
cppu::UnoType<css::beans::XPropertySet>::get());
Sequence< Type > aOldTypes = java_sql_Statement_BASE::getTypes();
- if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() )
+ if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() )
{
::std::remove(aOldTypes.getArray(),aOldTypes.getArray() + aOldTypes.getLength(),
cppu::UnoType<XGeneratedResultSet>::get());
@@ -166,8 +163,8 @@ Reference< XResultSet > SAL_CALL java_sql_Statement_Base::getGeneratedValues( )
Reference< XResultSet > xRes;
if ( !out )
{
- OSL_ENSURE( m_pConnection && m_pConnection->isAutoRetrievingEnabled(),"Illegal call here. isAutoRetrievingEnabled is false!");
- if ( m_pConnection )
+ OSL_ENSURE( m_pConnection.is() && m_pConnection->isAutoRetrievingEnabled(),"Illegal call here. isAutoRetrievingEnabled is false!");
+ if ( m_pConnection.is() )
{
OUString sStmt = m_pConnection->getTransformedGeneratedStatement(m_sSqlStatement);
if ( !sStmt.isEmpty() )
@@ -238,7 +235,7 @@ sal_Bool SAL_CALL java_sql_Statement_Base::execute( const OUString& sql ) throw(
jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) );
{
jdbc::ContextClassLoaderScope ccl( t.env(),
- m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
+ m_pConnection.is() ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
m_aLogger,
*this
);
@@ -273,7 +270,7 @@ Reference< XResultSet > SAL_CALL java_sql_Statement_Base::executeQuery( const OU
jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) );
{
jdbc::ContextClassLoaderScope ccl( t.env(),
- m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
+ m_pConnection.is() ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
m_aLogger,
*this
);
@@ -290,7 +287,7 @@ Reference< XConnection > SAL_CALL java_sql_Statement_Base::getConnection( ) thr
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- return Reference< XConnection >(m_pConnection);
+ return Reference< XConnection >(m_pConnection.get());
}
diff --git a/connectivity/source/drivers/jdbc/PreparedStatement.cxx b/connectivity/source/drivers/jdbc/PreparedStatement.cxx
index 98e13883..1762c62 100644
--- a/connectivity/source/drivers/jdbc/PreparedStatement.cxx
+++ b/connectivity/source/drivers/jdbc/PreparedStatement.cxx
@@ -142,7 +142,7 @@ void SAL_CALL java_sql_PreparedStatement::setString( sal_Int32 parameterIndex, c
css::uno::Reference< css::sdbc::XConnection > SAL_CALL java_sql_PreparedStatement::getConnection( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception)
{
- return Reference< XConnection >(m_pConnection);
+ return Reference< XConnection >(m_pConnection.get());
}
diff --git a/connectivity/source/drivers/mork/MPreparedStatement.cxx b/connectivity/source/drivers/mork/MPreparedStatement.cxx
index e092f22..5376e0e 100644
--- a/connectivity/source/drivers/mork/MPreparedStatement.cxx
+++ b/connectivity/source/drivers/mork/MPreparedStatement.cxx
@@ -179,7 +179,7 @@ Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQ
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
- return Reference< XConnection >(m_pConnection);
+ return Reference< XConnection >(m_pConnection.get());
}
diff --git a/connectivity/source/drivers/mork/MStatement.cxx b/connectivity/source/drivers/mork/MStatement.cxx
index 3a4279a..1a12d4b 100644
--- a/connectivity/source/drivers/mork/MStatement.cxx
+++ b/connectivity/source/drivers/mork/MStatement.cxx
@@ -69,7 +69,6 @@ OCommonStatement::OCommonStatement(OConnection* _pConnection )
{
m_xDBMetaData = _pConnection->getMetaData();
m_pParseTree = nullptr;
- m_pConnection->acquire();
}
@@ -85,9 +84,7 @@ void OCommonStatement::disposing()
clearWarnings();
clearCachedResultSet();
- if (m_pConnection)
- m_pConnection->release();
- m_pConnection = nullptr;
+ m_pConnection.clear();
m_pSQLIterator->dispose();
delete m_pParseTree;
@@ -276,7 +273,7 @@ Reference< XConnection > SAL_CALL OCommonStatement::getConnection( ) throw(SQLE
checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
// just return our connection here
- return Reference< XConnection >(m_pConnection);
+ return Reference< XConnection >(m_pConnection.get());
}
Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
diff --git a/connectivity/source/drivers/mork/MStatement.hxx b/connectivity/source/drivers/mork/MStatement.hxx
index 0f23533..4f5d375 100644
--- a/connectivity/source/drivers/mork/MStatement.hxx
+++ b/connectivity/source/drivers/mork/MStatement.hxx
@@ -64,7 +64,7 @@ namespace connectivity
// for this Statement
OTable* m_pTable;
- OConnection* m_pConnection; // The owning Connection object
+ rtl::Reference<OConnection> m_pConnection; // The owning Connection object
OValueRow m_aRow;
@@ -130,7 +130,7 @@ namespace connectivity
public:
// other methods
- OConnection* getOwnConnection() const { return m_pConnection;}
+ OConnection* getOwnConnection() const { return m_pConnection.get(); }
explicit OCommonStatement(OConnection* _pConnection );
using OCommonStatement_IBASE::operator css::uno::Reference< css::uno::XInterface >;
diff --git a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx
index 8160b8a1..d10f6c9 100644
--- a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx
+++ b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx
@@ -63,12 +63,11 @@ ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(OConnection* _pConnection
,m_bWasNull(true)
,m_bEOF(false)
{
- OSL_ENSURE(m_pConnection,"ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet: No parent set!");
+ OSL_ENSURE(m_pConnection.is(),"ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet: No parent set!");
if( SQL_NULL_HANDLE == m_aStatementHandle )
throw RuntimeException();
osl_atomic_increment( &m_refCount );
- m_pConnection->acquire();
m_pRowStatusArray = new SQLUSMALLINT[1]; // the default value
osl_atomic_decrement( &m_refCount );
// allocBuffer();
@@ -95,8 +94,8 @@ void ODatabaseMetaDataResultSet::disposing()
m_pConnection->freeStatementHandle(m_aStatementHandle);
m_aStatement = nullptr;
-m_xMetaData.clear();
- m_pConnection->release();
+ m_xMetaData.clear();
+ m_pConnection.clear();
}
Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
@@ -175,7 +174,7 @@ template < typename T, SQLSMALLINT sqlTypeId > T ODatabaseMetaDataResultSet::get
T nVal = 0;
if(columnIndex <= m_nDriverColumnCount)
{
- getValue<T>(m_pConnection, m_aStatementHandle, columnIndex, sqlTypeId, m_bWasNull, **this, nVal);
+ getValue<T>(m_pConnection.get(), m_aStatementHandle, columnIndex, sqlTypeId, m_bWasNull, **this, nVal);
if ( !m_aValueRange.empty() )
{
@@ -220,7 +219,7 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex
case DataType::BIT:
{
sal_Int8 nValue = 0;
- OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_BIT,m_bWasNull,**this,&nValue,sizeof nValue);
+ OTools::getValue(m_pConnection.get(),m_aStatementHandle,columnIndex,SQL_C_BIT,m_bWasNull,**this,&nValue,sizeof nValue);
bRet = nValue != 0;
}
break;
@@ -255,11 +254,11 @@ Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 co
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
{
- OUString aRet = OTools::getStringValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_BINARY,m_bWasNull,**this,m_nTextEncoding);
+ OUString aRet = OTools::getStringValue(m_pConnection.get(),m_aStatementHandle,columnIndex,SQL_C_BINARY,m_bWasNull,**this,m_nTextEncoding);
return Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(aRet.getStr()),sizeof(sal_Unicode)*aRet.getLength());
}
}
- return OTools::getBytesValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_BINARY,m_bWasNull,**this);
+ return OTools::getBytesValue(m_pConnection.get(),m_aStatementHandle,columnIndex,SQL_C_BINARY,m_bWasNull,**this);
}
else
m_bWasNull = true;
@@ -280,7 +279,7 @@ css::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIn
aDate.day = 0;
aDate.month = 0;
aDate.year = 0;
- OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_DATE : SQL_C_TYPE_DATE,m_bWasNull,**this,&aDate,sizeof aDate);
+ OTools::getValue(m_pConnection.get(),m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_DATE : SQL_C_TYPE_DATE,m_bWasNull,**this,&aDate,sizeof aDate);
return Date(aDate.day,aDate.month,aDate.year);
}
else
@@ -299,7 +298,7 @@ double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex ) t
columnIndex = mapColumn(columnIndex);
double nValue(0.0);
if(columnIndex <= m_nDriverColumnCount)
- OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_DOUBLE,m_bWasNull,**this,&nValue,sizeof nValue);
+ OTools::getValue(m_pConnection.get(),m_aStatementHandle,columnIndex,SQL_C_DOUBLE,m_bWasNull,**this,&nValue,sizeof nValue);
else
m_bWasNull = true;
return nValue;
@@ -316,7 +315,7 @@ float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex ) thr
columnIndex = mapColumn(columnIndex);
float nVal(0);
if(columnIndex <= m_nDriverColumnCount)
- OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_FLOAT,m_bWasNull,**this,&nVal,sizeof nVal);
+ OTools::getValue(m_pConnection.get(),m_aStatementHandle,columnIndex,SQL_C_FLOAT,m_bWasNull,**this,&nVal,sizeof nVal);
else
m_bWasNull = true;
return nVal;
@@ -345,7 +344,9 @@ Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData
{
checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
::osl::MutexGuard aGuard( m_aMutex );
- return m_xMetaData.is() ? m_xMetaData : (m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle));
+ if (!m_xMetaData.is())
+ m_xMetaData = new OResultSetMetaData(m_pConnection.get(),m_aStatementHandle);
+ return m_xMetaData;
}
Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
@@ -397,7 +398,7 @@ OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex )
columnIndex = mapColumn(columnIndex);
OUString aVal;
if(columnIndex <= m_nDriverColumnCount)
- aVal = OTools::getStringValue(m_pConnection,m_aStatementHandle,columnIndex,impl_getColumnType_nothrow(columnIndex),m_bWasNull,**this,m_nTextEncoding);
+ aVal = OTools::getStringValue(m_pConnection.get(),m_aStatementHandle,columnIndex,impl_getColumnType_nothrow(columnIndex),m_bWasNull,**this,m_nTextEncoding);
else
m_bWasNull = true;
@@ -415,7 +416,7 @@ css::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIn
columnIndex = mapColumn(columnIndex);
TIME_STRUCT aTime={0,0,0};
if(columnIndex <= m_nDriverColumnCount)
- OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_TIME : SQL_C_TYPE_TIME,m_bWasNull,**this,&aTime,sizeof aTime);
+ OTools::getValue(m_pConnection.get(),m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_TIME : SQL_C_TYPE_TIME,m_bWasNull,**this,&aTime,sizeof aTime);
else
m_bWasNull = true;
return Time(0, aTime.second,aTime.minute,aTime.hour, false);
@@ -432,7 +433,7 @@ css::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32
columnIndex = mapColumn(columnIndex);
TIMESTAMP_STRUCT aTime={0,0,0,0,0,0,0};
if(columnIndex <= m_nDriverColumnCount)
- OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_TIMESTAMP : SQL_C_TYPE_TIMESTAMP, m_bWasNull, **this, &aTime, sizeof aTime);
+ OTools::getValue(m_pConnection.get(),m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_TIMESTAMP : SQL_C_TYPE_TIMESTAMP, m_bWasNull, **this, &aTime, sizeof aTime);
else
m_bWasNull = true;
return DateTime(aTime.fraction, aTime.second, aTime.minute, aTime.hour,
@@ -515,7 +516,7 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first( ) throw(SQLException, Runt
m_bEOF = false;
m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_FIRST,0);
- OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
bool bRet = ( m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO );
if( bRet )
m_nRowPos = 1;
@@ -530,7 +531,7 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last( ) throw(SQLException, Runti
m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_LAST,0);
- OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
// here I know definitely that I stand on the last record
bool bRet = ( m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO );
if( bRet )
@@ -547,7 +548,7 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 row ) throw(SQ
m_bEOF = false;
m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_ABSOLUTE,row);
- OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
if(bRet)
m_nRowPos = row;
@@ -563,7 +564,7 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 row ) throw(SQ
m_bEOF = false;
m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,row);
- OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
if(bRet)
m_nRowPos += row;
@@ -579,7 +580,7 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous( ) throw(SQLException, R
m_bEOF = false;
m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
- OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
if(bRet)
--m_nRowPos;
@@ -646,7 +647,7 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next( ) throw(SQLException, Runti
SQLRETURN nOldFetchStatus = m_nCurrentFetchState;
// m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_NEXT,0);
m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
- OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
if(bRet || ( m_nCurrentFetchState == SQL_NO_DATA && nOldFetchStatus != SQL_NO_DATA ) )
++m_nRowPos;
@@ -827,7 +828,7 @@ void ODatabaseMetaDataResultSet::openTypeInfo() throw(SQLException, RuntimeExcep
m_aValueRange[2] = aMap;
- OTools::ThrowException(m_pConnection,N3SQLGetTypeInfo(m_aStatementHandle, SQL_ALL_TYPES),m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),N3SQLGetTypeInfo(m_aStatementHandle, SQL_ALL_TYPES),m_aStatementHandle,SQL_HANDLE_STMT,*this);
checkColumnCount();
}
@@ -875,7 +876,7 @@ void ODatabaseMetaDataResultSet::openTables(const Any& catalog, const OUString&
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKO)), pPKO ? SQL_NTS : 0,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKN)), SQL_NTS,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pCOL)), pCOL ? SQL_NTS : 0);
- OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
checkColumnCount();
}
@@ -887,12 +888,12 @@ void ODatabaseMetaDataResultSet::openTablesTypes( ) throw(SQLException, RuntimeE
nullptr,0,
nullptr,0,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(SQL_ALL_TABLE_TYPES)),SQL_NTS);
- OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
m_aColMapping.clear();
m_aColMapping.push_back(-1);
m_aColMapping.push_back(4);
- m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle,m_aColMapping);
+ m_xMetaData = new OResultSetMetaData(m_pConnection.get(),m_aStatementHandle,m_aColMapping);
checkColumnCount();
}
@@ -904,12 +905,12 @@ void ODatabaseMetaDataResultSet::openCatalogs() throw(SQLException, RuntimeExcep
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>("")),SQL_NTS,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>("")),SQL_NTS);
- OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
m_aColMapping.clear();
m_aColMapping.push_back(-1);
m_aColMapping.push_back(1);
- m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle,m_aColMapping);
+ m_xMetaData = new OResultSetMetaData(m_pConnection.get(),m_aStatementHandle,m_aColMapping);
checkColumnCount();
}
@@ -920,12 +921,12 @@ void ODatabaseMetaDataResultSet::openSchemas() throw(SQLException, RuntimeExcept
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(SQL_ALL_SCHEMAS)),SQL_NTS,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>("")),SQL_NTS,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>("")),SQL_NTS);
- OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
m_aColMapping.clear();
m_aColMapping.push_back(-1);
m_aColMapping.push_back(2);
- m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle,m_aColMapping);
+ m_xMetaData = new OResultSetMetaData(m_pConnection.get(),m_aStatementHandle,m_aColMapping);
checkColumnCount();
}
@@ -959,7 +960,7 @@ void ODatabaseMetaDataResultSet::openColumnPrivileges( const Any& catalog, cons
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKO)), pPKO ? SQL_NTS : 0 ,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKN)), SQL_NTS,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pCOL)), SQL_NTS);
- OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
checkColumnCount();
}
@@ -994,7 +995,7 @@ void ODatabaseMetaDataResultSet::openColumns( const Any& catalog,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKN)), SQL_NTS,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pCOL)), SQL_NTS);
- OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
TInt2IntMap aMap;
aMap[SQL_BIT] = DataType::BIT;
aMap[SQL_TINYINT] = DataType::TINYINT;
@@ -1062,7 +1063,7 @@ void ODatabaseMetaDataResultSet::openProcedureColumns( const Any& catalog,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKN)), SQL_NTS,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pCOL)), SQL_NTS);
- OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
checkColumnCount();
}
@@ -1093,7 +1094,7 @@ void ODatabaseMetaDataResultSet::openProcedures(const Any& catalog, const OUStri
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKQ)), (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKO)), pPKO ? SQL_NTS : 0 ,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKN)), SQL_NTS);
- OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
checkColumnCount();
}
@@ -1138,7 +1139,7 @@ void ODatabaseMetaDataResultSet::openSpecialColumns(bool _bRowVer,const Any& cat
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKN)), SQL_NTS,
(SQLSMALLINT)scope,
nullable ? SQL_NULLABLE : SQL_NO_NULLS);
- OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
checkColumnCount();
}
@@ -1181,7 +1182,7 @@ void ODatabaseMetaDataResultSet::openForeignKeys( const Any& catalog, const OUSt
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pFKO)), pFKO ? SQL_NTS : 0,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pFKN)), SQL_NTS
);
- OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
checkColumnCount();
}
@@ -1223,7 +1224,7 @@ void ODatabaseMetaDataResultSet::openPrimaryKeys(const Any& catalog, const OUStr
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKQ)), (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKO)), pPKO ? SQL_NTS : 0 ,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKN)), SQL_NTS);
- OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
checkColumnCount();
}
@@ -1252,7 +1253,7 @@ void ODatabaseMetaDataResultSet::openTablePrivileges(const Any& catalog, const O
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKQ)), (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKO)), pPKO ? SQL_NTS : 0 ,
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKN)), SQL_NTS);
- OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
checkColumnCount();
}
@@ -1284,14 +1285,14 @@ void ODatabaseMetaDataResultSet::openIndexInfo( const Any& catalog, const OUStri
reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKN)), SQL_NTS,
unique ? SQL_INDEX_UNIQUE : SQL_INDEX_ALL,
approximate ? 1 : 0);
- OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
checkColumnCount();
}
void ODatabaseMetaDataResultSet::checkColumnCount()
{
sal_Int16 nNumResultCols=0;
- OTools::ThrowException(m_pConnection,N3SQLNumResultCols(m_aStatementHandle,&nNumResultCols),m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),N3SQLNumResultCols(m_aStatementHandle,&nNumResultCols),m_aStatementHandle,SQL_HANDLE_STMT,*this);
m_nDriverColumnCount = nNumResultCols;
}
@@ -1300,7 +1301,7 @@ SWORD ODatabaseMetaDataResultSet::impl_getColumnType_nothrow(sal_Int32 columnInd
{
::std::map<sal_Int32,SWORD>::iterator aFind = m_aODBCColumnTypes.find(columnIndex);
if ( aFind == m_aODBCColumnTypes.end() )
- aFind = m_aODBCColumnTypes.insert(::std::map<sal_Int32,SWORD>::value_type(columnIndex,OResultSetMetaData::getColumnODBCType(m_pConnection,m_aStatementHandle,*this,columnIndex))).first;
+ aFind = m_aODBCColumnTypes.insert(::std::map<sal_Int32,SWORD>::value_type(columnIndex,OResultSetMetaData::getColumnODBCType(m_pConnection.get(),m_aStatementHandle,*this,columnIndex))).first;
return aFind->second;
}
diff --git a/connectivity/source/drivers/odbc/OPreparedStatement.cxx b/connectivity/source/drivers/odbc/OPreparedStatement.cxx
index 3ed72e2..6b33d55 100644
--- a/connectivity/source/drivers/odbc/OPreparedStatement.cxx
+++ b/connectivity/source/drivers/odbc/OPreparedStatement.cxx
@@ -171,7 +171,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute( ) throw(SQLException, RuntimeExc
{
SQLRETURN nReturn = N3SQLExecute(m_aStatementHandle);
- OTools::ThrowException(m_pConnection,nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this);
bool needData = nReturn == SQL_NEED_DATA;
// Now loop while more data is needed (i.e. a data-at-
@@ -247,7 +247,7 @@ Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQ
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
- return Reference< XConnection >(m_pConnection);
+ return Reference< XConnection >(m_pConnection.get());
}
@@ -409,7 +409,7 @@ void OPreparedStatement::setParameter(const sal_Int32 parameterIndex, const sal_
_nDataAllocLen,
&rDataLen);
- OTools::ThrowException(m_pConnection, nRetcode, m_aStatementHandle, SQL_HANDLE_STMT, *this);
+ OTools::ThrowException(m_pConnection.get(), nRetcode, m_aStatementHandle, SQL_HANDLE_STMT, *this);
}
void SAL_CALL OPreparedStatement::setByte( const sal_Int32 parameterIndex, const sal_Int8 x ) throw(SQLException, RuntimeException, std::exception)
@@ -546,7 +546,7 @@ void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, const sal_I
0,
lenBuf
);
- OTools::ThrowException(m_pConnection,nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this);
}
@@ -917,7 +917,7 @@ void OPreparedStatement::prepareStatement()
OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
OString aSql(OUStringToOString(m_sSqlStatement,getOwnConnection()->getTextEncoding()));
SQLRETURN nReturn = N3SQLPrepare(m_aStatementHandle, reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(aSql.getStr())), aSql.getLength());
- OTools::ThrowException(m_pConnection,nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ OTools::ThrowException(m_pConnection.get(),nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this);
m_bPrepared = true;
initBoundParam();
}
diff --git a/connectivity/source/drivers/odbc/OStatement.cxx b/connectivity/source/drivers/odbc/OStatement.cxx
index 9d8c710..1e8fbaa 100644
--- a/connectivity/source/drivers/odbc/OStatement.cxx
+++ b/connectivity/source/drivers/odbc/OStatement.cxx
@@ -41,7 +41,7 @@
using namespace ::comphelper;
#define THROW_SQL(x) \
- OTools::ThrowException(m_pConnection,x,m_aStatementHandle,SQL_HANDLE_STMT,*this)
+ OTools::ThrowException(m_pConnection.get(),x,m_aStatementHandle,SQL_HANDLE_STMT,*this)
using namespace connectivity::odbc;
@@ -63,7 +63,6 @@ OStatement_Base::OStatement_Base(OConnection* _pConnection )
,m_pRowStatusArray(nullptr)
{
osl_atomic_increment( &m_refCount );
- m_pConnection->acquire();
m_aStatementHandle = m_pConnection->createStatementHandle();
//setMaxFieldSize(0);
@@ -101,11 +100,10 @@ void SAL_CALL OStatement_Base::disposing()
::comphelper::disposeComponent(m_xGeneratedStatement);
OSL_ENSURE(m_aStatementHandle,"OStatement_BASE2::disposing: StatementHandle is null!");
- if (m_pConnection)
+ if (m_pConnection.is())
{
m_pConnection->freeStatementHandle(m_aStatementHandle);
- m_pConnection->release();
- m_pConnection = nullptr;
+ m_pConnection.clear();
}
OSL_ENSURE(!m_aStatementHandle,"Sohould ne null here!");
@@ -127,7 +125,7 @@ void SAL_CALL OStatement_BASE2::release() throw()
Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
{
- if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() && rType == cppu::UnoType<XGeneratedResultSet>::get())
+ if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() && rType == cppu::UnoType<XGeneratedResultSet>::get())
return Any();
Any aRet = OStatement_BASE::queryInterface(rType);
return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType);
@@ -139,7 +137,7 @@ Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) throw(RuntimeException,
cppu::UnoType<XFastPropertySet>::get(),
cppu::UnoType<XPropertySet>::get());
Sequence< Type > aOldTypes = OStatement_BASE::getTypes();
- if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() )
+ if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() )
{
::std::remove(aOldTypes.getArray(),aOldTypes.getArray() + aOldTypes.getLength(),
cppu::UnoType<XGeneratedResultSet>::get());
@@ -151,9 +149,9 @@ Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) throw(RuntimeException,
Reference< XResultSet > SAL_CALL OStatement_Base::getGeneratedValues( ) throw (SQLException, RuntimeException, std::exception)
{
- OSL_ENSURE( m_pConnection && m_pConnection->isAutoRetrievingEnabled(),"Illegal call here. isAutoRetrievingEnabled is false!");
+ OSL_ENSURE( m_pConnection.is() && m_pConnection->isAutoRetrievingEnabled(),"Illegal call here. isAutoRetrievingEnabled is false!");
Reference< XResultSet > xRes;
- if ( m_pConnection )
+ if ( m_pConnection.is() )
{
OUString sStmt = m_pConnection->getTransformedGeneratedStatement(m_sSqlStatement);
if ( !sStmt.isEmpty() )
@@ -465,7 +463,7 @@ Reference< XConnection > SAL_CALL OStatement_Base::getConnection( ) throw(SQLEx
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
- return Reference< XConnection >(m_pConnection);
+ return Reference< XConnection >(m_pConnection.get());
}
diff --git a/connectivity/source/inc/file/FResultSet.hxx b/connectivity/source/inc/file/FResultSet.hxx
index dcd50d9..ea2a6da 100644
--- a/connectivity/source/inc/file/FResultSet.hxx
+++ b/connectivity/source/inc/file/FResultSet.hxx
@@ -90,7 +90,7 @@ namespace connectivity
OSortIndex* m_pSortIndex;
::rtl::Reference<connectivity::OSQLColumns> m_xColumns; // this are the select columns
::rtl::Reference<connectivity::OSQLColumns> m_xParamColumns;
- OFileTable* m_pTable;
+ rtl::Reference<OFileTable> m_pTable;
connectivity::OSQLParseNode* m_pParseTree;
OSQLAnalyzer* m_pSQLAnalyzer;
diff --git a/connectivity/source/inc/file/FStatement.hxx b/connectivity/source/inc/file/FStatement.hxx
index 5a380bd..8e6c9fb 100644
--- a/connectivity/source/inc/file/FStatement.hxx
+++ b/connectivity/source/inc/file/FStatement.hxx
@@ -76,11 +76,11 @@ namespace connectivity
connectivity::OSQLParser m_aParser;
connectivity::OSQLParseTreeIterator m_aSQLIterator;
- OConnection* m_pConnection;// The owning Connection object
+ rtl::Reference<OConnection> m_pConnection;// The owning Connection object
connectivity::OSQLParseNode* m_pParseTree;
OSQLAnalyzer* m_pSQLAnalyzer; //the sql analyzer used by the resultset
- OFileTable* m_pTable; // the current table
+ rtl::Reference<OFileTable> m_pTable; // the current table
OValueRefRow m_aSelectRow;
OValueRefRow m_aRow;
OValueRefRow m_aEvaluateRow; // contains all values of a row
@@ -133,7 +133,7 @@ namespace connectivity
OStatement_Base(OConnection* _pConnection );
- OConnection* getOwnConnection() const { return m_pConnection;}
+ OConnection* getOwnConnection() const { return m_pConnection.get(); }
using OStatement_BASE::operator css::uno::Reference< css::uno::XInterface >;
diff --git a/connectivity/source/inc/java/sql/JStatement.hxx b/connectivity/source/inc/java/sql/JStatement.hxx
index ba027eb..e8292e4 100644
--- a/connectivity/source/inc/java/sql/JStatement.hxx
+++ b/connectivity/source/inc/java/sql/JStatement.hxx
@@ -79,7 +79,7 @@ namespace connectivity
protected:
css::uno::Reference< css::sdbc::XStatement> m_xGeneratedStatement;
- java_sql_Connection* m_pConnection;
+ rtl::Reference<java_sql_Connection> m_pConnection;
java::sql::ConnectionLog m_aLogger;
OUString m_sSqlStatement;
// Properties
diff --git a/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx b/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx
index 84f5bdc4..5747144 100644
--- a/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx
+++ b/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx
@@ -73,7 +73,7 @@ namespace connectivity
css::uno::Reference< css::sdbc::XResultSetMetaData>
m_xMetaData;
SQLUSMALLINT* m_pRowStatusArray;
- OConnection* m_pConnection;
+ rtl::Reference<OConnection> m_pConnection;
rtl_TextEncoding m_nTextEncoding;
sal_Int32 m_nRowPos;
sal_Int32 m_nDriverColumnCount; // column count of the driver which can sometimes be less than the metadata count
diff --git a/connectivity/source/inc/odbc/OStatement.hxx b/connectivity/source/inc/odbc/OStatement.hxx
index 8b60b3b..3138a27 100644
--- a/connectivity/source/inc/odbc/OStatement.hxx
+++ b/connectivity/source/inc/odbc/OStatement.hxx
@@ -71,7 +71,7 @@ namespace connectivity
::std::list< OUString> m_aBatchList;
OUString m_sSqlStatement;
- OConnection* m_pConnection;// The owning Connection object
+ rtl::Reference<OConnection> m_pConnection;// The owning Connection object
SQLHANDLE m_aStatementHandle;
SQLUSMALLINT* m_pRowStatusArray;
@@ -188,7 +188,7 @@ namespace connectivity
// other methods
SQLHANDLE getConnectionHandle() { return m_pConnection->getConnection(); }
- OConnection* getOwnConnection() const { return m_pConnection;}
+ OConnection* getOwnConnection() const { return m_pConnection.get();}
/** getCursorProperties return the properties for a specific cursor type
@param _nCursorType the CursorType
@param bFirst when true the first property set is returned
More information about the Libreoffice-commits
mailing list