Skip to content

Commit 90f33c5

Browse files
committed
bug21152054: Correct relative() not seeking after changing position.
1 parent 5c75875 commit 90f33c5

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

driver/mysql_ps_resultset.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ MySQL_Prepared_ResultSet::relative(const int rows)
13401340
row_position = rows > 0? num_rows + 1 : 0; /* after last or before first */
13411341
} else {
13421342
row_position += rows;
1343-
proxy->data_seek(row_position - 1);
1343+
seek();
13441344
}
13451345
}
13461346

test/unit/bugs/bugs.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,27 @@ void bugs::bug21067193()
959959
}
960960

961961

962+
}
963+
964+
void bugs::bug21152054()
965+
{
966+
967+
stmt->execute("DROP TABLE IF EXISTS bug21152054");
968+
stmt->execute("create table bug21152054(c1 int);" );
969+
stmt->execute("insert into bug21152054 values(1), (2), (3), (4);" );
970+
pstmt.reset( con->prepareStatement("select c1 from bug21152054;") );
971+
res.reset( pstmt->executeQuery() );
972+
ASSERT_EQUALS(true, res->absolute(4));
973+
ASSERT_EQUALS(4, res->getInt(1));
974+
int line = 4;
975+
ASSERT_EQUALS(true, res->relative(-1));
976+
do
977+
{
978+
--line;
979+
ASSERT_EQUALS(line, res->getInt(1));
980+
} while(res->relative(-1));
981+
982+
962983
}
963984

964985
} /* namespace regression */

test/unit/bugs/bugs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class bugs : public unit_fixture
6666
TEST_CASE(bug21053335);
6767
TEST_CASE(bug21067193);
6868
TEST_CASE(bug21066575);
69+
TEST_CASE(bug21152054);
6970
}
7071

7172
/**
@@ -119,6 +120,8 @@ class bugs : public unit_fixture
119120

120121
void bug21067193();
121122

123+
void bug21152054();
124+
122125
};
123126

124127
REGISTER_FIXTURE(bugs);

0 commit comments

Comments
 (0)