[Libreoffice-commits] core.git: 2 commits - connectivity/source
Lionel Elie Mamane (via logerrit)
logerrit at kemper.freedesktop.org
Sat May 9 19:18:16 UTC 2020
connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx | 18 ++++++++++++----
connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx | 1
connectivity/source/drivers/mysqlc/mysqlc_statement.cxx | 7 +++---
connectivity/source/drivers/mysqlc/mysqlc_statement.hxx | 2 -
4 files changed, 19 insertions(+), 9 deletions(-)
New commits:
commit 57cdc7f309f0863e1d8eef4a1780c3e9e2daadb5
Author: Lionel Elie Mamane <lionel at mamane.lu>
AuthorDate: Sat May 9 13:53:23 2020 +0200
Commit: Lionel Elie Mamane <lionel at mamane.lu>
CommitDate: Sat May 9 21:17:43 2020 +0200
mysql-sdbc: statement: rename disposeResultset to closeResultset
it does not actually dispose teh ResulteSet, it only lets go of the reference.
Change it to actually close the ResultSet.
Change-Id: Iee51738274468f5c00e026304915ba44139a9fab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93851
Tested-by: Jenkins
Reviewed-by: Lionel Elie Mamane <lionel at mamane.lu>
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_statement.cxx b/connectivity/source/drivers/mysqlc/mysqlc_statement.cxx
index 3211fe09eff7..6b35b236361f 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_statement.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_statement.cxx
@@ -50,11 +50,12 @@ OCommonStatement::OCommonStatement(OConnection* _pConnection)
OCommonStatement::~OCommonStatement() {}
-void OCommonStatement::disposeResultSet()
+void OCommonStatement::closeResultSet()
{
- // free the cursor if alive
if (m_xResultSet.is())
{
+ css::uno::Reference<css::sdbc::XCloseable> xClose(m_xResultSet, UNO_QUERY_THROW);
+ xClose->close();
m_xResultSet.clear();
m_pMysqlResult = nullptr; // it is freed by XResultSet
}
@@ -105,7 +106,7 @@ void SAL_CALL OCommonStatement::close()
checkDisposed(rBHelper.bDisposed);
}
dispose();
- disposeResultSet();
+ closeResultSet();
}
// void SAL_CALL OStatement::clearBatch()
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_statement.hxx b/connectivity/source/drivers/mysqlc/mysqlc_statement.hxx
index 54d67bd9d901..9595c596401a 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_statement.hxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_statement.hxx
@@ -71,7 +71,7 @@ protected:
sal_Int32 m_nAffectedRows = 0;
protected:
- void disposeResultSet();
+ void closeResultSet();
// OPropertyArrayUsageHelper
::cppu::IPropertyArrayHelper* createArrayHelper() const override;
commit a79194007fc0522d134ca2922ef59129fe7aa354
Author: Lionel Elie Mamane <lionel at mamane.lu>
AuthorDate: Sat May 9 13:45:10 2020 +0200
Commit: Lionel Elie Mamane <lionel at mamane.lu>
CommitDate: Sat May 9 21:17:37 2020 +0200
mysql-sdbc: resultset: do not keep m_pResult after freeing it
and replace m_bResultFetched by (m_pResult == nullptr)
Change-Id: I81dc9f1be9a72813a8a31c214ea6f8c43a1e37d0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93850
Tested-by: Jenkins
Reviewed-by: Lionel Elie Mamane <lionel at mamane.lu>
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx
index bd405dea973d..75c229823004 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx
@@ -111,12 +111,13 @@ OResultSet::OResultSet(OConnection& rConn, OCommonStatement* pStmt, MYSQL_RES* p
, m_pResult(pResult)
, m_encoding(_encoding)
{
+ assert(m_pResult);
m_xMetaData = new OResultSetMetaData(rConn, m_pResult);
}
void OResultSet::ensureResultFetched()
{
- if (!m_bResultFetched)
+ if (m_pResult)
{
fetchResult();
}
@@ -124,7 +125,7 @@ void OResultSet::ensureResultFetched()
void OResultSet::ensureFieldInfoFetched()
{
- if (m_bResultFetched)
+ if (m_pResult == nullptr)
return; // already fetched
// it works only if result set is produced via mysql_store_result
@@ -165,8 +166,8 @@ void OResultSet::fetchResult()
if (errorNum)
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(
mysql_error(m_pMysql), mysql_sqlstate(m_pMysql), errorNum, *this, m_encoding);
- m_bResultFetched = true;
mysql_free_result(m_pResult);
+ m_pResult = nullptr;
}
void OResultSet::disposing()
@@ -175,6 +176,11 @@ void OResultSet::disposing()
MutexGuard aGuard(m_aMutex);
+ if (m_pResult != nullptr)
+ {
+ mysql_free_result(m_pResult);
+ m_pResult = nullptr;
+ }
m_aStatement = nullptr;
m_xMetaData = nullptr;
}
@@ -575,7 +581,11 @@ void SAL_CALL OResultSet::close()
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
- m_pResult = nullptr;
+ if (m_pResult != nullptr)
+ {
+ mysql_free_result(m_pResult);
+ m_pResult = nullptr;
+ }
dispose();
}
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx b/connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx
index 027cc294c153..dca2bb4a9d88 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx
@@ -71,7 +71,6 @@ class OResultSet final : public OBase_Mutex,
MYSQL_RES* m_pResult;
rtl_TextEncoding m_encoding;
bool m_bWasNull = false; // did the last getXXX result null?
- bool m_bResultFetched = false;
sal_Int32 getDataLength(sal_Int32 column)
{
More information about the Libreoffice-commits
mailing list