Commit 222db574 authored by unknown's avatar unknown

Fix for the bug #971: ORDER BY DESC doesn't return correct num of rows with...

Fix for the bug #971: ORDER BY DESC doesn't return correct num of rows with BDB and an indexed column.

parent 81a01a7f
......@@ -1123,3 +1123,34 @@ a b
select * from t2;
a b
drop table t1,t2;
create table t1 (x int not null, index(x)) type=bdb;
insert into t1 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
select * from t1 where x <= 10 and x >= 7;
x
7
8
9
10
select * from t1 where x <= 10 and x >= 7 order by x;
x
7
8
9
10
select * from t1 where x <= 10 and x >= 7 order by x desc;
x
10
9
8
7
select * from t1 where x <= 8 and x >= 5 order by x desc;
x
8
7
6
5
select * from t1 where x < 8 and x > 5 order by x desc;
x
7
6
drop table t1;
......@@ -783,3 +783,16 @@ select * from t1;
select * from t2;
select * from t2;
drop table t1,t2;
#
# The bug #971
#
create table t1 (x int not null, index(x)) type=bdb;
insert into t1 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
select * from t1 where x <= 10 and x >= 7;
select * from t1 where x <= 10 and x >= 7 order by x;
select * from t1 where x <= 10 and x >= 7 order by x desc;
select * from t1 where x <= 8 and x >= 5 order by x desc;
select * from t1 where x < 8 and x > 5 order by x desc;
drop table t1;
......@@ -1420,6 +1420,8 @@ int ha_berkeley::index_read(byte * buf, const byte * key,
bzero((char*) &row,sizeof(row));
if (key_len == key_info->key_length)
{
if (find_flag == HA_READ_AFTER_KEY)
key_info->handler.bdb_return_if_eq= 1;
error=read_row(cursor->c_get(cursor, pack_key(&last_key,
active_index,
key_buff,
......@@ -1428,6 +1430,7 @@ int ha_berkeley::index_read(byte * buf, const byte * key,
(find_flag == HA_READ_KEY_EXACT ?
DB_SET : DB_SET_RANGE)),
(char*) buf, active_index, &row, (DBT*) 0, 0);
key_info->handler.bdb_return_if_eq= 0;
}
else
{
......
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