summaryrefslogtreecommitdiffstats
path: root/connectivity
diff options
context:
space:
mode:
authorTamas Bunth <tamas.bunth@collabora.co.uk>2019-01-22 13:06:45 +0100
committerAndras Timar <andras.timar@collabora.com>2019-01-22 16:37:56 +0100
commitfca928b481e6410967df914ce6dd120edee61805 (patch)
treec7bf245122c89e1d9780ea51c749b3a6e1aaa678 /connectivity
parenttdf#122748 Don't restore previous language selection (diff)
downloadcore-fca928b481e6410967df914ce6dd120edee61805.tar.gz
core-fca928b481e6410967df914ce6dd120edee61805.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>
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 758f7eb123ff..6c9fb45b7c30 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 079fea40daf7..4633d064ce9a 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx
@@ -654,8 +654,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;