From 1539f91267a8ca11b137444a4cb87c61febfb05c Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 10 Sep 2012 16:46:33 +0300 Subject: Fixed Bug#1002564: Wrong result for a lookup query from a heap table mysql-test/suite/heap/heap_hash.result: Added test case mysql-test/suite/heap/heap_hash.test: Added test case storage/heap/hp_hash.c: Limit key data length to max key length --- mysql-test/suite/heap/heap_hash.result | 19 +++++++++++++++++++ mysql-test/suite/heap/heap_hash.test | 13 +++++++++++++ 2 files changed, 32 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/suite/heap/heap_hash.result b/mysql-test/suite/heap/heap_hash.result index 453bfc0c165..ac62427c81c 100644 --- a/mysql-test/suite/heap/heap_hash.result +++ b/mysql-test/suite/heap/heap_hash.result @@ -427,4 +427,23 @@ INDEX(col_int_key) USING HASH) ENGINE = HEAP; INSERT INTO t1 (col_int_nokey, col_int_key) VALUES (3, 0), (4, 0), (3, 1); DELETE FROM t1 WHERE col_int_nokey = 5 ORDER BY col_int_key LIMIT 2; DROP TABLE t1; +# +# Bug #1002564: Wrong result for a lookup query from a heap table +# +CREATE TABLE t1 (c1 VARCHAR(10) NOT NULL, KEY i1 (c1(3))) ENGINE=MEMORY DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('foo1'), ('bar2'), ('baz3'); +explain SELECT * FROM t1 WHERE c1='bar2'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref i1 i1 5 const 2 Using where +SELECT * FROM t1 WHERE c1='bar2'; +c1 +bar2 +ALTER TABLE t1 DROP KEY i1, ADD KEY il (c1(3)) using btree; +explain SELECT * FROM t1 WHERE c1='bar2'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref il il 5 const 1 Using where +SELECT * FROM t1 WHERE c1='bar2'; +c1 +bar2 +DROP TABLE t1; End of 5.5 tests diff --git a/mysql-test/suite/heap/heap_hash.test b/mysql-test/suite/heap/heap_hash.test index 80ae01e9547..80d6ef9c8f2 100644 --- a/mysql-test/suite/heap/heap_hash.test +++ b/mysql-test/suite/heap/heap_hash.test @@ -316,4 +316,17 @@ DELETE FROM t1 WHERE col_int_nokey = 5 ORDER BY col_int_key LIMIT 2; DROP TABLE t1; +--echo # +--echo # Bug #1002564: Wrong result for a lookup query from a heap table +--echo # + +CREATE TABLE t1 (c1 VARCHAR(10) NOT NULL, KEY i1 (c1(3))) ENGINE=MEMORY DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('foo1'), ('bar2'), ('baz3'); +explain SELECT * FROM t1 WHERE c1='bar2'; +SELECT * FROM t1 WHERE c1='bar2'; +ALTER TABLE t1 DROP KEY i1, ADD KEY il (c1(3)) using btree; +explain SELECT * FROM t1 WHERE c1='bar2'; +SELECT * FROM t1 WHERE c1='bar2'; +DROP TABLE t1; + --echo End of 5.5 tests -- cgit v1.2.1