summaryrefslogtreecommitdiffstats
path: root/connectivity
diff options
context:
space:
mode:
authorTamas Bunth <tamas.bunth@collabora.co.uk>2019-01-22 13:06:45 +0100
committerTamás Bunth <btomi96@gmail.com>2019-08-02 16:49:13 +0200
commit3d5adeab32a1b40dff203face30223ce7d298c26 (patch)
tree123cc160db1f0a4f04d2ab9175041bf78f787cc4 /connectivity
parentmysqlc: Fix result set metadata related issue (diff)
downloadcore-3d5adeab32a1b40dff203face30223ce7d298c26.tar.gz
core-3d5adeab32a1b40dff203face30223ce7d298c26.zip
mysqlc: resultset's previous() on first position..
.. should move the cursor backwards to beforeFirst position and return false. Change-Id: Icbb4bed0ea39ea3a0bf375d5616e3ef768fc69d9 Reviewed-on: https://gerrit.libreoffice.org/66730 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/76729 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tamás Bunth <btomi96@gmail.com>
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/qa/connectivity/mysql/mysql.cxx6
-rw-r--r--connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx9
2 files changed, 14 insertions, 1 deletions
diff --git a/connectivity/qa/connectivity/mysql/mysql.cxx b/connectivity/qa/connectivity/mysql/mysql.cxx
index 414a0de569e2..77e82c9cdfc5 100644
--- a/connectivity/qa/connectivity/mysql/mysql.cxx
+++ b/connectivity/qa/connectivity/mysql/mysql.cxx
@@ -241,6 +241,12 @@ void MysqlTestDriver::testDBPositionChange()
xResultSet->first();
CPPUNIT_ASSERT_EQUAL(1, xResultSet->getRow());
+ // Now previous should put the cursor to before-first position, but it
+ // should return with false.
+ successPrevious = xResultSet->previous();
+ CPPUNIT_ASSERT(!successPrevious);
+ CPPUNIT_ASSERT_EQUAL(0, xResultSet->getRow());
+
nUpdateCount = xStatement->executeUpdate("DROP TABLE myTestTable");
CPPUNIT_ASSERT_EQUAL(0, nUpdateCount); // it's a DDL statement
}
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx
index be02c7c73ee3..1d93aa952383 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx
@@ -659,8 +659,15 @@ sal_Bool SAL_CALL OResultSet::previous()
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
- if (m_nRowPosition <= 0)
+ if (m_nRowPosition == 0)
+ {
+ m_nRowPosition--;
return false;
+ }
+ else if (m_nRowPosition < 0)
+ {
+ return false;
+ }
m_nRowPosition--;
return true;