summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2013-07-12 09:11:52 +0100
committerAndrzej J.R. Hunt <andrzej@ahunt.org>2013-07-16 16:40:14 +0200
commita066f9e3b96c0157a91514f46712a140afe4ac36 (patch)
tree4a6395ee65e514290daa3eec8724a22db906c610 /connectivity
parent25772a93fa8a3a8378fdc44178b5d37a4962cca9 (diff)
Implement transaction isolation in firebird-sdbc.
Change-Id: Id18c26cbd62b2cf9573ffafcd3da0041c2d8e9c5
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/firebird/FConnection.cxx35
-rw-r--r--connectivity/source/drivers/firebird/FConnection.hxx3
2 files changed, 30 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)
diff --git a/connectivity/source/drivers/firebird/FConnection.hxx b/connectivity/source/drivers/firebird/FConnection.hxx
index 543b4b0362a8..0ca035cc28fc 100644
--- a/connectivity/source/drivers/firebird/FConnection.hxx
+++ b/connectivity/source/drivers/firebird/FConnection.hxx
@@ -110,6 +110,9 @@ namespace connectivity
sal_Bool m_bUseOldDateFormat;
sal_Bool m_bAutoCommit;
sal_Bool m_bReadOnly;
+
+ sal_Int32 m_aTransactionIsolation;
+
isc_db_handle m_DBHandler;
isc_tr_handle m_transactionHandle;