[Libreoffice-commits] core.git: Branch 'feature/firebird-sdbc2' - 6 commits - connectivity/source
Andrzej J.R. Hunt
andrzej at ahunt.org
Fri Jul 12 02:36:23 PDT 2013
connectivity/source/drivers/firebird/FConnection.cxx | 235 ++++++++-----
connectivity/source/drivers/firebird/FConnection.hxx | 12
connectivity/source/drivers/firebird/FDatabaseMetaData.cxx | 18
connectivity/source/drivers/firebird/FDatabaseMetaData.hxx | 1
4 files changed, 157 insertions(+), 109 deletions(-)
New commits:
commit 699aa1aff95b517d4a749f548526ca62bef912db
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Fri Jul 12 09:45:39 2013 +0100
Remove unnecessary catalog state (unsupported in firebird).
Change-Id: I34a7a245eb87a5b0d626be4008e2584774e82cf3
diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index 89d1967..0735d24 100644
--- a/connectivity/source/drivers/firebird/FConnection.cxx
+++ b/connectivity/source/drivers/firebird/FConnection.cxx
@@ -71,15 +71,16 @@
using namespace connectivity::firebird;
using namespace connectivity;
-using namespace com::sun::star;
-using namespace com::sun::star::beans;
-using namespace com::sun::star::document;
-using namespace com::sun::star::embed;
-using namespace com::sun::star::frame;
-using namespace com::sun::star::io;
-using namespace com::sun::star::lang;
-using namespace com::sun::star::sdbc;
-using namespace com::sun::star::uno;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::embed;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
const OUString OConnection::sDBLocation( "firebird.fdb" );
@@ -92,7 +93,6 @@ OConnection::OConnection(FirebirdDriver* _pDriver)
m_sUser(),
m_pDriver(_pDriver),
m_bClosed(sal_False),
- m_bUseCatalog(sal_False),
m_bUseOldDateFormat(sal_False),
m_bAutoCommit(sal_True),
m_bReadOnly(sal_False),
@@ -493,7 +493,7 @@ sal_Bool SAL_CALL OConnection::isReadOnly() throw(SQLException, RuntimeException
void SAL_CALL OConnection::setCatalog(const OUString& catalog)
throw(SQLException, RuntimeException)
{
- // Unsupported
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::setCatalog", *this );
(void) catalog;
}
@@ -519,23 +519,21 @@ sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) throw(SQLException,
return m_aTransactionIsolation;
}
-// --------------------------------------------------------------------------------
-Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OConnection::getTypeMap( ) throw(SQLException, RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(OConnection_BASE::rBHelper.bDisposed);
-
- // if your driver has special database types you can return it here
- return NULL;
+Reference< XNameAccess > SAL_CALL OConnection::getTypeMap() throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::getTypeMap", *this );
+ return 0;
}
-// --------------------------------------------------------------------------------
-void SAL_CALL OConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException)
+
+void SAL_CALL OConnection::setTypeMap(const Reference< XNameAccess >& typeMap)
+ throw(SQLException, RuntimeException)
{
- // the other way around
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::setTypeMap", *this );
+ (void) typeMap;
}
-// --------------------------------------------------------------------------------
-// XCloseable
+
+//----- XCloseable -----------------------------------------------------------
void SAL_CALL OConnection::close( ) throw(SQLException, RuntimeException)
{
SAL_INFO("connectivity.firebird", "=> OConnection::close().");
diff --git a/connectivity/source/drivers/firebird/FConnection.hxx b/connectivity/source/drivers/firebird/FConnection.hxx
index 0ca035c..e91aef6 100644
--- a/connectivity/source/drivers/firebird/FConnection.hxx
+++ b/connectivity/source/drivers/firebird/FConnection.hxx
@@ -106,7 +106,6 @@ namespace connectivity
// driver object
sal_Bool m_bClosed;
- sal_Bool m_bUseCatalog; // should we use the catalog on filebased databases
sal_Bool m_bUseOldDateFormat;
sal_Bool m_bAutoCommit;
sal_Bool m_bReadOnly;
@@ -167,8 +166,6 @@ namespace connectivity
// css.lang.XEventListener
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
- // should we use the catalog on filebased databases
- inline sal_Bool isCatalogUsed() const { return m_bUseCatalog; }
inline ::rtl::OUString getUserName() const { return m_sUser; }
inline isc_db_handle getDBHandler() const { return m_DBHandler; }
inline FirebirdDriver* getDriver() const { return m_pDriver;}
diff --git a/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx b/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
index 80c4470..0bdcc17 100644
--- a/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
+++ b/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
@@ -61,17 +61,10 @@ namespace connectivity
ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon)
: m_pConnection(_pCon)
-, m_bUseCatalog(sal_True)
{
OSL_ENSURE(m_pConnection,"ODatabaseMetaData::ODatabaseMetaData: No connection set!");
- if(!m_pConnection->isCatalogUsed())
- {
- osl_atomic_increment( &m_refCount );
- m_bUseCatalog = !(usesLocalFiles() || usesLocalFilePerTable());
- osl_atomic_decrement( &m_refCount );
- }
}
-// -------------------------------------------------------------------------
+
ODatabaseMetaData::~ODatabaseMetaData()
{
}
@@ -79,9 +72,6 @@ ODatabaseMetaData::~ODatabaseMetaData()
::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogSeparator( ) throw(SQLException, RuntimeException)
{
::rtl::OUString aVal;
- if(m_bUseCatalog)
- { // do some special here for you database
- }
return aVal;
}
@@ -218,9 +208,6 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLExc
::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
{
::rtl::OUString aVal;
- if(m_bUseCatalog)
- {
- }
return aVal;
}
// -------------------------------------------------------------------------
@@ -245,9 +232,6 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( )
sal_Bool SAL_CALL ODatabaseMetaData::isCatalogAtStart( ) throw(SQLException, RuntimeException)
{
sal_Bool bValue = sal_False;
- if(m_bUseCatalog)
- {
- }
return bValue;
}
// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/firebird/FDatabaseMetaData.hxx b/connectivity/source/drivers/firebird/FDatabaseMetaData.hxx
index a2852e0..414dcac 100644
--- a/connectivity/source/drivers/firebird/FDatabaseMetaData.hxx
+++ b/connectivity/source/drivers/firebird/FDatabaseMetaData.hxx
@@ -53,7 +53,6 @@ namespace connectivity
class ODatabaseMetaData : public ODatabaseMetaData_BASE
{
OConnection* m_pConnection;
- sal_Bool m_bUseCatalog;
public:
inline OConnection* getOwnConnection() const { return m_pConnection; }
commit c5587174570b9f1f64c03eccdc530f7b2e4ae582
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Fri Jul 12 09:27:49 2013 +0100
Clean up and remove warnings for unsupported methods.
Change-Id: Id1a6c3c438c88791654ca9f301dbc7763caebeab
diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index 25aa251..89d1967 100644
--- a/connectivity/source/drivers/firebird/FConnection.cxx
+++ b/connectivity/source/drivers/firebird/FConnection.cxx
@@ -489,23 +489,18 @@ sal_Bool SAL_CALL OConnection::isReadOnly() throw(SQLException, RuntimeException
return m_bReadOnly;
}
-// --------------------------------------------------------------------------------
-void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& catalog ) throw(SQLException, RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(OConnection_BASE::rBHelper.bDisposed);
- // if your database doesn't work with catalogs you go to next method otherwise you kjnow what to do
-}
-// --------------------------------------------------------------------------------
-::rtl::OUString SAL_CALL OConnection::getCatalog( ) throw(SQLException, RuntimeException)
+void SAL_CALL OConnection::setCatalog(const OUString& catalog)
+ throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(OConnection_BASE::rBHelper.bDisposed);
-
+ // Unsupported
+ (void) catalog;
+}
- // return your current catalog
- return ::rtl::OUString();
+OUString SAL_CALL OConnection::getCatalog() throw(SQLException, RuntimeException)
+{
+ // Unsupported
+ return OUString();
}
void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 level ) throw(SQLException, RuntimeException)
commit 3055c14b252087d8b628a64d284fe568d22bfa88
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Fri Jul 12 09:11:52 2013 +0100
Implement transaction isolation in firebird-sdbc.
Change-Id: Id18c26cbd62b2cf9573ffafcd3da0041c2d8e9c5
diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index f919276..25aa251 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 543b4b0..0ca035c 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;
commit 0d99864d19b68d2fb829bf8a54fb8ca9804302d8
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Fri Jul 12 08:34:34 2013 +0100
Make db location a static member variable.
Change-Id: I138c18839f2816baae24ef84eb08dbb71cce2948
diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index 3f0f070..f919276 100644
--- a/connectivity/source/drivers/firebird/FConnection.cxx
+++ b/connectivity/source/drivers/firebird/FConnection.cxx
@@ -81,6 +81,8 @@ using namespace com::sun::star::lang;
using namespace com::sun::star::sdbc;
using namespace com::sun::star::uno;
+const OUString OConnection::sDBLocation( "firebird.fdb" );
+
OConnection::OConnection(FirebirdDriver* _pDriver)
:OMetaConnection_BASE(m_aMutex),
OSubComponent<OConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this),
@@ -173,7 +175,6 @@ void OConnection::construct(const ::rtl::OUString& url, const Sequence< Property
bIsNewDatabase = !m_xEmbeddedStorage->hasElements();
- const OUString sDBName( "firebird.fdb" ); // Location within .odb container
m_aURL = utl::TempFile::CreateTempName() + ".fdb";
SAL_INFO("connectivity.firebird", "Temporary .fdb location: "
@@ -181,14 +182,14 @@ void OConnection::construct(const ::rtl::OUString& url, const Sequence< Property
if (!bIsNewDatabase)
{
SAL_INFO("connectivity.firebird", "Extracting .fdb from .odb" );
- if (!m_xEmbeddedStorage->isStreamElement(sDBName))
+ if (!m_xEmbeddedStorage->isStreamElement(sDBLocation))
{
::connectivity::SharedResources aResources;
const OUString sMessage = aResources.getResourceString(STR_ERROR_NEW_VERSION);
::dbtools::throwGenericSQLException(sMessage ,*this);
}
- Reference< XStream > xDBStream(m_xEmbeddedStorage->openStreamElement(sDBName,
+ Reference< XStream > xDBStream(m_xEmbeddedStorage->openStreamElement(sDBLocation,
ElementModes::READ));
uno::Reference< ucb::XSimpleFileAccess2 > xFileAccess(
@@ -554,11 +555,9 @@ void SAL_CALL OConnection::documentEventOccured( const DocumentEvent& _Event )
{
if ( m_bIsEmbedded && m_xEmbeddedStorage.is() )
{
- const OUString sDBName( "firebird.fdb" ); // Location within .odb container
-
SAL_INFO("connectivity.firebird", "Writing .fdb into .odb" );
- Reference< XStream > xDBStream(m_xEmbeddedStorage->openStreamElement(sDBName,
+ Reference< XStream > xDBStream(m_xEmbeddedStorage->openStreamElement(sDBLocation,
ElementModes::WRITE));
using namespace ::comphelper;
diff --git a/connectivity/source/drivers/firebird/FConnection.hxx b/connectivity/source/drivers/firebird/FConnection.hxx
index d8338b3..543b4b0 100644
--- a/connectivity/source/drivers/firebird/FConnection.hxx
+++ b/connectivity/source/drivers/firebird/FConnection.hxx
@@ -82,7 +82,7 @@ namespace connectivity
friend class connectivity::firebird::OSubComponent<OConnection, OConnection_BASE>;
protected:
-
+ static const OUString sDBLocation; // Location within .odb container
rtl_TextEncoding m_nTextEncoding; // the encoding which is used for all text conversions
//====================================================================
// Data attributes
commit 26897cd0720e4bacace486ffc18b7a3b1f38b315
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Fri Jul 12 08:17:20 2013 +0100
Implement readonly support in firebird-sdbc.
Change-Id: Ifdb235a3772b92b7064d059700084f75d468d146
diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index aa4bf72..3f0f070 100644
--- a/connectivity/source/drivers/firebird/FConnection.cxx
+++ b/connectivity/source/drivers/firebird/FConnection.cxx
@@ -93,6 +93,7 @@ OConnection::OConnection(FirebirdDriver* _pDriver)
m_bUseCatalog(sal_False),
m_bUseOldDateFormat(sal_False),
m_bAutoCommit(sal_True),
+ m_bReadOnly(sal_False),
m_DBHandler(0),
m_transactionHandle(0)
{
@@ -383,11 +384,10 @@ void OConnection::setupTransaction()
static char isc_tpb[] = {
isc_tpb_version3,
- (m_bAutoCommit ? isc_tpb_autocommit : 0),
- isc_tpb_write,
- isc_tpb_read_committed,
- isc_tpb_wait,
- isc_tpb_no_rec_version
+ (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
+ isc_tpb_wait
};
isc_start_transaction(status_vector, &m_transactionHandle, 1, &m_DBHandler,
@@ -449,22 +449,23 @@ Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLEx
return xMetaData;
}
-// --------------------------------------------------------------------------------
-void SAL_CALL OConnection::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException)
+
+void SAL_CALL OConnection::setReadOnly(sal_Bool readOnly)
+ throw(SQLException, RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
- // set you connection to readonly
+ m_bReadOnly = readOnly;
+ setupTransaction();
}
-// --------------------------------------------------------------------------------
-sal_Bool SAL_CALL OConnection::isReadOnly( ) throw(SQLException, RuntimeException)
+
+sal_Bool SAL_CALL OConnection::isReadOnly() throw(SQLException, RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
- // return if your connection to readonly
- return sal_False;
+ return m_bReadOnly;
}
// --------------------------------------------------------------------------------
void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& catalog ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/firebird/FConnection.hxx b/connectivity/source/drivers/firebird/FConnection.hxx
index fb9b0a8..d8338b3 100644
--- a/connectivity/source/drivers/firebird/FConnection.hxx
+++ b/connectivity/source/drivers/firebird/FConnection.hxx
@@ -109,6 +109,7 @@ namespace connectivity
sal_Bool m_bUseCatalog; // should we use the catalog on filebased databases
sal_Bool m_bUseOldDateFormat;
sal_Bool m_bAutoCommit;
+ sal_Bool m_bReadOnly;
isc_db_handle m_DBHandler;
isc_tr_handle m_transactionHandle;
commit 9d9d2d813e720365aebd91dabf6d19cbb0234bbe
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Fri Jul 12 07:39:15 2013 +0100
Add auto-commit support to firebird-sdbc, enabled by default.
Change-Id: I0303cc8df281c70973ee10dd67d23757cc7bd97a
diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index 5576d1f..aa4bf72 100644
--- a/connectivity/source/drivers/firebird/FConnection.cxx
+++ b/connectivity/source/drivers/firebird/FConnection.cxx
@@ -92,7 +92,9 @@ OConnection::OConnection(FirebirdDriver* _pDriver)
m_bClosed(sal_False),
m_bUseCatalog(sal_False),
m_bUseOldDateFormat(sal_False),
- m_DBHandler(0)
+ m_bAutoCommit(sal_True),
+ m_DBHandler(0),
+ m_transactionHandle(0)
{
SAL_INFO("connectivity.firebird", "=> OConnection::OConnection().");
@@ -234,7 +236,7 @@ void OConnection::construct(const ::rtl::OUString& url, const Sequence< Property
return;
}
- if (m_bIsEmbedded)
+ if (m_bIsEmbedded) // Add DocumentEventListener to save the .fdb as needed
{
uno::Reference< frame::XDesktop2 > xFramesSupplier =
frame::Desktop::create(::comphelper::getProcessComponentContext());
@@ -270,12 +272,14 @@ void OConnection::construct(const ::rtl::OUString& url, const Sequence< Property
osl_atomic_decrement( &m_refCount );
}
-// XServiceInfo
-// --------------------------------------------------------------------------------
-IMPLEMENT_SERVICE_INFO(OConnection, "com.sun.star.sdbc.drivers.firebird.OConnection", "com.sun.star.sdbc.Connection")
-// --------------------------------------------------------------------------------
-Reference< XStatement > SAL_CALL OConnection::createStatement( ) throw(SQLException, RuntimeException)
+//----- XServiceInfo ---------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OConnection, "com.sun.star.sdbc.drivers.firebird.OConnection",
+ "com.sun.star.sdbc.Connection")
+
+//----- XConnection ----------------------------------------------------------
+Reference< XStatement > SAL_CALL OConnection::createStatement( )
+ throw(SQLException, RuntimeException)
{
SAL_INFO("connectivity.firebird", "=> OConnection::createStatement().");
@@ -295,8 +299,9 @@ Reference< XStatement > SAL_CALL OConnection::createStatement( ) throw(SQLExcep
m_aStatements.push_back(WeakReferenceHelper(xReturn));
return xReturn;
}
-// --------------------------------------------------------------------------------
-Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
+
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement(
+ const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
{
SAL_INFO("connectivity.firebird", "=> OConnection::prepareStatement(). "
"Got called with sql: " << _sSql);
@@ -321,8 +326,9 @@ Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::
return xReturn;
}
-// --------------------------------------------------------------------------------
-Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
+
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall(
+ const OUString& _sSql ) throw(SQLException, RuntimeException)
{
SAL_INFO("connectivity.firebird", "=> OConnection::prepareCall(). "
"_sSql: " << _sSql);
@@ -333,49 +339,90 @@ Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::
// not implemented yet :-) a task to do
return NULL;
}
-// --------------------------------------------------------------------------------
-::rtl::OUString SAL_CALL OConnection::nativeSQL( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
+
+OUString SAL_CALL OConnection::nativeSQL( const OUString& _sSql )
+ throw(SQLException, RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
- // when you need to transform SQL92 to you driver specific you can do it here
-
+ // We do not need to adapt the SQL for Firebird atm.
return _sSql;
}
-// --------------------------------------------------------------------------------
-void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException)
+
+void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit )
+ throw(SQLException, RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
- // here you have to set your commit mode please have a look at the jdbc documentation to get a clear explanation
+
+ m_bAutoCommit = autoCommit;
+
+ if (m_transactionHandle)
+ {
+ setupTransaction();
+ }
}
-// --------------------------------------------------------------------------------
-sal_Bool SAL_CALL OConnection::getAutoCommit( ) throw(SQLException, RuntimeException)
+
+sal_Bool SAL_CALL OConnection::getAutoCommit() throw(SQLException, RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
- // you have to distinguish which if you are in autocommit mode or not
- // at normal case true should be fine here
- return sal_True;
+ return m_bAutoCommit;
}
-// --------------------------------------------------------------------------------
-void SAL_CALL OConnection::commit( ) throw(SQLException, RuntimeException)
+
+void OConnection::setupTransaction()
+{
+ ISC_STATUS status_vector[20];
+
+ // TODO: is this sensible? If we have changed parameters then transaction
+ // is lost...
+ if (m_transactionHandle)
+ {
+ isc_rollback_transaction(status_vector, &m_transactionHandle);
+ }
+
+ static char isc_tpb[] = {
+ isc_tpb_version3,
+ (m_bAutoCommit ? isc_tpb_autocommit : 0),
+ isc_tpb_write,
+ isc_tpb_read_committed,
+ isc_tpb_wait,
+ isc_tpb_no_rec_version
+ };
+
+ isc_start_transaction(status_vector, &m_transactionHandle, 1, &m_DBHandler,
+ (unsigned short) sizeof(isc_tpb), isc_tpb);
+
+ //TODO: transmit to open statements?
+
+}
+
+void SAL_CALL OConnection::commit() throw(SQLException, RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
- // when you database does support transactions you should commit here
+ ISC_STATUS status_vector[20];
+
+ if (!m_bAutoCommit && m_transactionHandle)
+ {
+ isc_commit_transaction(status_vector, &m_transactionHandle);
+ }
}
-// --------------------------------------------------------------------------------
-void SAL_CALL OConnection::rollback( ) throw(SQLException, RuntimeException)
+
+void SAL_CALL OConnection::rollback() throw(SQLException, RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+ ISC_STATUS status_vector[20];
- // same as commit but for the other case
+ if (!m_bAutoCommit && m_transactionHandle)
+ {
+ isc_rollback_transaction(status_vector, &m_transactionHandle);
+ }
}
-// --------------------------------------------------------------------------------
+
sal_Bool SAL_CALL OConnection::isClosed( ) throw(SQLException, RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
@@ -606,6 +653,8 @@ void OConnection::disposing()
if (isc_detach_database(status, &m_DBHandler))
if (pr_error(status, "dattach database"))
return;
+ // TODO: write to storage again?
+ // and delete temporary file.
dispose_ChildImpl();
cppu::WeakComponentImplHelperBase::disposing();
diff --git a/connectivity/source/drivers/firebird/FConnection.hxx b/connectivity/source/drivers/firebird/FConnection.hxx
index e72bb19..fb9b0a8 100644
--- a/connectivity/source/drivers/firebird/FConnection.hxx
+++ b/connectivity/source/drivers/firebird/FConnection.hxx
@@ -108,12 +108,15 @@ namespace connectivity
sal_Bool m_bClosed;
sal_Bool m_bUseCatalog; // should we use the catalog on filebased databases
sal_Bool m_bUseOldDateFormat;
+ sal_Bool m_bAutoCommit;
isc_db_handle m_DBHandler;
+ isc_tr_handle m_transactionHandle;
::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > m_xEmbeddedStorage;
void buildTypeInfo() throw( ::com::sun::star::sdbc::SQLException);
+ void setupTransaction();
public:
virtual void construct( const ::rtl::OUString& url,
const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info)
More information about the Libreoffice-commits
mailing list