diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-08-07 18:10:20 +0100 |
---|---|---|
committer | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-08-07 18:23:37 +0100 |
commit | ebe37593c53f9fbad0e9a798834db10fc19b7479 (patch) | |
tree | 89308d48989d5017a0b003091b0a55c5dfbdbc0c /connectivity/source | |
parent | eb5e9ab4c4d6a00be96f6db760c2c64ca061e426 (diff) |
Clean up ResultSet management. (firebird-sdbc)
Change-Id: I00cd0aa08a5a3da17f06933ebc3422a6b4b8bc74
Diffstat (limited to 'connectivity/source')
4 files changed, 20 insertions, 26 deletions
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx index 55bba8cb7fdd..f391618f3333 100644 --- a/connectivity/source/drivers/firebird/PreparedStatement.cxx +++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx @@ -258,6 +258,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute() MutexGuard aGuard( m_pConnection->getMutex() ); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); + ensurePrepared(); ISC_STATUS aErr; @@ -273,9 +274,12 @@ sal_Bool SAL_CALL OPreparedStatement::execute() evaluateStatusVector(m_statusVector, "isc_dsql_execute", *this); } - // TODO: check we actually got results -- ? + m_xResultSet = new OResultSet(m_pConnection, + uno::Reference< XInterface >(*this), + m_statementHandle, + m_pOutSqlda); - return sal_True; + return m_xResultSet.is(); // TODO: implement handling of multiple ResultSets. } @@ -296,12 +300,6 @@ Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery() throw SQLException(); // TODO: add message to exception } - uno::Reference< OResultSet > pResult(new OResultSet(m_pConnection, - uno::Reference< XInterface >(*this), - m_statementHandle, - m_pOutSqlda)); - m_xResultSet = pResult.get(); - return m_xResultSet; } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/firebird/Statement.cxx b/connectivity/source/drivers/firebird/Statement.cxx index 8809330a57c7..6f2ee586dd1e 100644 --- a/connectivity/source/drivers/firebird/Statement.cxx +++ b/connectivity/source/drivers/firebird/Statement.cxx @@ -82,7 +82,6 @@ void SAL_CALL OStatement::release() throw() sal_Int32 SAL_CALL OStatement::executeUpdate(const OUString& sql) throw(SQLException, RuntimeException) { - // TODO: close ResultSet if existing -- so so in all 3 execute methods. MutexGuard aGuard(m_pConnection->getMutex()); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); @@ -133,12 +132,10 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s SAL_WARN("connectivity.firebird", "isc_dsql_execute failed" ); } - uno::Reference< OResultSet > pResult(new OResultSet(m_pConnection, - uno::Reference< XInterface >(*this), - aStatementHandle, - pOutSqlda)); - //initializeResultSet( pResult.get() ); - m_xResultSet = pResult.get(); + m_xResultSet = new OResultSet(m_pConnection, + uno::Reference< XInterface >(*this), + aStatementHandle, + pOutSqlda); // TODO: deal with cleanup // close(); diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.cxx b/connectivity/source/drivers/firebird/StatementCommonBase.cxx index eba79de6e41b..d3ee72caa536 100644 --- a/connectivity/source/drivers/firebird/StatementCommonBase.cxx +++ b/connectivity/source/drivers/firebird/StatementCommonBase.cxx @@ -59,11 +59,10 @@ OStatementCommonBase::~OStatementCommonBase() void OStatementCommonBase::disposeResultSet() { - //free the cursor if alive -// uno::Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY); -// if (xComp.is()) -// xComp->dispose(); -// m_xResultSet = uno::Reference< XResultSet>(); + uno::Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY); + if (xComp.is()) + xComp->dispose(); + m_xResultSet = uno::Reference< XResultSet>(); } //----------------------------------------------------------------------------- @@ -101,7 +100,7 @@ void SAL_CALL OStatementCommonBase::close( ) throw(SQLException, RuntimeExcepti { MutexGuard aGuard(m_pConnection->getMutex()); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); - + disposeResultSet(); } dispose(); } @@ -191,11 +190,11 @@ int OStatementCommonBase::prepareAndDescribeStatement(const OUString& sql, uno::Reference< XResultSet > SAL_CALL OStatementCommonBase::getResultSet() throw(SQLException, RuntimeException) { // TODO: verify we really can't support this - return uno::Reference< XResultSet >(); -// MutexGuard aGuard( m_aMutex ); -// checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); +// return uno::Reference< XResultSet >(); + MutexGuard aGuard(m_pConnection->getMutex()); + checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); -// return m_xResultSet; + return m_xResultSet; } sal_Bool SAL_CALL OStatementCommonBase::getMoreResults() throw(SQLException, RuntimeException) diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.hxx b/connectivity/source/drivers/firebird/StatementCommonBase.hxx index 99f456361c34..12483a6d3faf 100644 --- a/connectivity/source/drivers/firebird/StatementCommonBase.hxx +++ b/connectivity/source/drivers/firebird/StatementCommonBase.hxx @@ -53,7 +53,7 @@ namespace connectivity { protected: - ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created // for this Statement ::std::list< ::rtl::OUString> m_aBatchList; |