summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2013-07-17 17:00:18 +0200
committerAndrzej J.R. Hunt <andrzej@ahunt.org>2013-07-18 16:21:39 +0200
commitc28b720186f67392446a93b2d6ecf9df547068a4 (patch)
treeba95f1149ff88fbec659f3d338557ad7e71a707b
parentee4569efa8322497112e8e951a67b9adca4ac55e (diff)
Refactor FStatement to use transactions from Connection.
Also some furthe cleanup of various parts of firebird-sdbc. Change-Id: I008e1011632d628633f34c0893e656be054de637
-rw-r--r--connectivity/source/drivers/firebird/FConnection.cxx77
-rw-r--r--connectivity/source/drivers/firebird/FConnection.hxx11
-rw-r--r--connectivity/source/drivers/firebird/FDatabaseMetaData.cxx5
-rw-r--r--connectivity/source/drivers/firebird/FPreparedStatement.cxx45
-rw-r--r--connectivity/source/drivers/firebird/FPreparedStatement.hxx4
-rw-r--r--connectivity/source/drivers/firebird/FResultSet.cxx43
-rw-r--r--connectivity/source/drivers/firebird/FResultSet.hxx6
-rw-r--r--connectivity/source/drivers/firebird/FStatement.cxx598
-rw-r--r--connectivity/source/drivers/firebird/FStatement.hxx43
9 files changed, 420 insertions, 412 deletions
diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index f9ba966540ee..1713a1485b62 100644
--- a/connectivity/source/drivers/firebird/FConnection.cxx
+++ b/connectivity/source/drivers/firebird/FConnection.cxx
@@ -71,6 +71,8 @@
using namespace connectivity::firebird;
using namespace connectivity;
+using namespace ::osl;
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
@@ -289,7 +291,7 @@ Reference< XStatement > SAL_CALL OConnection::createStatement( )
{
SAL_INFO("connectivity.firebird", "=> OConnection::createStatement().");
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
// the pre
@@ -312,7 +314,7 @@ Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement(
SAL_INFO("connectivity.firebird", "=> OConnection::prepareStatement(). "
"Got called with sql: " << _sSql);
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
// the pre
@@ -324,7 +326,9 @@ Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement(
// create a statement
// the statement can only be executed more than once
- Reference< XPreparedStatement > xReturn = new OPreparedStatement(this,m_aTypeInfo,_sSql);
+ Reference< XPreparedStatement > xReturn = new OPreparedStatement(this,
+ m_aTypeInfo,
+ _sSql);
m_aStatements.push_back(WeakReferenceHelper(xReturn));
SAL_INFO("connectivity.firebird", "=> OConnection::prepareStatement(). "
@@ -339,7 +343,7 @@ Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall(
SAL_INFO("connectivity.firebird", "=> OConnection::prepareCall(). "
"_sSql: " << _sSql);
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
// not implemented yet :-) a task to do
@@ -349,7 +353,7 @@ Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall(
OUString SAL_CALL OConnection::nativeSQL( const OUString& _sSql )
throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
// We do not need to adapt the SQL for Firebird atm.
return _sSql;
}
@@ -357,7 +361,7 @@ OUString SAL_CALL OConnection::nativeSQL( const OUString& _sSql )
void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit )
throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
m_bAutoCommit = autoCommit;
@@ -370,7 +374,7 @@ void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit )
sal_Bool SAL_CALL OConnection::getAutoCommit() throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
return m_bAutoCommit;
@@ -378,6 +382,7 @@ sal_Bool SAL_CALL OConnection::getAutoCommit() throw(SQLException, RuntimeExcept
void OConnection::setupTransaction()
{
+ MutexGuard aGuard( m_aMutex );
ISC_STATUS status_vector[20];
// TODO: is this sensible? If we have changed parameters then transaction
@@ -422,9 +427,19 @@ void OConnection::setupTransaction()
}
+isc_tr_handle& OConnection::getTransaction()
+{
+ MutexGuard aGuard( m_aMutex );
+ if (!m_transactionHandle)
+ {
+ setupTransaction();
+ }
+ return m_transactionHandle;
+}
+
void SAL_CALL OConnection::commit() throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
ISC_STATUS status_vector[20];
@@ -437,7 +452,7 @@ void SAL_CALL OConnection::commit() throw(SQLException, RuntimeException)
void SAL_CALL OConnection::rollback() throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
ISC_STATUS status_vector[20];
@@ -450,7 +465,7 @@ void SAL_CALL OConnection::rollback() throw(SQLException, RuntimeException)
sal_Bool SAL_CALL OConnection::isClosed( ) throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
// just simple -> we are close when we are disposed taht means someone called dispose(); (XComponent)
return OConnection_BASE::rBHelper.bDisposed;
@@ -460,7 +475,7 @@ Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLEx
{
SAL_INFO("connectivity.firebird", "=> OConnection::getMetaData().");
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
// here we have to create the class with biggest interface
@@ -478,7 +493,7 @@ Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLEx
void SAL_CALL OConnection::setReadOnly(sal_Bool readOnly)
throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
m_bReadOnly = readOnly;
@@ -487,7 +502,7 @@ void SAL_CALL OConnection::setReadOnly(sal_Bool readOnly)
sal_Bool SAL_CALL OConnection::isReadOnly() throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
return m_bReadOnly;
@@ -508,7 +523,7 @@ OUString SAL_CALL OConnection::getCatalog() throw(SQLException, RuntimeException
void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 level ) throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
m_aTransactionIsolation = level;
@@ -517,7 +532,7 @@ void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 level ) throw(SQLE
sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
return m_aTransactionIsolation;
@@ -543,7 +558,7 @@ void SAL_CALL OConnection::close( ) throw(SQLException, RuntimeException)
// we just dispose us
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
}
@@ -598,7 +613,7 @@ void OConnection::buildTypeInfo() throw( SQLException)
{
SAL_INFO("connectivity.firebird", "=> OConnection::buildTypeInfo().");
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
Reference< XResultSet> xRs = getMetaData ()->getTypeInfo ();
Reference< XRow> xRow(xRs,UNO_QUERY);
@@ -652,7 +667,7 @@ void OConnection::disposing()
SAL_INFO("connectivity.firebird", "=> OConnection::disposing().");
// we noticed that we should be destroied in near future so we have to dispose our statements
- ::osl::MutexGuard aGuard(m_aMutex);
+ MutexGuard aGuard(m_aMutex);
for (OWeakRefArray::iterator i = m_aStatements.begin(); m_aStatements.end() != i; ++i)
{
@@ -675,8 +690,32 @@ void OConnection::disposing()
dispose_ChildImpl();
cppu::WeakComponentImplHelperBase::disposing();
}
-// -----------------------------------------------------------------------------
+void SAL_CALL OConnection::evaluateStatusVector( ISC_STATUS_ARRAY& aStatusVector,
+ const OUString& aCause )
+ throw(SQLException)
+{
+ if (aStatusVector[0]==1 && aStatusVector[1]) // indicates error
+ {
+ OUStringBuffer buf;
+ buf.appendAscii( "firebird_sdbc error: ");
+
+ char msg[512];
+ const ISC_STATUS* pStatus = (const ISC_STATUS*) &aStatusVector;
+
+ while(fb_interpret(msg, sizeof(msg), &pStatus))
+ {
+ // TODO: verify encoding
+ buf.append(OUString(msg, strlen(msg), RTL_TEXTENCODING_UTF8));
+ }
+ buf.appendAscii( " (caused by '" );
+ buf.append( aCause );
+ buf.appendAscii( "')" );
+ OUString error = buf.makeStringAndClear();
+ SAL_WARN( "connectivity.firebird", error );
+ throw SQLException( error, *this, OUString(), 1, Any() );
+ }
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/firebird/FConnection.hxx b/connectivity/source/drivers/firebird/FConnection.hxx
index c25390fa3418..a7411c35c0b7 100644
--- a/connectivity/source/drivers/firebird/FConnection.hxx
+++ b/connectivity/source/drivers/firebird/FConnection.hxx
@@ -169,12 +169,21 @@ namespace connectivity
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
inline ::rtl::OUString getUserName() const { return m_sUser; }
- inline isc_db_handle getDBHandler() const { return m_DBHandler; }
+ inline isc_db_handle& getDBHandle() { return m_DBHandler; }
inline FirebirdDriver* getDriver() const { return m_pDriver;}
inline rtl_TextEncoding getTextEncoding() const { return m_nTextEncoding; }
::rtl::OUString getConnectionURL() const { return m_sConnectionURL; }
sal_Bool isEmbedded() const { return m_bIsEmbedded; }
+ isc_tr_handle& getTransaction();
+
+ /**
+ * Evaluate a firebird status vector and throw exceptions as necessary.
+ * The content of the status vector is included in the thrown exception.
+ */
+ void evaluateStatusVector( ISC_STATUS_ARRAY& aStatusVector,
+ const ::rtl::OUString& aCause )
+ throw (::com::sun::star::sdbc::SQLException);
};
}
}
diff --git a/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx b/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
index 9babda7f37fb..71e2181058c1 100644
--- a/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
+++ b/connectivity/source/drivers/firebird/FDatabaseMetaData.cxx
@@ -764,9 +764,10 @@ sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 setType ) thr
(void) setType;
return sal_False;
}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates() throw(SQLException, RuntimeException)
{
+ // No batch support in firebird
return sal_False;
}
diff --git a/connectivity/source/drivers/firebird/FPreparedStatement.cxx b/connectivity/source/drivers/firebird/FPreparedStatement.cxx
index 9901064ed864..c819b0c88ad2 100644
--- a/connectivity/source/drivers/firebird/FPreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/FPreparedStatement.cxx
@@ -61,25 +61,10 @@ typedef struct vary {
IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbcx.firebird.PreparedStatement","com.sun.star.sdbc.PreparedStatement");
-/*
- * Print the status, the SQLCODE, and exit.
- * Also, indicate which operation the error occured on.
- */
-static int pr_error (const ISC_STATUS* status, const char* operation)
-{
- SAL_WARN("connectivity.firebird", "=> OPreparedStatement static pr_error().");
-
- isc_print_status(status);
-
- SAL_WARN("connectivity.firebird", "=> OPreparedStatement static pr_error(). "
- "PROBLEM ON " << operation << ". "
- "SQLCODE: " << isc_sqlcode(status) << ".");
-
- return 1;
-}
-
-OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const TTypeInfoVector& _TypeInfo,const ::rtl::OUString& sql)
+OPreparedStatement::OPreparedStatement( OConnection* _pConnection,
+ const TTypeInfoVector& _TypeInfo,
+ const OUString& sql)
:OStatement_BASE2(_pConnection)
,m_aTypeInfo(_TypeInfo)
,m_nNumParams(0)
@@ -89,7 +74,8 @@ OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const TTypeInf
SAL_INFO("connectivity.firebird", "=> OPreparedStatement::OPreparedStatement_BASE(). "
"sql: " << sql);
- prepareQuery(m_sSqlStatement);
+// prepareQuery(m_sSqlStatement);
+ (void) sql;
}
// -----------------------------------------------------------------------------
@@ -232,27 +218,16 @@ Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLE
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
- ISC_STATUS_ARRAY status; /* status vector */
- if (0 == m_TRANSHandler)
- {
- isc_db_handle db = m_pConnection->getDBHandler(); // database handle
- if (isc_start_transaction(status, &m_TRANSHandler, 1, &db, 0, NULL))
- if (pr_error(status, "start transaction"))
- return NULL;
- }
+// ISC_STATUS_ARRAY status; /* status vector */
- if (isc_dsql_execute(status, &m_TRANSHandler, &m_STMTHandler, 1, m_INsqlda))
- if (pr_error(status, "execute query"))
- return NULL;
+// if (isc_dsql_execute(status, &m_pConnection->getTransaction(), &m_statementHandle, 1, m_INsqlda))
+// if (pr_error(status, "execute query"))
+// return NULL;
- Reference< OResultSet > pResult( new OResultSet( this) );
+ Reference< OResultSet > pResult( new OResultSet( this, 0) );
//initializeResultSet( pResult.get() );
Reference< XResultSet > xRS = pResult.get();
- if (isc_commit_transaction(status, &m_TRANSHandler))
- if (pr_error(status, "commit transaction"))
- return NULL;
-
SAL_INFO("connectivity.firebird", "=> OPreparedStatement::executeQuery(). "
"Query executed.");
diff --git a/connectivity/source/drivers/firebird/FPreparedStatement.hxx b/connectivity/source/drivers/firebird/FPreparedStatement.hxx
index f1b785487405..e6577b540021 100644
--- a/connectivity/source/drivers/firebird/FPreparedStatement.hxx
+++ b/connectivity/source/drivers/firebird/FPreparedStatement.hxx
@@ -97,7 +97,9 @@ namespace connectivity
public:
DECLARE_SERVICE_INFO();
// a constructor, which is required for returning objects:
- OPreparedStatement( OConnection* _pConnection,const TTypeInfoVector& _TypeInfo,const ::rtl::OUString& sql);
+ OPreparedStatement( OConnection* _pConnection,
+ const TTypeInfoVector& _TypeInfo,
+ const ::rtl::OUString& sql);
//XInterface
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
diff --git a/connectivity/source/drivers/firebird/FResultSet.cxx b/connectivity/source/drivers/firebird/FResultSet.cxx
index deef30ac64ad..5ba1880a9c54 100644
--- a/connectivity/source/drivers/firebird/FResultSet.cxx
+++ b/connectivity/source/drivers/firebird/FResultSet.cxx
@@ -56,23 +56,6 @@ using namespace com::sun::star::container;
using namespace com::sun::star::io;
using namespace com::sun::star::util;
-/*
- * Print the status, the SQLCODE, and exit.
- * Also, indicate which operation the error occured on.
- */
-static int pr_error (const ISC_STATUS* status, const char* operation)
-{
- SAL_WARN("connectivity.firebird", "=> OResultSet static pr_error().");
-
- isc_print_status(status);
-
- SAL_WARN("connectivity.firebird", "=> OResultSet static pr_error(). "
- "PROBLEM ON " << operation << ". "
- "SQLCODE: " << isc_sqlcode(status) << ".");
-
- return 1;
-}
-
//------------------------------------------------------------------------------
// IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.OResultSet","com.sun.star.sdbc.ResultSet");
::rtl::OUString SAL_CALL OResultSet::getImplementationName( ) throw ( RuntimeException) \
@@ -100,39 +83,41 @@ sal_Bool SAL_CALL OResultSet::supportsService( const ::rtl::OUString& _rServiceN
}
// -------------------------------------------------------------------------
-OResultSet::OResultSet(OStatement_Base* pStmt)
+OResultSet::OResultSet(OStatement_Base* pStmt,
+ XSQLDA* pSqlda)
: OResultSet_BASE(m_aMutex)
,OPropertySetHelper(OResultSet_BASE::rBHelper)
,m_pStatement(pStmt)
,m_aStatement((OWeakObject*)pStmt)
,m_xMetaData(NULL)
+ ,m_pSqlda(pSqlda)
,m_nTextEncoding(pStmt->getOwnConnection()->getTextEncoding())
,m_bWasNull(sal_True)
,m_row(-1)
{
SAL_INFO("connectivity.firebird", "=> OResultSet::OResultSet().");
- isc_stmt_handle stmt = m_pStatement->getSTMTHandler();
- XSQLDA *sqlda = m_pStatement->getOUTsqlda();
- if (sqlda == NULL)
+ isc_stmt_handle stmt = 0;// m_pStatement->getSTMTHandler();
+
+ if (pSqlda == NULL)
{
m_rowCount = 0;
m_fieldCount = 0;
} else {
m_rowCount = 0;
- m_fieldCount = sqlda->sqld;
+ m_fieldCount = pSqlda->sqld;
}
ISC_STATUS_ARRAY status; // status vector
ISC_STATUS retcode;
int j = 0;
- while ((retcode = isc_dsql_fetch(status, &stmt, 1, sqlda)) == 0)
+ while ((retcode = isc_dsql_fetch(status, &stmt, 1, pSqlda)) == 0)
{
m_rowCount++;
TRow row(m_fieldCount);
XSQLVAR *var = NULL;
- for (j=0, var = sqlda->sqlvar; j < m_fieldCount; j++, var++)
+ for (j=0, var = pSqlda->sqlvar; j < m_fieldCount; j++, var++)
{
row[j] = OUString(var->sqldata, var->sqllen, RTL_TEXTENCODING_UTF8);
}
@@ -142,12 +127,12 @@ OResultSet::OResultSet(OStatement_Base* pStmt)
{
SAL_INFO("connectivity.firebird", "=> OResultSet::OResultSet(). "
"Retcode: " << retcode);
- if (pr_error(status, "fetch data"))
- return;
+// if (pr_error(status, "fetch data"))
+// return;
}
- if (isc_dsql_free_statement(status, &stmt, DSQL_close))
- if (pr_error(status, "free statement"))
- return;
+// if (isc_dsql_free_statement(status, &stmt, DSQL_close))
+// if (pr_error(status, "free statement"))
+// return;
}
// -------------------------------------------------------------------------
OResultSet::~OResultSet()
diff --git a/connectivity/source/drivers/firebird/FResultSet.hxx b/connectivity/source/drivers/firebird/FResultSet.hxx
index a27098b3c625..43ec56416313 100644
--- a/connectivity/source/drivers/firebird/FResultSet.hxx
+++ b/connectivity/source/drivers/firebird/FResultSet.hxx
@@ -86,6 +86,9 @@ namespace connectivity
OStatement_Base* m_pStatement;
::com::sun::star::uno::WeakReferenceHelper m_aStatement;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData;
+
+ XSQLDA* m_pSqlda;
+
rtl_TextEncoding m_nTextEncoding;
sal_Bool m_bWasNull;
sal_Int32 m_row;
@@ -124,7 +127,8 @@ namespace connectivity
public:
DECLARE_SERVICE_INFO();
- OResultSet( OStatement_Base* pStmt);
+ OResultSet(OStatement_Base* pStmt,
+ XSQLDA* aSqlda);
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > operator *()
diff --git a/connectivity/source/drivers/firebird/FStatement.cxx b/connectivity/source/drivers/firebird/FStatement.cxx
index d3257264fdba..f53d2f9dcdda 100644
--- a/connectivity/source/drivers/firebird/FStatement.cxx
+++ b/connectivity/source/drivers/firebird/FStatement.cxx
@@ -34,24 +34,28 @@
*************************************************************************/
#include <stdio.h>
-#include <osl/diagnose.h>
+
+#include "propertyids.hxx"
#include "FStatement.hxx"
#include "FConnection.hxx"
#include "FResultSet.hxx"
+
+#include <ibase.h>
+
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <osl/diagnose.h>
#include <osl/thread.h>
+#include <rtl/ustrbuf.hxx>
+
#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
#include <com/sun/star/sdbc/ResultSetType.hpp>
#include <com/sun/star/sdbc/FetchDirection.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
-#include <cppuhelper/typeprovider.hxx>
-#include "propertyids.hxx"
-#include <ibase.h>
-#include <comphelper/sequence.hxx>
-
-using namespace ::comphelper;
using namespace connectivity::firebird;
-//------------------------------------------------------------------------------
+
+using namespace com::sun::star;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::beans;
@@ -60,74 +64,45 @@ using namespace com::sun::star::sdbcx;
using namespace com::sun::star::container;
using namespace com::sun::star::io;
using namespace com::sun::star::util;
-//------------------------------------------------------------------------------
-
-/*
- * Print the status, the SQLCODE, and exit.
- * Also, indicate which operation the error occured on.
- */
-static int pr_error (const ISC_STATUS* status, const char* operation)
-{
- printf("[\n");
- printf("PROBLEM ON \"%s\".\n", operation);
-
- isc_print_status(status);
-
-// printf("SQLCODE:%d\n", isc_sqlcode(status)); Causes warning on some platforms
- printf("]\n");
-
- return 1;
-}
+using namespace ::comphelper;
+using namespace ::osl;
+using namespace ::rtl;
+using namespace ::std;
-//------------------------------------------------------------------------------
-OStatement_Base::OStatement_Base(OConnection* _pConnection )
+OStatement_Base::OStatement_Base(OConnection* _pConnection)
: OStatement_BASE(m_aMutex),
- OPropertySetHelper(OStatement_BASE::rBHelper),
- m_pConnection(_pConnection),
- rBHelper(OStatement_BASE::rBHelper)
+ OPropertySetHelper(OStatement_BASE::rBHelper),
+ m_pConnection(_pConnection),
+ rBHelper(OStatement_BASE::rBHelper)
{
m_pConnection->acquire();
+// // enabling the XSQLDA to accommodate up to 10 parameter items (DEFAULT)
+// m_INsqlda = (XSQLDA *)malloc(XSQLDA_LENGTH(10));
+// m_INsqlda->version = SQLDA_VERSION1;
+// m_INsqlda->sqln = 10;
+// m_INsqlda->sqld = 0;
- ISC_STATUS_ARRAY status; // status vector
- isc_db_handle db = m_pConnection->getDBHandler(); // database handle
-
- // enabling the XSQLDA to accommodate up to 10 select-list items (DEFAULT)
- m_OUTsqlda = (XSQLDA *)malloc(XSQLDA_LENGTH(10));
- m_OUTsqlda->version = SQLDA_VERSION1;
- m_OUTsqlda->sqln = 10;
- m_OUTsqlda->sqld = 0;
-
- // enabling the XSQLDA to accommodate up to 10 parameter items (DEFAULT)
- m_INsqlda = (XSQLDA *)malloc(XSQLDA_LENGTH(10));
- m_INsqlda->version = SQLDA_VERSION1;
- m_INsqlda->sqln = 10;
- m_INsqlda->sqld = 0;
-
- m_STMTHandler = 0; // Set handle to NULL before allocation.
- if (isc_dsql_allocate_statement(status, &db, &m_STMTHandler))
- if (pr_error(status, "allocate statement"))
- return;
}
-//-----------------------------------------------------------------------------
+
OStatement_Base::~OStatement_Base()
{
}
-//------------------------------------------------------------------------------
+
void OStatement_Base::disposeResultSet()
{
//free the cursor if alive
- Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY);
- if (xComp.is())
- xComp->dispose();
- m_xResultSet = Reference< XResultSet>();
+// uno::Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY);
+// if (xComp.is())
+// xComp->dispose();
+// m_xResultSet = uno::Reference< XResultSet>();
}
-//------------------------------------------------------------------------------
+
void OStatement_BASE2::disposing()
{
SAL_INFO("connectivity.firebird", "=> OStatement_BASE2::disposing().");
- ::osl::MutexGuard aGuard(m_aMutex);
+ MutexGuard aGuard(m_aMutex);
disposeResultSet();
@@ -135,25 +110,20 @@ void OStatement_BASE2::disposing()
m_pConnection->release();
m_pConnection = NULL;
- if (NULL != m_OUTsqlda)
- {
- int i;
- XSQLVAR *var;
- for (i=0, var = m_OUTsqlda->sqlvar; i < m_OUTsqlda->sqld; i++, var++)
- free(var->sqldata);
- free(m_OUTsqlda);
- m_OUTsqlda = NULL;
- }
- if (NULL != m_INsqlda)
- {
- free(m_INsqlda);
- m_INsqlda = NULL;
- }
-
- ISC_STATUS_ARRAY status; // status vector
- if (isc_dsql_free_statement(status, &m_STMTHandler, DSQL_drop))
- if (pr_error(status, "fetch data"))
- return;
+// if (NULL != m_OUTsqlda)
+// {
+// int i;
+// XSQLVAR *var;
+// for (i=0, var = m_OUTsqlda->sqlvar; i < m_OUTsqlda->sqld; i++, var++)
+// free(var->sqldata);
+// free(m_OUTsqlda);
+// m_OUTsqlda = NULL;
+// }
+// if (NULL != m_INsqlda)
+// {
+// free(m_INsqlda);
+// m_INsqlda = NULL;
+// }
dispose_ChildImpl();
OStatement_Base::disposing();
@@ -175,9 +145,9 @@ Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(Runtime
Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) throw(RuntimeException)
{
::cppu::OTypeCollection aTypes(
- ::cppu::UnoType< Reference< XMultiPropertySet > >::get(),
- ::cppu::UnoType< Reference< XFastPropertySet > >::get(),
- ::cppu::UnoType< Reference< XPropertySet > >::get());
+ ::cppu::UnoType< uno::Reference< XMultiPropertySet > >::get(),
+ ::cppu::UnoType< uno::Reference< XFastPropertySet > >::get(),
+ ::cppu::UnoType< uno::Reference< XPropertySet > >::get());
return concatSequences(aTypes.getTypes(),OStatement_BASE::getTypes());
}
@@ -185,7 +155,7 @@ Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) throw(RuntimeException)
void SAL_CALL OStatement_Base::cancel( ) throw(RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
// cancel the current sql statement
}
@@ -196,299 +166,315 @@ void SAL_CALL OStatement_Base::close( ) throw(SQLException, RuntimeException)
SAL_INFO("connectivity.firebird", "=> OStatement_Base::close().");
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
}
dispose();
}
-// -------------------------------------------------------------------------
-void SAL_CALL OStatement::clearBatch( ) throw(SQLException, RuntimeException)
+Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException)
{
- // if you support batches clear it here
+ Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this));
+ if(!aRet.hasValue())
+ aRet = OStatement_Base::queryInterface(rType);
+ return aRet;
}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL OStatement_Base::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
-{
- static const sal_Unicode pattern('"');
- static const sal_Unicode empty(' ');
- OUString query = sql.replace(pattern, empty);
- SAL_INFO("connectivity.firebird", "=> OStatement_Base::executeQuery(). "
- "Got called with sql: " << query);
-
- ::osl::MutexGuard aGuard( m_aMutex );
+// ---- XStatement -----------------------------------------------------------
+sal_Int32 SAL_CALL OStatement_Base::executeUpdate(const OUString& sql)
+ throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
- ISC_STATUS_ARRAY status; // status vector
- isc_db_handle db = m_pConnection->getDBHandler(); // database handle
-
- m_TRANSHandler = 0L; // transaction handle
- if (isc_start_transaction(status, &m_TRANSHandler, 1, &db, 0, NULL))
- if (pr_error(status, "start transaction"))
- return sal_False;
-
- char *sqlStr = strdup(OUStringToOString( query, RTL_TEXTENCODING_UTF8 ).getStr());
- if (isc_dsql_execute_immediate(status, &db, &m_TRANSHandler, 0, sqlStr, 1, NULL))
- if (pr_error(status, "create table"))
- return sal_False;
- free(sqlStr);
+ int aErr = isc_dsql_execute_immediate(m_statusVector,
+ &m_pConnection->getDBHandle(),
+ &m_pConnection->getTransaction(),
+ 0,
+ OUStringToOString(sql, RTL_TEXTENCODING_UTF8).getStr(),
+ 1,
+ NULL);
- if (isc_commit_transaction(status, &m_TRANSHandler))
- if (pr_error(status, "commit transaction"))
- return sal_False;
+ if (aErr)
+ SAL_WARN("connectivity.firebird", "isc_dsql_execute_immediate failed" );
- // returns true when a resultset is available
- return sal_False;
+ m_pConnection->evaluateStatusVector(m_statusVector, sql);
+ // TODO: get number of changed rows with SELECT ROW_COUNT (use executeQuery)
+ // return getUpdateCount();
+ return 0;
}
-void SAL_CALL OStatement_Base::prepareQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+int OStatement_Base::prepareAndDescribeStatement(const OUString& sql,
+ isc_stmt_handle& aStatementHandle,
+ XSQLDA*& pOutSqlda,
+ XSQLVAR*& pVar)
{
- ISC_STATUS_ARRAY status; // status vector
- isc_db_handle db = m_pConnection->getDBHandler(); // database handle
-
- m_TRANSHandler = 0L; // transaction handle
- if (isc_start_transaction(status, &m_TRANSHandler, 1, &db, 0, NULL))
- if (pr_error(status, "start transaction"))
- return;
-
- // sets the statement handle (stmt) to refer to the parsed format.
- char *sqlStr = strdup(OUStringToOString( sql, RTL_TEXTENCODING_UTF8 ).getStr());
- if (isc_dsql_prepare(status, &m_TRANSHandler, &m_STMTHandler, 0, sqlStr, 1, m_OUTsqlda))
- if (pr_error(status, "prepare statement"))
- return;
- free(sqlStr);
+ if (!pOutSqlda)
+ {
+ pOutSqlda = (XSQLDA*) malloc(XSQLDA_LENGTH(10));
+ pOutSqlda->version = SQLDA_VERSION1;
+ pOutSqlda->sqln = 10;
+ }
- // fill the input XSQLDA with information about the parameters
- if (isc_dsql_describe_bind(status, &m_STMTHandler, 1, m_INsqlda))
- if (pr_error(status, "bind statement"))
- return;
+ int aErr = 0;
- XSQLVAR *var = NULL;
- int i, dtype;
+ aErr = isc_dsql_allocate_statement(m_statusVector,
+ &m_pConnection->getDBHandle(),
+ &aStatementHandle);
- // determine if the input descriptor can accommodate the number of parameters
- // contained in the statement.
- if (0 == m_INsqlda->sqld)
+ if (aErr)
{
- free(m_INsqlda);
- m_INsqlda = NULL;
+ SAL_WARN("connectivity.firebird", "isc_dsql_allocate_statement failed");
+ return aErr;
}
else
{
- if (m_INsqlda->sqld > m_INsqlda->sqln)
- {
- int n = m_INsqlda->sqld;
- free(m_INsqlda);
- m_INsqlda = (XSQLDA *)malloc(XSQLDA_LENGTH(n));
- m_INsqlda->sqln = n;
- m_INsqlda->version = SQLDA_VERSION1;
- if (isc_dsql_describe_bind(status, &m_STMTHandler, 1, m_INsqlda))
- if (pr_error(status, "bind statement 2"))
- return;
- }
+ aErr = isc_dsql_prepare(m_statusVector,
+ &m_pConnection->getTransaction(),
+ &aStatementHandle,
+ 0,
+ OUStringToOString(sql, RTL_TEXTENCODING_UTF8).getStr(),
+ 1,
+ NULL);
}
- // fill the output XSQLDA with information about the select-list items.
- if (isc_dsql_describe(status, &m_STMTHandler, 1, m_OUTsqlda))
- if (pr_error(status, "describe statement"))
- return;
+ if (aErr)
+ {
+ SAL_WARN("connectivity.firebird", "isc_dsql_prepare failed");
+ return aErr;
+ }
+ else
+ {
+ aErr = isc_dsql_describe(m_statusVector,
+ &aStatementHandle,
+ 1,
+ pOutSqlda);
+ }
- // determine if the output descriptor can accommodate the number of select-list
- // items specified in the statement.
- if (m_OUTsqlda->sqld > m_OUTsqlda->sqln)
+ // Ensure we have enough space in pOutSqlda
+ if (aErr)
+ {
+ SAL_WARN("connectivity.firebird", "isc_dsql_describe failed");
+ return aErr;
+ }
+ else if (!aErr && (pOutSqlda->sqld > pOutSqlda->sqln))
{
- int n = m_OUTsqlda->sqld;
- free(m_OUTsqlda);
- m_OUTsqlda = (XSQLDA *)malloc(XSQLDA_LENGTH(n));
- m_OUTsqlda->sqln = n;
- m_OUTsqlda->version = SQLDA_VERSION1;
- if (isc_dsql_describe(status, &m_STMTHandler, 1, m_OUTsqlda))
- if (pr_error(status, "describe statement 2"))
- return;
+ int n = pOutSqlda->sqld;
+ free(pOutSqlda);
+ pOutSqlda = (XSQLDA*) malloc(XSQLDA_LENGTH(n));
+ pOutSqlda->version = SQLDA_VERSION1;
+ aErr = isc_dsql_describe(m_statusVector,
+ &aStatementHandle,
+ 1,
+ pOutSqlda);
}
+ pVar = pOutSqlda->sqlvar;
// Process each XSQLVAR parameter structure in the output XSQLDA
- for (i=0, var = m_OUTsqlda->sqlvar; i < m_OUTsqlda->sqld; i++, var++)
+ if (aErr)
{
- dtype = (var->sqltype & ~1); /* drop flag bit for now */
- switch(dtype) {
- case SQL_VARYING:
- var->sqltype = SQL_TEXT;
- var->sqldata = (char *)malloc(sizeof(char)*var->sqllen + 2);
- break;
- case SQL_TEXT:
- var->sqldata = (char *)malloc(sizeof(char)*var->sqllen);
- break;
- case SQL_LONG:
- var->sqldata = (char *)malloc(sizeof(long));
- break;
- case SQL_SHORT:
- var->sqldata = (char *)malloc(sizeof(char)*var->sqllen);
- break;
- case SQL_FLOAT:
- var->sqldata = (char *)malloc(sizeof(double));
- break;
- case SQL_DOUBLE:
- var->sqldata = (char *)malloc(sizeof(double));
- break;
- case SQL_D_FLOAT:
- var->sqldata = (char *)malloc(sizeof(double));
- break;
- case SQL_TIMESTAMP:
- var->sqldata = (char *)malloc(sizeof(time_t));
- break;
- case SQL_INT64:
- var->sqldata = (char *)malloc(sizeof(int));
- break;
- /* process remaining types */
- default:
- OSL_ASSERT( false );
- break;
- }
- if (var->sqltype & 1)
+ SAL_WARN("connectivity.firebird","isc_dsql_describe failed when resizing pOutSqlda");
+ return aErr;
+ }
+ else
+ {
+ for (int i=0; i < pOutSqlda->sqld; i++, pVar++)
{
- /* allocate variable to hold NULL status */
- var->sqlind = (short *)malloc(sizeof(short));
+ int dtype = (pVar->sqltype & ~1); /* drop flag bit for now */
+ switch(dtype) {
+ case SQL_VARYING:
+ pVar->sqltype = SQL_TEXT;
+ pVar->sqldata = (char *)malloc(sizeof(char)*pVar->sqllen + 2);
+ break;
+ case SQL_TEXT:
+ pVar->sqldata = (char *)malloc(sizeof(char)*pVar->sqllen);
+ break;
+ case SQL_LONG:
+ pVar->sqldata = (char *)malloc(sizeof(long));
+ break;
+ case SQL_SHORT:
+ pVar->sqldata = (char *)malloc(sizeof(char)*pVar->sqllen);
+ break;
+ case SQL_FLOAT:
+ pVar->sqldata = (char *)malloc(sizeof(double));
+ break;
+ case SQL_DOUBLE:
+ pVar->sqldata = (char *)malloc(sizeof(double));
+ break;
+ case SQL_D_FLOAT:
+ pVar->sqldata = (char *)malloc(sizeof(double));
+ break;
+ case SQL_TIMESTAMP:
+ pVar->sqldata = (char *)malloc(sizeof(time_t));
+ break;
+ case SQL_INT64:
+ pVar->sqldata = (char *)malloc(sizeof(int));
+ break;
+ /* process remaining types */
+ default:
+ OSL_ASSERT( false );
+ break;
+ }
+ if (pVar->sqltype & 1)
+ {
+ /* allocate variable to hold NULL status */
+ pVar->sqlind = (short *)malloc(sizeof(short));
+ }
}
}
-}
-// -------------------------------------------------------------------------
+ return aErr;
+}
-Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+uno::Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery(const OUString& sql) throw(SQLException, RuntimeException)
{
- SAL_INFO("connectivity.firebird", "=> OStatement_Base::executeQuery(). "
- "Got called with sql: " << sql);
-
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
- ISC_STATUS_ARRAY status; // status vector
-
- prepareQuery(sql);
+ XSQLDA* pOutSqlda = 0;
+ XSQLVAR* pVar = 0;
+ isc_stmt_handle aStatementHandle = 0;
+ int aErr = 0;
- if (isc_dsql_execute(status, &m_TRANSHandler, &m_STMTHandler, 1, m_INsqlda))
- if (pr_error(status, "execute query"))
- return NULL;
- Reference< OResultSet > pResult( new OResultSet( this) );
- //initializeResultSet( pResult.get() );
- Reference< XResultSet > xRS = pResult.get();
+ aErr = prepareAndDescribeStatement(sql,
+ aStatementHandle,
+ pOutSqlda,
+ pVar);
- if (isc_commit_transaction(status, &m_TRANSHandler))
- if (pr_error(status, "commit transaction"))
- return NULL;
-
- SAL_INFO("connectivity.firebird", "=> OStatement::executeQuery(). "
- "Query executed.");
+ if (aErr)
+ {
+ SAL_WARN("connectivity.firebird", "prepareAndDescribeStatement failed");
+ }
+ else
+ {
+ aErr = isc_dsql_execute(m_statusVector,
+ &m_pConnection->getTransaction(),
+ &aStatementHandle,
+ 1,
+ NULL);
+ if (aErr)
+ SAL_WARN("connectivity.firebird", "isc_dsql_execute failed" );
+ }
- close();
+ uno::Reference< OResultSet > pResult(new OResultSet(this, pOutSqlda));
+ //initializeResultSet( pResult.get() );
+ m_xResultSet = pResult.get();
- return xRS;
+ // TODO: deal with cleanup
+// close();
+ m_pConnection->evaluateStatusVector(m_statusVector, sql);
+ return m_xResultSet;
}
+sal_Bool SAL_CALL OStatement_Base::execute(const OUString& sql) throw(SQLException, RuntimeException)
+{
+ // TODO: is this needed, and for all execute methods>
+ static const sal_Unicode pattern('"');
+ static const sal_Unicode empty(' ');
+ OUString query = sql.replace(pattern, empty);
-// -------------------------------------------------------------------------
+ // TODO: use the isc_ validation functions?
-Reference< XConnection > SAL_CALL OStatement_Base::getConnection( ) throw(SQLException, RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
+ SAL_INFO("connectivity.firebird", "=> OStatement_Base::executeQuery(). "
+ "Got called with sql: " << query);
+
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
- // just return our connection here
- return (Reference< XConnection >)m_pConnection;
-}
-// -----------------------------------------------------------------------------
-sal_Int32 SAL_CALL OStatement_Base::getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
-{
- return 0;
-}
-// -------------------------------------------------------------------------
+ XSQLDA* pOutSqlda = 0;
+ XSQLVAR* pVar = 0;
+ isc_stmt_handle aStatementHandle = 0;
+ int aErr = 0;
-Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException)
-{
- Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this));
- if(!aRet.hasValue())
- aRet = OStatement_Base::queryInterface(rType);
- return aRet;
-}
-// -------------------------------------------------------------------------
-void SAL_CALL OStatement::addBatch( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ aErr = prepareAndDescribeStatement(sql,
+ aStatementHandle,
+ pOutSqlda,
+ pVar);
+ if (aErr)
+ {
+ SAL_WARN("connectivity.firebird", "isc_dsql_execute failed" );
+ }
+ else
+ {
+ aErr = isc_dsql_execute(m_statusVector,
+ &m_pConnection->getTransaction(),
+ &aStatementHandle,
+ 1,
+ NULL);
+ if (aErr)
+ SAL_WARN("connectivity.firebird", "isc_dsql_execute failed" );
+ }
- m_aBatchList.push_back(sql);
-}
-// -------------------------------------------------------------------------
-Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch( ) throw(SQLException, RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ m_pConnection->evaluateStatusVector(m_statusVector, sql);
- return Sequence< sal_Int32 >();
+ // returns true when a resultset is available
+ return sal_False;
}
-// -------------------------------------------------------------------------
-
-sal_Int32 SAL_CALL OStatement_Base::executeUpdate( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+uno::Reference< XConnection > SAL_CALL OStatement_Base::getConnection()
+ throw(SQLException, RuntimeException)
{
- (void) sql;
- ::osl::MutexGuard aGuard( m_aMutex );
+ MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
- // the return values gives information about how many rows are affected by executing the sql statement
- return 0;
-
+ return (uno::Reference< XConnection >)m_pConnection;
}
-// -------------------------------------------------------------------------
-Reference< XResultSet > SAL_CALL OStatement_Base::getResultSet( ) throw(SQLException, RuntimeException)
+// ---- XMultipleResults - UNSUPPORTED ----------------------------------------
+uno::Reference< XResultSet > SAL_CALL OStatement_Base::getResultSet() throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ // TODO: verify we really can't support this
+ return uno::Reference< XResultSet >();
+// MutexGuard aGuard( m_aMutex );
+// checkDisposed(OStatement_BASE::rBHelper.bDisposed);
-// return our save resultset here
- return m_xResultSet;
+// return m_xResultSet;
}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL OStatement_Base::getMoreResults( ) throw(SQLException, RuntimeException)
+sal_Bool SAL_CALL OStatement_Base::getMoreResults() throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(OStatement_BASE::rBHelper.bDisposed);
-
- // if your driver supports more than only one resultset
- // and has one more at this moment return true
+ // TODO: verify we really can't support this
return sal_False;
+// MutexGuard aGuard( m_aMutex );
+// checkDisposed(OStatement_BASE::rBHelper.bDisposed);
}
-// -------------------------------------------------------------------------
-// -------------------------------------------------------------------------
-Any SAL_CALL OStatement_Base::getWarnings( ) throw(SQLException, RuntimeException)
+sal_Int32 SAL_CALL OStatement_Base::getUpdateCount() throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ // TODO: verify we really can't support this
+ return 0;
+}
+// ---- XBatchExecution - UNSUPPORTED ----------------------------------------
+void SAL_CALL OStatement::addBatch(const OUString& sql)
+ throw(SQLException, RuntimeException)
+{
+ (void) sql;
+}
- return makeAny(m_aLastWarning);
+void SAL_CALL OStatement::clearBatch() throw(SQLException, RuntimeException)
+{
}
-// -------------------------------------------------------------------------
-// -------------------------------------------------------------------------
-void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeException)
+Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch() throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ return Sequence< sal_Int32 >();
+}
+// ---- XWarningsSupplier - UNSUPPORTED ----------------------------------------
+Any SAL_CALL OStatement_Base::getWarnings() throw(SQLException, RuntimeException)
+{
+ return Any();
+}
- m_aLastWarning = SQLWarning();
+void SAL_CALL OStatement_Base::clearWarnings() throw(SQLException, RuntimeException)
+{
}
-// -------------------------------------------------------------------------
+
::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const
{
// this properties are define by the service statement
@@ -496,7 +482,7 @@ void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeExce
Sequence< Property > aProps(10);
Property* pProperties = aProps.getArray();
sal_Int32 nPos = 0;
- DECL_PROP0(CURSORNAME, ::rtl::OUString);
+ DECL_PROP0(CURSORNAME, OUString);
DECL_BOOL_PROP0(ESCAPEPROCESSING);
DECL_PROP0(FETCHDIRECTION,sal_Int32);
DECL_PROP0(FETCHSIZE, sal_Int32);
@@ -510,7 +496,7 @@ void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeExce
return new ::cppu::OPropertyArrayHelper(aProps);
}
-// -------------------------------------------------------------------------
+
::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper()
{
return *const_cast<OStatement_Base*>(this)->getArrayHelper();
@@ -521,7 +507,7 @@ sal_Bool OStatement_Base::convertFastPropertyValue(
Any & rOldValue,
sal_Int32 nHandle,
const Any& rValue )
- throw (::com::sun::star::lang::IllegalArgumentException)
+ throw (IllegalArgumentException)
{
(void) rConvertedValue;
(void) rOldValue;
@@ -572,33 +558,31 @@ void OStatement_Base::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
;
}
}
-// -------------------------------------------------------------------------
+
IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.OStatement","com.sun.star.sdbc.Statement");
-// -----------------------------------------------------------------------------
+
void SAL_CALL OStatement_Base::acquire() throw()
{
OStatement_BASE::acquire();
}
-// -----------------------------------------------------------------------------
+
void SAL_CALL OStatement_Base::release() throw()
{
OStatement_BASE::release();
}
-// -----------------------------------------------------------------------------
+
void SAL_CALL OStatement::acquire() throw()
{
OStatement_BASE2::acquire();
}
-// -----------------------------------------------------------------------------
+
void SAL_CALL OStatement::release() throw()
{
OStatement_BASE2::release();
}
-// -----------------------------------------------------------------------------
-Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OStatement_Base::getPropertySetInfo( ) throw(RuntimeException)
+
+uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OStatement_Base::getPropertySetInfo( ) throw(RuntimeException)
{
return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
}
-// -----------------------------------------------------------------------------
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/firebird/FStatement.hxx b/connectivity/source/drivers/firebird/FStatement.hxx
index 824d0a3461c4..fc7e0ebb6c02 100644
--- a/connectivity/source/drivers/firebird/FStatement.hxx
+++ b/connectivity/source/drivers/firebird/FStatement.hxx
@@ -70,18 +70,17 @@ namespace connectivity
public OPropertyArrayUsageHelper<OStatement_Base>
{
- ::com::sun::star::sdbc::SQLWarning m_aLastWarning;
protected:
::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created
// for this Statement
::std::list< ::rtl::OUString> m_aBatchList;
- OConnection* m_pConnection; // The owning Connection object
- isc_stmt_handle m_STMTHandler;
- isc_tr_handle m_TRANSHandler;
+ OConnection* m_pConnection;
+
XSQLDA * m_OUTsqlda;
XSQLDA * m_INsqlda;
+ ISC_STATUS_ARRAY m_statusVector;
protected:
void disposeResultSet();
@@ -103,13 +102,11 @@ namespace connectivity
virtual void SAL_CALL getFastPropertyValue(
::com::sun::star::uno::Any& rValue,
sal_Int32 nHandle) const;
- virtual void SAL_CALL prepareQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
virtual ~OStatement_Base();
public:
::cppu::OBroadcastHelper& rBHelper;
- OStatement_Base(OConnection* _pConnection );
+ OStatement_Base(OConnection* _pConnection);
using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
// OComponentHelper
@@ -129,24 +126,30 @@ namespace connectivity
virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
- // XWarningsSupplier
+
+ // XWarningsSupplier - UNSUPPORTED
virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XMultipleResults - UNSUPPORTED
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
// XCancellable
virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException);
// XCloseable
virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- // XMultipleResults
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
// other methods
OConnection* getOwnConnection() const { return m_pConnection;}
- inline isc_stmt_handle getSTMTHandler() const { return m_STMTHandler; }
inline XSQLDA * getOUTsqlda() const { return m_OUTsqlda; }
inline XSQLDA * getINsqlda() const { return m_INsqlda; }
+
+ int prepareAndDescribeStatement(const OUString& sql,
+ isc_stmt_handle& aStatementHandle,
+ XSQLDA*& pOutSqlda,
+ XSQLVAR*& pVar);
};
class OStatement_BASE2 :public OStatement_Base
@@ -155,8 +158,11 @@ namespace connectivity
{
friend class OSubComponent<OStatement_BASE2, OStatement_BASE>;
public:
- OStatement_BASE2(OConnection* _pConnection ) : OStatement_Base(_pConnection ),
- OSubComponent<OStatement_BASE2, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this){}
+ OStatement_BASE2(OConnection* _pConnection)
+ : OStatement_Base(_pConnection),
+ OSubComponent<OStatement_BASE2, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this)
+ {}
+
// OComponentHelper
virtual void SAL_CALL disposing(void);
// XInterface
@@ -171,13 +177,16 @@ namespace connectivity
virtual ~OStatement(){}
public:
// a constructor, which is required for returning objects:
- OStatement( OConnection* _pConnection) : OStatement_BASE2( _pConnection){}
+ OStatement( OConnection* _pConnection)
+ : OStatement_BASE2( _pConnection)
+ {}
+
DECLARE_SERVICE_INFO();
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL acquire() throw();
virtual void SAL_CALL release() throw();
- // XBatchExecution
+ // XBatchExecution - UNSUPPORTED
virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);