summaryrefslogtreecommitdiff
path: root/mysql-test/t/heap_btree.test
diff options
context:
space:
mode:
authorunknown <svoj@mysql.com/june.mysql.com>2007-09-13 15:39:16 +0500
committerunknown <svoj@mysql.com/june.mysql.com>2007-09-13 15:39:16 +0500
commitcf5762b40262ff7a74b3dba525e81ec0d9a8211b (patch)
tree82d23f01d2218d826e733d6d8a4d62634c9555bd /mysql-test/t/heap_btree.test
parentd20374821f4bee14f2c8ac16d3b3b0fcf97df6be (diff)
downloadmariadb-git-cf5762b40262ff7a74b3dba525e81ec0d9a8211b.tar.gz
BUG#30590 - delete from memory table with composite btree primary key
DELETE query against memory table with btree index may remove not all matching rows. This happens only when DELETE uses index read method to find matching rows. E.g. for queries like DELETE FROM t1 WHERE a=1. Fixed by reverting fix for BUG9719 and applying proper solution. heap/hp_delete.c: Reverted fix for BUG9719 as it makes queries like DELETE FROM t1 WHERE a=1 to remove not all matching rows (assuming this is memory table and there is btree key over `a`). This happens because we calculate info->lastkey_len in heap_rkey(). When we enter heap_rnext(), info->lastkey_len is 0 (set by hp_rb_delete_key()). We need to preserve info->lastkey_len in this situation, otherwise tree_search_key() will always return smallest value in a tree. heap/hp_rfirst.c: If we're performing index_first on a table that was taken from table cache, info->lastkey_len is initialized to previous query. Thus we set info->lastkey_len to proper value for subsequent heap_rnext() calls. This is needed for DELETE queries only, otherwise this variable is not used. Note that the same workaround may be needed for heap_rlast(), but for now heap_rlast() is never used for DELETE queries. heap/hp_rnext.c: An optimization for DELETE queries that use index_first()/index_next(). Use faster tree_search_edge() instead of tree_search_key(). mysql-test/r/heap_btree.result: A test case for BUG#30590. mysql-test/t/heap_btree.test: A test case for BUG#30590.
Diffstat (limited to 'mysql-test/t/heap_btree.test')
-rw-r--r--mysql-test/t/heap_btree.test9
1 files changed, 9 insertions, 0 deletions
diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test
index f8d6afbad04..849b7e12843 100644
--- a/mysql-test/t/heap_btree.test
+++ b/mysql-test/t/heap_btree.test
@@ -213,4 +213,13 @@ CREATE TABLE t1 (
INSERT INTO t1 VALUES('1'), ('2');
DROP TABLE t1;
+#
+# BUG#30590 - delete from memory table with composite btree primary key
+#
+CREATE TABLE t1 (a INT, KEY USING BTREE(a)) ENGINE=MEMORY;
+INSERT INTO t1 VALUES(1),(2),(2);
+DELETE FROM t1 WHERE a=2;
+SELECT * FROM t1;
+DROP TABLE t1;
+
--echo End of 4.1 tests