Kaydet (Commit) 878c36f8 authored tarafından Tamas Bunth's avatar Tamas Bunth Kaydeden (comit) Tamás Bunth

mysqlc: next() should move cursor from Last

XResultSet::next() should move cursor when called while cursor is on the
last position. It is not documented, but older versions of the mysqlc
extension are implemented that way. The cursor goes to the so called
afterlast position.

Even so, the next() call on the last position should return false.

Change-Id: I0fd145c920077151364a6a8c12e05290496b99c8
Reviewed-on: https://gerrit.libreoffice.org/63895
Tested-by: Jenkins
Reviewed-by: 's avatarTamás Bunth <btomi96@gmail.com>
üst da16857f
......@@ -173,9 +173,16 @@ 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("Cursor is not on last position.",
xResultSet->isLast()); // cursor is on last position
CPPUNIT_ASSERT_EQUAL(ROW_COUNT, xResultSet->getRow()); // which is the last position
bool hasRow = xResultSet->next(); // go to afterlast
// no more rows, next should return false
CPPUNIT_ASSERT_MESSAGE("next returns true after last row", !hasRow);
// cursor should be in afterlast position
CPPUNIT_ASSERT_EQUAL(ROW_COUNT + 1, xResultSet->getRow());
CPPUNIT_ASSERT_MESSAGE("Cursor is not on after-last position.", xResultSet->isAfterLast());
nUpdateCount = xStatement->executeUpdate("DROP TABLE myTestTable");
CPPUNIT_ASSERT_EQUAL(0, nUpdateCount); // it's a DDL statement
......@@ -691,8 +691,14 @@ sal_Bool SAL_CALL OResultSet::next()
MutexGuard aGuard(m_aMutex);
if (m_nRowPosition + 1 >= m_nRowCount)
if (m_nRowPosition + 1 > m_nRowCount) // afterlast
return false;
if (m_nRowPosition + 1 == m_nRowCount) // last
// return false but take it to afterlast anyway
return false;
return true;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment