1
0
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:
Sergei Petrunia
2016-07-11 22:22:32 +03:00
parent 0bb5d95542
commit 8a8ba1949b
3 changed files with 103 additions and 3 deletions

View File

@@ -721,5 +721,58 @@ explain select * from t1 where col1='1234567890-a';
drop table t0,t1;
--echo #
--echo # MDEV-10360: Extended keys: index properties depend on index order
--echo #
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;
--echo # This must have the same query plan as the query below it:
--echo # type=range, key=index_date_updated, key_len=13
--replace_column 9 #
explain
select * from t1 force index(index_date_updated)
where index_date_updated= 10 and index_id < 800;
--echo # This used to work from the start:
--replace_column 9 #
explain
select * from t2 force index(index_date_updated)
where index_date_updated= 10 and index_id < 800;
drop table t0,t1,t2;
set optimizer_switch=@save_ext_key_optimizer_switch;
SET SESSION STORAGE_ENGINE=DEFAULT;