connectivity/source/drivers/firebird/PreparedStatement.cxx | 55 +------------ connectivity/source/drivers/firebird/PreparedStatement.hxx | 2 connectivity/source/drivers/firebird/wrapper/Sqlda.cxx | 20 ++++ connectivity/source/drivers/firebird/wrapper/Sqlda.hxx | 8 + 4 files changed, 32 insertions(+), 53 deletions(-)
New commits: commit dc0af89801e0f6a2105487915259a879533083df Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Wed Mar 19 20:51:59 2014 +0000 firebird-sdbc: upgrade PreparedStatement to use Sqlda wrapper. Change-Id: If79a8b1cfe76292054db4417c452f6443e663fda diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx index 3ddf3b5..4814b91 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 688063a..b75b6b0 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); commit 2a7ce8dc71129c0d90ed9447bd37805a34c17139 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Wed Mar 19 20:51:15 2014 +0000 firebird-sdbc: Sqlda wrapper also needs operator->. Change-Id: I12a57dff5183365e3b05d107204d593c3d4ca6a6 diff --git a/connectivity/source/drivers/firebird/wrapper/Sqlda.hxx b/connectivity/source/drivers/firebird/wrapper/Sqlda.hxx index f51252b..eb26d8d 100644 --- a/connectivity/source/drivers/firebird/wrapper/Sqlda.hxx +++ b/connectivity/source/drivers/firebird/wrapper/Sqlda.hxx @@ -32,6 +32,7 @@ namespace connectivity Sqlda(); ~Sqlda(); XSQLDA* operator&() { return mpSqlda; }; + XSQLDA* operator->() { return mpSqlda; }; /** * Set up the Sqlda for a given statement, is equivalent to commit e1c1dca297055631876827d94e6a73683a68ae18 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Wed Mar 19 20:42:00 2014 +0000 firebird-sdbc: Allow describe-bind for Sqlda wrapper. Is needed to handle input XSQLDAs. Change-Id: I7b57dd97e0ff5cebedae245e5a609f2aac1a5820 diff --git a/connectivity/source/drivers/firebird/wrapper/Sqlda.cxx b/connectivity/source/drivers/firebird/wrapper/Sqlda.cxx index 9cca23d..f3c520c 100644 --- a/connectivity/source/drivers/firebird/wrapper/Sqlda.cxx +++ b/connectivity/source/drivers/firebird/wrapper/Sqlda.cxx @@ -152,7 +152,9 @@ Sqlda::~Sqlda() } } -void Sqlda::describeStatement(isc_stmt_handle& aStatementHandle) +void Sqlda::describeStatement( + isc_stmt_handle& aStatementHandle, + bool bDescribeBind) { if (!mpSqlda) { @@ -169,7 +171,13 @@ void Sqlda::describeStatement(isc_stmt_handle& aStatementHandle) { ISC_STATUS_ARRAY aStatusVector; - if (isc_dsql_describe(aStatusVector, + if (!bDescribeBind ? + isc_dsql_describe(aStatusVector, + &aStatementHandle, + FIREBIRD_SQL_DIALECT, + mpSqlda) + : + isc_dsql_describe_bind(aStatusVector, &aStatementHandle, FIREBIRD_SQL_DIALECT, mpSqlda)) @@ -184,7 +192,13 @@ void Sqlda::describeStatement(isc_stmt_handle& aStatementHandle) mpSqlda = lcl_allocateSqlda(mpSqlda->sqld); } - if (isc_dsql_describe(aStatusVector, + if (!bDescribeBind ? + isc_dsql_describe(aStatusVector, + &aStatementHandle, + FIREBIRD_SQL_DIALECT, + mpSqlda) + : + isc_dsql_describe_bind(aStatusVector, &aStatementHandle, FIREBIRD_SQL_DIALECT, mpSqlda)) diff --git a/connectivity/source/drivers/firebird/wrapper/Sqlda.hxx b/connectivity/source/drivers/firebird/wrapper/Sqlda.hxx index 0c395db..f51252b 100644 --- a/connectivity/source/drivers/firebird/wrapper/Sqlda.hxx +++ b/connectivity/source/drivers/firebird/wrapper/Sqlda.hxx @@ -37,8 +37,13 @@ namespace connectivity * Set up the Sqlda for a given statement, is equivalent to * using isc_dsql_describe, but with all the details handled * within. + * + * Use bDescribeBind if we are binding an input sqlda, i.e. + * if we want isc_dsql_describe_bind instead of isc_dsql_describe. */ - void describeStatement(isc_stmt_handle& aStatementHandle); + void describeStatement( + isc_stmt_handle& aStatementHandle, + bool bDescribeBind = false); }; } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits