summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--connectivity/source/drivers/firebird/PreparedStatement.cxx15
-rw-r--r--connectivity/source/drivers/firebird/PreparedStatement.hxx3
-rw-r--r--connectivity/source/drivers/firebird/Statement.cxx12
-rw-r--r--connectivity/source/drivers/firebird/Statement.hxx6
-rw-r--r--connectivity/source/drivers/firebird/StatementCommonBase.cxx63
-rw-r--r--connectivity/source/drivers/firebird/StatementCommonBase.hxx3
6 files changed, 21 insertions, 81 deletions
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx
index d5e1213a93a6..3ddf3b572c60 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx
@@ -56,7 +56,6 @@ OPreparedStatement::OPreparedStatement( Connection* _pConnection,
:OStatementCommonBase(_pConnection)
,m_aTypeInfo(_TypeInfo)
,m_sSqlStatement(sql)
- ,m_pOutSqlda(0)
,m_pInSqlda(0)
{
SAL_INFO("connectivity.firebird", "OPreparedStatement(). "
@@ -82,8 +81,8 @@ void OPreparedStatement::ensurePrepared()
}
prepareAndDescribeStatement(m_sSqlStatement,
- m_pOutSqlda,
- m_pInSqlda);
+ m_aOutSqlda,
+ m_pInSqlda);
aErr = isc_dsql_describe_bind(m_statusVector,
@@ -152,7 +151,7 @@ Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData()
ensurePrepared();
if(!m_xMetaData.is())
- m_xMetaData = new OResultSetMetaData(m_pConnection, m_pOutSqlda);
+ m_xMetaData = new OResultSetMetaData(m_pConnection, &m_aOutSqlda);
return m_xMetaData;
}
@@ -169,12 +168,6 @@ void SAL_CALL OPreparedStatement::close() throw(SQLException, RuntimeException,
free(m_pInSqlda);
m_pInSqlda = 0;
}
- if (m_pOutSqlda)
- {
- freeSQLVAR(m_pOutSqlda);
- free(m_pOutSqlda);
- m_pOutSqlda = 0;
- }
}
void SAL_CALL OPreparedStatement::disposing()
@@ -286,7 +279,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute()
m_aMutex,
uno::Reference< XInterface >(*this),
m_aStatementHandle,
- m_pOutSqlda);
+ &m_aOutSqlda);
if (getStatementChangeCount() > 0)
m_pConnection->notifyDatabaseModified();
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.hxx b/connectivity/source/drivers/firebird/PreparedStatement.hxx
index 90e89a8c2362..688063acc0cd 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.hxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.hxx
@@ -21,6 +21,7 @@
#define CONNECTIVITY_FIREBIRD_PREPAREDSTATEMENT_HXX
#include "Statement.hxx"
+#include "wrapper/Sqlda.hxx"
#include <cppuhelper/implbase5.hxx>
@@ -69,7 +70,7 @@ namespace connectivity
::rtl::OUString m_sSqlStatement;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData;
- XSQLDA* m_pOutSqlda;
+ wrapper::Sqlda m_aOutSqlda;
XSQLDA* m_pInSqlda;
void checkParameterIndex(sal_Int32 nParameterIndex)
throw(::com::sun::star::sdbc::SQLException,
diff --git a/connectivity/source/drivers/firebird/Statement.cxx b/connectivity/source/drivers/firebird/Statement.cxx
index 94b947409245..eb185a4c89aa 100644
--- a/connectivity/source/drivers/firebird/Statement.cxx
+++ b/connectivity/source/drivers/firebird/Statement.cxx
@@ -34,6 +34,7 @@
#include <com/sun/star/sdbc/FetchDirection.hpp>
using namespace connectivity::firebird;
+using namespace connectivity::firebird::wrapper;
using namespace com::sun::star;
using namespace com::sun::star::uno;
@@ -84,13 +85,6 @@ void OStatement::disposeResultSet()
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
OStatementCommonBase::disposeResultSet();
-
- if (m_pSqlda)
- {
- freeSQLVAR(m_pSqlda);
- free(m_pSqlda);
- m_pSqlda = 0;
- }
}
// ---- XStatement -----------------------------------------------------------
@@ -115,7 +109,7 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s
disposeResultSet();
prepareAndDescribeStatement(sql,
- m_pSqlda);
+ m_aSqlda);
aErr = isc_dsql_execute(m_statusVector,
&m_pConnection->getTransaction(),
@@ -129,7 +123,7 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s
m_aMutex,
uno::Reference< XInterface >(*this),
m_aStatementHandle,
- m_pSqlda);
+ &m_aSqlda);
// TODO: deal with cleanup
diff --git a/connectivity/source/drivers/firebird/Statement.hxx b/connectivity/source/drivers/firebird/Statement.hxx
index 15b81f224bee..ed183766ddad 100644
--- a/connectivity/source/drivers/firebird/Statement.hxx
+++ b/connectivity/source/drivers/firebird/Statement.hxx
@@ -21,6 +21,7 @@
#define CONNECTIVITY_FIREBIRD_STATEMENT_HXX
#include "StatementCommonBase.hxx"
+#include "wrapper/Sqlda.hxx"
#include <cppuhelper/implbase1.hxx>
@@ -40,13 +41,12 @@ namespace connectivity
protected:
virtual ~OStatement(){}
- XSQLDA* m_pSqlda;
+ wrapper::Sqlda m_aSqlda;
public:
// a constructor, which is required for returning objects:
OStatement( Connection* _pConnection)
- : OStatementCommonBase( _pConnection),
- m_pSqlda(0)
+ : OStatementCommonBase( _pConnection)
{}
virtual void disposeResultSet();
diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.cxx b/connectivity/source/drivers/firebird/StatementCommonBase.cxx
index 93770c2ffdd6..8a12fa95d160 100644
--- a/connectivity/source/drivers/firebird/StatementCommonBase.cxx
+++ b/connectivity/source/drivers/firebird/StatementCommonBase.cxx
@@ -28,6 +28,7 @@
#include <TConnection.hxx>
using namespace ::connectivity::firebird;
+using namespace ::connectivity::firebird::wrapper;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -123,35 +124,22 @@ void SAL_CALL OStatementCommonBase::close()
}
void OStatementCommonBase::prepareAndDescribeStatement(const OUString& sql,
- XSQLDA*& pOutSqlda,
- XSQLDA* pInSqlda)
+ Sqlda& rOutSqlda,
+ XSQLDA* pInSqlda)
throw (SQLException)
{
MutexGuard aGuard(m_aMutex);
freeStatementHandle();
- if (!pOutSqlda)
- {
- pOutSqlda = (XSQLDA*) malloc(XSQLDA_LENGTH(10));
- pOutSqlda->version = SQLDA_VERSION1;
- pOutSqlda->sqln = 10;
- }
-
ISC_STATUS aErr = 0;
- aErr = isc_dsql_allocate_statement(m_statusVector,
- &m_pConnection->getDBHandle(),
- &m_aStatementHandle);
-
- if (aErr)
- {
- free(pOutSqlda);
- pOutSqlda = 0;
+ if (isc_dsql_allocate_statement(m_statusVector,
+ &m_pConnection->getDBHandle(),
+ &m_aStatementHandle))
evaluateStatusVector(m_statusVector,
"isc_dsql_allocate_statement",
*this);
- }
aErr = isc_dsql_prepare(m_statusVector,
&m_pConnection->getTransaction(),
@@ -164,49 +152,12 @@ void OStatementCommonBase::prepareAndDescribeStatement(const OUString& sql,
if (aErr)
{
// TODO: free statement handle?
- free(pOutSqlda);
- pOutSqlda = 0;
evaluateStatusVector(m_statusVector,
"isc_dsql_prepare",
*this);
}
- aErr = isc_dsql_describe(m_statusVector,
- &m_aStatementHandle,
- 1,
- pOutSqlda);
-
-
- if (aErr)
- {
- // TODO: free statement handle, etc.?
- free(pOutSqlda);
- pOutSqlda = 0;
- evaluateStatusVector(m_statusVector,
- "isc_dsql_describe",
- *this);
- }
-
- // Ensure we have enough space in pOutSqlda
- if (pOutSqlda->sqld > pOutSqlda->sqln)
- {
- int n = pOutSqlda->sqld;
- free(pOutSqlda);
- pOutSqlda = (XSQLDA*) malloc(XSQLDA_LENGTH(n));
- pOutSqlda->version = SQLDA_VERSION1;
- aErr = isc_dsql_describe(m_statusVector,
- &m_aStatementHandle,
- 1,
- pOutSqlda);
- }
-
- // Process each XSQLVAR parameter structure in the output XSQLDA
- if (aErr)
- evaluateStatusVector(m_statusVector,
- "isc_dsql_describe",
- *this);
-
- mallocSQLVAR(pOutSqlda);
+ rOutSqlda.describeStatement(m_aStatementHandle);
}
// ---- XMultipleResults - UNSUPPORTED ----------------------------------------
diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.hxx b/connectivity/source/drivers/firebird/StatementCommonBase.hxx
index b1e04114eb93..edd201687397 100644
--- a/connectivity/source/drivers/firebird/StatementCommonBase.hxx
+++ b/connectivity/source/drivers/firebird/StatementCommonBase.hxx
@@ -21,6 +21,7 @@
#define CONNECTIVITY_FIREBIRD_STATEMENT_BASE_HXX
#include "Connection.hxx"
+#include "wrapper/Sqlda.hxx"
#include <ibase.h>
@@ -90,7 +91,7 @@ namespace connectivity
virtual ~OStatementCommonBase();
void prepareAndDescribeStatement(const OUString& sqlIn,
- XSQLDA*& pOutSqlda,
+ wrapper::Sqlda& aOutSqlda,
XSQLDA* pInSqlda=0)
throw (::com::sun::star::sdbc::SQLException);