summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2013-08-07 11:06:09 +0100
committerAndrzej J.R. Hunt <andrzej@ahunt.org>2013-08-07 18:23:36 +0100
commit211094992c610b77abd46d93b3e46b5a25fe4f95 (patch)
treef88d85396f09136d0fe78c46168c788afe4c1db4 /connectivity
parent67596ee0b1ad4fa7268488d16ca20ee2d3032d97 (diff)
Fix transaction creation when autocommit disabled. (firebird-sdbc)
Change-Id: I190a90e9821961c4e972ec26ac282b05fd375d4b
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/firebird/Connection.cxx34
-rw-r--r--connectivity/source/drivers/firebird/Connection.hxx4
2 files changed, 26 insertions, 12 deletions
diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx
index 07b16ebe6fc3..db2652323ccd 100644
--- a/connectivity/source/drivers/firebird/Connection.cxx
+++ b/connectivity/source/drivers/firebird/Connection.cxx
@@ -82,7 +82,7 @@ OConnection::OConnection(FirebirdDriver* _pDriver)
m_pDriver(_pDriver),
m_bClosed(sal_False),
m_bUseOldDateFormat(sal_False),
- m_bAutoCommit(sal_True),
+ m_bAutoCommit(sal_False),
m_bReadOnly(sal_False),
m_aTransactionIsolation(TransactionIsolation::REPEATABLE_READ),
m_DBHandler(0),
@@ -413,6 +413,7 @@ sal_Bool SAL_CALL OConnection::getAutoCommit() throw(SQLException, RuntimeExcept
}
void OConnection::setupTransaction()
+ throw (SQLException)
{
MutexGuard aGuard( m_aMutex );
ISC_STATUS status_vector[20];
@@ -445,19 +446,32 @@ void OConnection::setupTransaction()
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),
- aTransactionIsolation,
- isc_tpb_wait
- };
+ // You cannot pass an empty tpb parameter so we have to do some pointer
+ // arithmetic to avoid problems. (i.e. aTPB[x] = 0 is invalid)
+ char aTPB[5];
+ char* pTPB = aTPB;
- isc_start_transaction(status_vector, &m_transactionHandle, 1, &m_DBHandler,
- (unsigned short) sizeof(isc_tpb), isc_tpb);
+ *pTPB++ = isc_tpb_version3;
+ if (m_bAutoCommit)
+ *pTPB++ = isc_tpb_autocommit;
+ *pTPB++ = (!m_bReadOnly ? isc_tpb_write : isc_tpb_read);
+ *pTPB++ = aTransactionIsolation;
+ *pTPB++ = isc_tpb_wait;
+
+ isc_start_transaction(status_vector,
+ &m_transactionHandle,
+ 1,
+ &m_DBHandler,
+ pTPB - aTPB, // bytes used in TPB
+ aTPB);
+
+ evaluateStatusVector(status_vector,
+ "isc_start_transaction",
+ *this);
}
isc_tr_handle& OConnection::getTransaction()
+ throw (SQLException)
{
MutexGuard aGuard( m_aMutex );
if (!m_transactionHandle)
diff --git a/connectivity/source/drivers/firebird/Connection.hxx b/connectivity/source/drivers/firebird/Connection.hxx
index fcc59efb7c4f..5e35b36e501d 100644
--- a/connectivity/source/drivers/firebird/Connection.hxx
+++ b/connectivity/source/drivers/firebird/Connection.hxx
@@ -111,7 +111,7 @@ namespace connectivity
void buildTypeInfo() throw( ::com::sun::star::sdbc::SQLException);
- void setupTransaction();
+ void setupTransaction() throw(::com::sun::star::sdbc::SQLException);
void clearStatements();
public:
virtual void construct( const ::rtl::OUString& url,
@@ -166,7 +166,7 @@ namespace connectivity
::rtl::OUString getConnectionURL() const { return m_sConnectionURL; }
sal_Bool isEmbedded() const { return m_bIsEmbedded; }
- isc_tr_handle& getTransaction();
+ isc_tr_handle& getTransaction() throw(::com::sun::star::sdbc::SQLException);
/**
* Create a new Blob tied to this connection. Blobs are tied to a