1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

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
This commit is contained in:
Michael Widenius
2012-09-10 16:46:33 +03:00
parent 7fbd2de8b8
commit 1539f91267
3 changed files with 41 additions and 0 deletions

View File

@ -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

View File

@ -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