diff --git a/heap/hp_delete.c b/heap/hp_delete.c index 90e537081d3..266a9da6ca3 100644 --- a/heap/hp_delete.c +++ b/heap/hp_delete.c @@ -73,7 +73,10 @@ int hp_rb_delete_key(HP_INFO *info, register HP_KEYDEF *keyinfo, int res; if (flag) + { info->last_pos= NULL; /* For heap_rnext/heap_rprev */ + info->lastkey_len= 0; + } custom_arg.keyseg= keyinfo->seg; custom_arg.key_length= hp_rb_make_key(keyinfo, info->recbuf, record, recpos); diff --git a/mysql-test/r/heap_btree.result b/mysql-test/r/heap_btree.result index 5c60c97d674..91c3ec65a13 100644 --- a/mysql-test/r/heap_btree.result +++ b/mysql-test/r/heap_btree.result @@ -246,3 +246,38 @@ DELETE from t1 where a < 100; SELECT * from t1; a DROP TABLE t1; +create table t1(a int not null, key using btree(a)) engine=heap; +insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3); +select a from t1 where a > 2; +a +3 +3 +3 +3 +delete from t1 where a < 4; +select a from t1; +a +insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3); +select a from t1 where a > 4; +a +delete from t1 where a > 4; +select a from t1; +a +3 +3 +1 +3 +3 +1 +2 +2 +2 +select a from t1 where a > 3; +a +delete from t1 where a >= 2; +select a from t1; +a +1 +1 +drop table t1; +End of 4.1 tests diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test index aea9e9486e5..f510f97fe9b 100644 --- a/mysql-test/t/heap_btree.test +++ b/mysql-test/t/heap_btree.test @@ -164,4 +164,22 @@ DELETE from t1 where a < 100; SELECT * from t1; DROP TABLE t1; -# End of 4.1 tests +# +# Bug #9719: problem with delete +# + +create table t1(a int not null, key using btree(a)) engine=heap; +insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3); +select a from t1 where a > 2; +delete from t1 where a < 4; +select a from t1; +insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3); +select a from t1 where a > 4; +delete from t1 where a > 4; +select a from t1; +select a from t1 where a > 3; +delete from t1 where a >= 2; +select a from t1; +drop table t1; + +--echo End of 4.1 tests