mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
MDEV-10360: Extended keys: index properties depend on index order
TABLE_SHARE::init_from_binary_frm_image has a rule: if an index has a partially-covered column (like in "KEY(col(N))" ), then dont provide "Extended Keys" feature for this index. The problem was that due to coding error Extended Keys feature was disabled for *ALL* subsequent indexes. Fixed the error.
This commit is contained in:
@@ -1064,5 +1064,50 @@ explain select * from t1 where col1='1234567890-a';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL idx1 NULL NULL NULL # Using where
|
||||
drop table t0,t1;
|
||||
#
|
||||
# MDEV-10360: Extended keys: index properties depend on index order
|
||||
#
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t1 (
|
||||
index_id bigint(20) unsigned NOT NULL,
|
||||
index_class varchar(265) COLLATE latin1_general_ci DEFAULT NULL ,
|
||||
index_object_id int(10) unsigned NOT NULL DEFAULT '0' ,
|
||||
index_date_updated int(10) unsigned DEFAULT NULL ,
|
||||
PRIMARY KEY (index_id),
|
||||
KEY object (index_class(181),index_object_id),
|
||||
KEY index_date_updated (index_date_updated)
|
||||
) engine=innodb;
|
||||
create table t2 (
|
||||
index_id bigint(20) unsigned NOT NULL,
|
||||
index_class varchar(265) COLLATE latin1_general_ci DEFAULT NULL ,
|
||||
index_object_id int(10) unsigned NOT NULL DEFAULT '0' ,
|
||||
index_date_updated int(10) unsigned DEFAULT NULL ,
|
||||
PRIMARY KEY (index_id),
|
||||
KEY index_date_updated (index_date_updated),
|
||||
KEY object (index_class(181),index_object_id)
|
||||
) engine=innodb;
|
||||
insert into t1 select
|
||||
@a:=A.a + 10*B.a + 100*C.a,
|
||||
concat('val-', @a),
|
||||
123456,
|
||||
A.a + 10*B.a
|
||||
from
|
||||
t0 A, t0 B, t0 C;
|
||||
insert into t2 select * from t1;
|
||||
# This must have the same query plan as the query below it:
|
||||
# type=range, key=index_date_updated, key_len=13
|
||||
explain
|
||||
select * from t1 force index(index_date_updated)
|
||||
where index_date_updated= 10 and index_id < 800;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range index_date_updated index_date_updated 13 NULL # Using index condition
|
||||
# This used to work from the start:
|
||||
explain
|
||||
select * from t2 force index(index_date_updated)
|
||||
where index_date_updated= 10 and index_id < 800;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range index_date_updated index_date_updated 13 NULL # Using index condition
|
||||
drop table t0,t1,t2;
|
||||
set optimizer_switch=@save_ext_key_optimizer_switch;
|
||||
SET SESSION STORAGE_ENGINE=DEFAULT;
|
||||
|
||||
Reference in New Issue
Block a user