mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug #37742: HA_EXTRA_KEYREAD flag is set when key contains only prefix of requested
column When the storage engine uses secondary keys clustered with the primary key MySQL was adding the primary key parts to each secondary key. In doing so it was not checking whether the index was on full columns and this resulted in the secondary keys being added to the list of covering keys even if they have partial columns. Fixed by not adding a primary key part to the list of columns that can be used for index read of the secondary keys when the primary key part is a partial key part.
This commit is contained in:
@ -43,3 +43,39 @@ CREATE TABLE t1 ( a INT ) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES(1);
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug #37742: HA_EXTRA_KEYREAD flag is set when key contains only prefix of
|
||||
# requested column
|
||||
#
|
||||
|
||||
CREATE TABLE foo (a int, b int, c char(10),
|
||||
PRIMARY KEY (c(3)),
|
||||
KEY b (b)
|
||||
) engine=innodb;
|
||||
|
||||
CREATE TABLE foo2 (a int, b int, c char(10),
|
||||
PRIMARY KEY (c),
|
||||
KEY b (b)
|
||||
) engine=innodb;
|
||||
|
||||
CREATE TABLE bar (a int, b int, c char(10),
|
||||
PRIMARY KEY (c(3)),
|
||||
KEY b (b)
|
||||
) engine=myisam;
|
||||
|
||||
INSERT INTO foo VALUES
|
||||
(1,2,'abcdefghij'), (2,3,''), (3,4,'klmnopqrst'),
|
||||
(4,5,'uvwxyz'), (5,6,'meotnsyglt'), (4,5,'asfdewe');
|
||||
|
||||
INSERT INTO bar SELECT * FROM foo;
|
||||
INSERT INTO foo2 SELECT * FROM foo;
|
||||
|
||||
--query_vertical EXPLAIN SELECT c FROM bar WHERE b>2;
|
||||
--query_vertical EXPLAIN SELECT c FROM foo WHERE b>2;
|
||||
--query_vertical EXPLAIN SELECT c FROM foo2 WHERE b>2;
|
||||
|
||||
--query_vertical EXPLAIN SELECT c FROM bar WHERE c>2;
|
||||
--query_vertical EXPLAIN SELECT c FROM foo WHERE c>2;
|
||||
--query_vertical EXPLAIN SELECT c FROM foo2 WHERE c>2;
|
||||
|
||||
DROP TABLE foo, bar, foo2;
|
||||
|
Reference in New Issue
Block a user