summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/bdb.result31
-rw-r--r--mysql-test/t/bdb.test13
-rw-r--r--sql/ha_berkeley.cc3
3 files changed, 47 insertions, 0 deletions
diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result
index eb97d19136d..ebc2866183c 100644
--- a/mysql-test/r/bdb.result
+++ b/mysql-test/r/bdb.result
@@ -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;
diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test
index 608d4bf5042..d0cc63a9389 100644
--- a/mysql-test/t/bdb.test
+++ b/mysql-test/t/bdb.test
@@ -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;
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index 2154fbd7a32..78704a18052 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -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
{