[Libreoffice-commits] core.git: connectivity/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Sun Sep 5 07:52:00 UTC 2021
connectivity/source/drivers/firebird/PreparedStatement.cxx | 4
connectivity/source/drivers/firebird/StatementCommonBase.cxx | 51 +++--------
connectivity/source/drivers/firebird/StatementCommonBase.hxx | 4
3 files changed, 19 insertions(+), 40 deletions(-)
New commits:
commit b96e84528153b8b613003a040e90acf4f5abe0f4
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sun Sep 5 07:57:21 2021 +0200
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sun Sep 5 09:51:26 2021 +0200
m_pInSqlda is not needed in prepareAndDescribeStatement
As described in Isc_dsql_prepare [1] and Isc_dsql_describe [2] docs,
these two take and fill a pointer to XSQLDA used for output. Only
Isc_dsql_describe_bind [3] fills the structure used for input.
Additionally, since Isc_dsql_prepare already does the necessary
initialization, Isc_dsql_describe is documented to be not needed
unless there is an indication that there is insufficient room in
the output XSQLDA. Hence the change allows to avoid one redundant
call.
[1] https://docwiki.embarcadero.com/InterBase/2020/en/Isc_dsql_prepare()
[2] https://docwiki.embarcadero.com/InterBase/2020/en/Isc_dsql_describe()
[3] https://docwiki.embarcadero.com/InterBase/2020/en/Isc_dsql_describe_bind()
Change-Id: Ia8ba09f079fa949e53a174f551fca6653852d31e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121563
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx
index 3b5511518957..483ad14b0e0e 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx
@@ -81,9 +81,7 @@ void OPreparedStatement::ensurePrepared()
m_pInSqlda->sqln = 10;
}
- prepareAndDescribeStatement(m_sSqlStatement,
- m_pOutSqlda,
- m_pInSqlda);
+ prepareAndDescribeStatement(m_sSqlStatement, m_pOutSqlda);
aErr = isc_dsql_describe_bind(m_statusVector,
&m_aStatementHandle,
diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.cxx b/connectivity/source/drivers/firebird/StatementCommonBase.cxx
index 01ae41dca120..61f57f330516 100644
--- a/connectivity/source/drivers/firebird/StatementCommonBase.cxx
+++ b/connectivity/source/drivers/firebird/StatementCommonBase.cxx
@@ -124,9 +124,7 @@ void SAL_CALL OStatementCommonBase::close()
dispose();
}
-void OStatementCommonBase::prepareAndDescribeStatement(std::u16string_view sql,
- XSQLDA*& pOutSqlda,
- XSQLDA* pInSqlda)
+void OStatementCommonBase::prepareAndDescribeStatement(std::u16string_view sql, XSQLDA*& pOutSqlda)
{
SolarMutexGuard g; // tdf#122129
@@ -157,7 +155,7 @@ void OStatementCommonBase::prepareAndDescribeStatement(std::u16string_view sql,
0,
OUStringToOString(sql, RTL_TEXTENCODING_UTF8).getStr(),
FIREBIRD_SQL_DIALECT,
- pInSqlda);
+ pOutSqlda);
if (aErr)
{
@@ -167,45 +165,30 @@ void OStatementCommonBase::prepareAndDescribeStatement(std::u16string_view sql,
}
else
{
- aErr = isc_dsql_describe(m_statusVector,
- &m_aStatementHandle,
- 1,
- pOutSqlda);
+ // Ensure we have enough space in pOutSqlda
+ if (pOutSqlda->sqld > pOutSqlda->sqln)
+ {
+ int n = pOutSqlda->sqld;
+ free(pOutSqlda);
+ pOutSqlda = static_cast<XSQLDA*>(calloc(1, XSQLDA_LENGTH(n)));
+ pOutSqlda->version = SQLDA_VERSION1;
+ pOutSqlda->sqln = n;
+ aErr = isc_dsql_describe(m_statusVector,
+ &m_aStatementHandle,
+ 1,
+ pOutSqlda);
+ }
+ // Process each XSQLVAR parameter structure in the output XSQLDA
if (aErr)
{
- // TODO: free statement handle, etc.?
evaluateStatusVector(m_statusVector,
u"isc_dsql_describe",
*this);
}
else
{
- // Ensure we have enough space in pOutSqlda
- if (pOutSqlda->sqld > pOutSqlda->sqln)
- {
- int n = pOutSqlda->sqld;
- free(pOutSqlda);
- pOutSqlda = static_cast<XSQLDA*>(calloc(1, XSQLDA_LENGTH(n)));
- pOutSqlda->version = SQLDA_VERSION1;
- pOutSqlda->sqln = n;
- aErr = isc_dsql_describe(m_statusVector,
- &m_aStatementHandle,
- 1,
- pOutSqlda);
- }
-
- // Process each XSQLVAR parameter structure in the output XSQLDA
- if (aErr)
- {
- evaluateStatusVector(m_statusVector,
- u"isc_dsql_describe",
- *this);
- }
- else
- {
- mallocSQLVAR(pOutSqlda);
- }
+ mallocSQLVAR(pOutSqlda);
}
}
if(aErr)
diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.hxx b/connectivity/source/drivers/firebird/StatementCommonBase.hxx
index a8e3812cea6e..fa9cd790272e 100644
--- a/connectivity/source/drivers/firebird/StatementCommonBase.hxx
+++ b/connectivity/source/drivers/firebird/StatementCommonBase.hxx
@@ -84,9 +84,7 @@ namespace connectivity::firebird
virtual ~OStatementCommonBase() override;
/// @throws css::sdbc::SQLException
- void prepareAndDescribeStatement(std::u16string_view sqlIn,
- XSQLDA*& pOutSqlda,
- XSQLDA* pInSqlda=nullptr);
+ void prepareAndDescribeStatement(std::u16string_view sqlIn, XSQLDA*& pOutSqlda);
/// @throws css::sdbc::SQLException
short getSqlInfoItem(char aInfoItem);
More information about the Libreoffice-commits
mailing list