connectivity/source/drivers/file/FPreparedStatement.cxx | 9 +++- connectivity/source/drivers/file/FStatement.cxx | 31 +++++++++++++--- connectivity/source/inc/file/FStatement.hxx | 4 +- 3 files changed, 36 insertions(+), 8 deletions(-)
New commits: commit f6b9cc2c5b2133b5a44f54ed307bbe9e1e02e5fc Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Tue Jun 17 18:12:45 2014 +0200 fdo#80084 file driver PreparedStatement: close previous ResultSet on reexec This partially reverts commit d87c2c59c9c1d5f5825f355c9eb941fdf95b42f6 "sdbc file driver (Prepared)Statement: created ResultSet owned by *caller*" From that commit, we keep the part about not reusing the same ResultSet on reexecution (client code may have disposed it or closed it), but we revert the part about not closing / disposing the previous ResultSet on reexecution. Change-Id: I4946207f9740484b2f5fbc3575a5708fe39f357c Reviewed-on: https://gerrit.libreoffice.org/9823 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/connectivity/source/drivers/file/FPreparedStatement.cxx b/connectivity/source/drivers/file/FPreparedStatement.cxx index 6fb706b..81ac7a9 100644 --- a/connectivity/source/drivers/file/FPreparedStatement.cxx +++ b/connectivity/source/drivers/file/FPreparedStatement.cxx @@ -101,15 +101,16 @@ void OPreparedStatement::construct(const OUString& sql) throw(SQLException, Run Reference<XResultSet> OPreparedStatement::makeResultSet() { + closeResultSet(); + OResultSet *pResultSet = createResultSet(); Reference<XResultSet> xRS(pResultSet); initializeResultSet(pResultSet); initResultSet(pResultSet); + m_xResultSet = xRS; return xRS; } - - Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException, std::exception) { Any aRet = OStatement_BASE2::queryInterface(rType); @@ -145,6 +146,8 @@ void SAL_CALL OPreparedStatement::close( ) throw(SQLException, RuntimeException { ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + closeResultSet(); } @@ -157,6 +160,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute( ) throw(SQLException, RuntimeExc // since we don't support the XMultipleResults interface, nobody will ever get that ResultSet... Reference< XComponent > xComp(xRS, UNO_QUERY); + assert(xComp.is() || !xRS.is()); if (xComp.is()) xComp->dispose(); @@ -512,7 +516,6 @@ void OPreparedStatement::describeParameter() } } } - void OPreparedStatement::initializeResultSet(OResultSet* pRS) { OStatement_Base::initializeResultSet(pRS); diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx index a95af1c..65f587f 100644 --- a/connectivity/source/drivers/file/FStatement.cxx +++ b/connectivity/source/drivers/file/FStatement.cxx @@ -95,10 +95,23 @@ OStatement_Base::~OStatement_Base() delete m_pSQLAnalyzer; } +void OStatement_Base::disposeResultSet() +{ + SAL_INFO( "connectivity.drivers", "file ocke.jans...@sun.com OStatement_Base::disposeResultSet" ); + // free the cursor if alive + Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY); + assert(xComp.is() || !m_xResultSet.get().is()); + if (xComp.is()) + xComp->dispose(); + m_xResultSet.clear(); +} + void OStatement_BASE2::disposing() { ::osl::MutexGuard aGuard(m_aMutex); + disposeResultSet(); + if(m_pSQLAnalyzer) m_pSQLAnalyzer->dispose(); @@ -173,17 +186,26 @@ void SAL_CALL OStatement_Base::close( ) throw(SQLException, RuntimeException, s dispose(); } - -void OStatement_Base::reset() throw (SQLException) +void OStatement_Base::closeResultSet () throw (SQLException) { + SAL_INFO( "connectivity.drivers", "file ocke.jans...@sun.com OStatement_Base::clearMyResultSet " ); ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OStatement_BASE::rBHelper.bDisposed); - clearWarnings (); + Reference< XCloseable > xCloseable(m_xResultSet.get(), UNO_QUERY); + assert(xCloseable.is() || !m_xResultSet.get().is()); + if (xCloseable.is()) + { + try + { + xCloseable->close(); + } + catch( const DisposedException& ) { } + } + m_xResultSet.clear(); } - Any SAL_CALL OStatement_Base::getWarnings( ) throw(SQLException, RuntimeException, std::exception) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -252,6 +274,7 @@ Reference< XResultSet > SAL_CALL OStatement::executeQuery( const OUString& sql ) OResultSet* pResult = createResultSet(); xRS = pResult; initializeResultSet(pResult); + m_xResultSet = xRS; pResult->OpenImpl(); diff --git a/connectivity/source/inc/file/FStatement.hxx b/connectivity/source/inc/file/FStatement.hxx index 1abb479..3bf0432 100644 --- a/connectivity/source/inc/file/FStatement.hxx +++ b/connectivity/source/inc/file/FStatement.hxx @@ -68,6 +68,7 @@ namespace connectivity ::std::vector<TAscendingOrder> m_aOrderbyAscending; ::com::sun::star::sdbc::SQLWarning m_aLastWarning; + ::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::XDatabaseMetaData> m_xDBMetaData; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColNames; // table columns // for this Statement @@ -112,9 +113,10 @@ namespace connectivity // create the analyzer virtual OSQLAnalyzer* createAnalyzer(); - void reset () throw( ::com::sun::star::sdbc::SQLException); + void closeResultSet () throw( ::com::sun::star::sdbc::SQLException); sal_Int32 getPrecision ( sal_Int32 sqlType); + void disposeResultSet(); void GetAssignValues(); void SetAssignValue(const OUString& aColumnName, const OUString& aValue,
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits