diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-07-12 09:11:52 +0100 |
---|---|---|
committer | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-07-12 16:34:28 +0100 |
commit | aa535d3ed8ea64a547ab33259dfdce53c6ff2fa9 (patch) | |
tree | c6e3e2b903e65799bde95346e45ee6331a30add3 /connectivity/source/drivers/firebird/FConnection.cxx | |
parent | bb8802d72ce628aa977342520ea70f063613403b (diff) |
Implement transaction isolation in firebird-sdbc.
Change-Id: Id18c26cbd62b2cf9573ffafcd3da0041c2d8e9c5
Diffstat (limited to 'connectivity/source/drivers/firebird/FConnection.cxx')
-rw-r--r-- | connectivity/source/drivers/firebird/FConnection.cxx | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx index f9192762aa95..25aa25164eb6 100644 --- a/connectivity/source/drivers/firebird/FConnection.cxx +++ b/connectivity/source/drivers/firebird/FConnection.cxx @@ -96,6 +96,7 @@ OConnection::OConnection(FirebirdDriver* _pDriver) m_bUseOldDateFormat(sal_False), m_bAutoCommit(sal_True), m_bReadOnly(sal_False), + m_aTransactionIsolation(TransactionIsolation::REPEATABLE_READ), m_DBHandler(0), m_transactionHandle(0) { @@ -383,11 +384,31 @@ void OConnection::setupTransaction() isc_rollback_transaction(status_vector, &m_transactionHandle); } + char aTransactionIsolation = 0; + switch (m_aTransactionIsolation) + { + // TODO: confirm that these are correct. + case(TransactionIsolation::READ_UNCOMMITTED): + aTransactionIsolation = isc_tpb_concurrency; + break; + case(TransactionIsolation::READ_COMMITTED): + aTransactionIsolation = isc_tpb_read_committed; + break; + case(TransactionIsolation::REPEATABLE_READ): + aTransactionIsolation = isc_tpb_consistency; + break; + case(TransactionIsolation::SERIALIZABLE): + aTransactionIsolation = isc_tpb_consistency; + break; + default: + assert( false ); // We must have a valid TransactionIsolation. + } + static char isc_tpb[] = { isc_tpb_version3, (char) (m_bAutoCommit ? isc_tpb_autocommit : 0), (char) (!m_bReadOnly ? isc_tpb_write : isc_tpb_read), - isc_tpb_read_committed, // TODO: set isolation level here + aTransactionIsolation, isc_tpb_wait }; @@ -486,24 +507,22 @@ void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& catalog ) throw(SQ // return your current catalog return ::rtl::OUString(); } -// -------------------------------------------------------------------------------- + void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 level ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OConnection_BASE::rBHelper.bDisposed); - // set your isolation level - // please have a look at @see com.sun.star.sdbc.TransactionIsolation + m_aTransactionIsolation = level; + setupTransaction(); } -// -------------------------------------------------------------------------------- + sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OConnection_BASE::rBHelper.bDisposed); - - // please have a look at @see com.sun.star.sdbc.TransactionIsolation - return TransactionIsolation::NONE; + return m_aTransactionIsolation; } // -------------------------------------------------------------------------------- Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OConnection::getTypeMap( ) throw(SQLException, RuntimeException) |