diff options
author | Tamas Bunth <tamas.bunth@collabora.co.uk> | 2018-11-08 18:48:54 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-11-09 09:55:45 +0100 |
commit | 00c3278816980d2d3949a5665133248058b93b16 (patch) | |
tree | dd9f0d710a5a16c8005595113b81cd2e9ad4f97b /connectivity | |
parent | c99e885565f9d741a659e7e18c22d092ed90b9de (diff) |
mysqlc: fix return value of XResultSet::next
Change-Id: I59e4803a5d9b01062eb0eaca0bf65d28298bd3e4
Reviewed-on: https://gerrit.libreoffice.org/63122
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.cxx | 6 | ||||
-rw-r--r-- | connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/connectivity/qa/connectivity/mysql/mysql.cxx b/connectivity/qa/connectivity/mysql/mysql.cxx index f78ea2ea57e5..8f2f664056c4 100644 --- a/connectivity/qa/connectivity/mysql/mysql.cxx +++ b/connectivity/qa/connectivity/mysql/mysql.cxx @@ -123,6 +123,7 @@ void MysqlTestDriver::testCreateAndDropTable() uno::Reference<XStatement> xStatement = xConnection->createStatement(); CPPUNIT_ASSERT(xStatement.is()); + xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); auto nUpdateCount = xStatement->executeUpdate("CREATE TABLE myTestTable (id INTEGER PRIMARY KEY)"); @@ -143,6 +144,7 @@ void MysqlTestDriver::testIntegerInsertAndQuery() Reference<XStatement> xStatement = xConnection->createStatement(); CPPUNIT_ASSERT(xStatement.is()); + xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); auto nUpdateCount = xStatement->executeUpdate("CREATE TABLE myTestTable (id INTEGER PRIMARY KEY)"); @@ -171,6 +173,9 @@ void MysqlTestDriver::testIntegerInsertAndQuery() CPPUNIT_ASSERT_MESSAGE("not enough result after query", hasRow); CPPUNIT_ASSERT_EQUAL(i, xRow->getLong(1)); // first and only column } + bool hasRow = xResultSet->next(); + // no more rows + CPPUNIT_ASSERT_MESSAGE("next returns true after last row", !hasRow); nUpdateCount = xStatement->executeUpdate("DROP TABLE myTestTable"); CPPUNIT_ASSERT_EQUAL(0, nUpdateCount); // it's a DDL statement @@ -186,6 +191,7 @@ void MysqlTestDriver::testDBPositionChange() Reference<XStatement> xStatement = xConnection->createStatement(); CPPUNIT_ASSERT(xStatement.is()); + xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); auto nUpdateCount = xStatement->executeUpdate("CREATE TABLE myTestTable (id INTEGER PRIMARY KEY)"); diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx index d08a31bab11e..50ab0be3af16 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx @@ -693,7 +693,7 @@ sal_Bool SAL_CALL OResultSet::next() MutexGuard aGuard(m_aMutex); checkDisposed(OResultSet_BASE::rBHelper.bDisposed); ensureResultFetched(); - if (m_nRowPosition >= m_nRowCount) + if (m_nRowPosition + 1 >= m_nRowCount) return false; ++m_nRowPosition; return true; |