summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-03-19 20:51:59 +0000
committerAndrzej Hunt <andrzej.hunt@collabora.com>2014-03-19 20:51:59 +0000
commitdc0af89801e0f6a2105487915259a879533083df (patch)
tree089887385ec99b97a7e3dd93e3c82cf36eb795bf
parent2a7ce8dc71129c0d90ed9447bd37805a34c17139 (diff)
firebird-sdbc: upgrade PreparedStatement to use Sqlda wrapper.
Change-Id: If79a8b1cfe76292054db4417c452f6443e663fda
-rw-r--r--connectivity/source/drivers/firebird/PreparedStatement.cxx55
-rw-r--r--connectivity/source/drivers/firebird/PreparedStatement.hxx2
2 files changed, 8 insertions, 49 deletions
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx
index 3ddf3b572c60..4814b9112f15 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_pInSqlda(0)
{
SAL_INFO("connectivity.firebird", "OPreparedStatement(). "
"sql: " << sql);
@@ -71,46 +70,12 @@ void OPreparedStatement::ensurePrepared()
if (m_aStatementHandle)
return;
- ISC_STATUS aErr = 0;
-
- if (!m_pInSqlda)
- {
- m_pInSqlda = (XSQLDA*) malloc(XSQLDA_LENGTH(10));
- m_pInSqlda->version = SQLDA_VERSION1;
- m_pInSqlda->sqln = 10;
- }
-
prepareAndDescribeStatement(m_sSqlStatement,
m_aOutSqlda,
- m_pInSqlda);
-
-
- aErr = isc_dsql_describe_bind(m_statusVector,
- &m_aStatementHandle,
- 1,
- m_pInSqlda);
+ &m_aInSqlda);
- if (aErr)
- {
- SAL_WARN("connectivity.firebird", "isc_dsql_describe_bind failed");
- }
- else if (m_pInSqlda->sqld > m_pInSqlda->sqln) // Not large enough
- {
- short nItems = m_pInSqlda->sqld;
- free(m_pInSqlda);
- m_pInSqlda = (XSQLDA*) malloc(XSQLDA_LENGTH(nItems));
- m_pInSqlda->version = SQLDA_VERSION1;
- m_pInSqlda->sqln = nItems;
- isc_dsql_describe_bind(m_statusVector,
- &m_aStatementHandle,
- 1,
- m_pInSqlda);
- }
- if (!aErr)
- mallocSQLVAR(m_pInSqlda);
- else
- evaluateStatusVector(m_statusVector, m_sSqlStatement, *this);
+ m_aInSqlda.describeStatement(m_aStatementHandle, true);
}
OPreparedStatement::~OPreparedStatement()
@@ -162,12 +127,6 @@ void SAL_CALL OPreparedStatement::close() throw(SQLException, RuntimeException,
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
OStatementCommonBase::close();
- if (m_pInSqlda)
- {
- freeSQLVAR(m_pInSqlda);
- free(m_pInSqlda);
- m_pInSqlda = 0;
- }
}
void SAL_CALL OPreparedStatement::disposing()
@@ -191,7 +150,7 @@ void SAL_CALL OPreparedStatement::setString(sal_Int32 nParameterIndex,
OString str = OUStringToOString(x , RTL_TEXTENCODING_UTF8 );
- XSQLVAR* pVar = m_pInSqlda->sqlvar + (nParameterIndex - 1);
+ XSQLVAR* pVar = m_aInSqlda->sqlvar + (nParameterIndex - 1);
int dtype = (pVar->sqltype & ~1); // drop flag bit for now
@@ -268,7 +227,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute()
&m_pConnection->getTransaction(),
&m_aStatementHandle,
1,
- m_pInSqlda);
+ &m_aInSqlda);
if (aErr)
{
SAL_WARN("connectivity.firebird", "isc_dsql_execute failed" );
@@ -331,7 +290,7 @@ void OPreparedStatement::setValue(sal_Int32 nIndex, T& nValue, ISC_SHORT nType)
checkParameterIndex(nIndex);
setParameterNull(nIndex, false);
- XSQLVAR* pVar = m_pInSqlda->sqlvar + (nIndex - 1);
+ XSQLVAR* pVar = m_aInSqlda->sqlvar + (nIndex - 1);
if ((pVar->sqltype & ~1) != nType)
{
@@ -686,7 +645,7 @@ void OPreparedStatement::checkParameterIndex(sal_Int32 nParameterIndex)
throw(SQLException, RuntimeException)
{
ensurePrepared();
- if ((nParameterIndex == 0) || (nParameterIndex > m_pInSqlda->sqld))
+ if ((nParameterIndex == 0) || (nParameterIndex > m_aInSqlda->sqld))
{
::dbtools::throwSQLException(
"No column " + OUString::number(nParameterIndex),
@@ -698,7 +657,7 @@ void OPreparedStatement::checkParameterIndex(sal_Int32 nParameterIndex)
void OPreparedStatement::setParameterNull(sal_Int32 nParameterIndex,
bool bSetNull)
{
- XSQLVAR* pVar = m_pInSqlda->sqlvar + (nParameterIndex - 1);
+ XSQLVAR* pVar = m_aInSqlda->sqlvar + (nParameterIndex - 1);
if (pVar->sqltype & 1)
{
if (bSetNull)
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.hxx b/connectivity/source/drivers/firebird/PreparedStatement.hxx
index 688063acc0cd..b75b6b04f36f 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.hxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.hxx
@@ -71,7 +71,7 @@ namespace connectivity
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData;
wrapper::Sqlda m_aOutSqlda;
- XSQLDA* m_pInSqlda;
+ wrapper::Sqlda m_aInSqlda;
void checkParameterIndex(sal_Int32 nParameterIndex)
throw(::com::sun::star::sdbc::SQLException,
::com::sun::star::uno::RuntimeException);