diff options
Diffstat (limited to 'mysql-test/r/innodb_ext_key.result')
-rw-r--r-- | mysql-test/r/innodb_ext_key.result | 148 |
1 files changed, 147 insertions, 1 deletions
diff --git a/mysql-test/r/innodb_ext_key.result b/mysql-test/r/innodb_ext_key.result index 2b3b98eb26a..de1323e00f8 100644 --- a/mysql-test/r/innodb_ext_key.result +++ b/mysql-test/r/innodb_ext_key.result @@ -1030,7 +1030,7 @@ insert into t2 (b) values (null), (null), (null); set optimizer_switch='extended_keys=on'; explain select a from t1 where b is null order by a desc limit 2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref b b 9 const 2 Using where; Using filesort +1 SIMPLE t1 index b PRIMARY 8 NULL 3 Using where select a from t1 where b is null order by a desc limit 2; a 3 @@ -1068,5 +1068,151 @@ a 1 drop table t1, t2; set optimizer_switch=@save_optimizer_switch; +# +# MDEV-10325: Queries examines all rows of a tables when it should not +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 ( +pk int not null, +col1 varchar(32), +filler varchar(100), +key idx1(col1(10)), +primary key (pk) +)engine=innodb; +insert into t1 +select +A.a + 10*B.a + 100*C.a, +concat('1234567890-', 1000+ A.a + 10*B.a + 100*C.a), +repeat('filler-data-', 4) +from +t0 A, t0 B, t0 C; +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; +# +# MDEV-11196: Error:Run-Time Check Failure #2 - Stack around the variable 'key_buff' +# was corrupted, server crashes in opt_sum_query +set @save_innodb_file_format= @@innodb_file_format; +set @save_innodb_large_prefix= @@innodb_large_prefix; +set global innodb_file_format = BARRACUDA; +set global innodb_large_prefix = ON; +CREATE TABLE t1 ( +pk INT, +f1 VARCHAR(3), +f2 VARCHAR(1024), +PRIMARY KEY (pk), +KEY(f2) +) ENGINE=InnoDB CHARSET utf8 ROW_FORMAT= DYNAMIC; +INSERT INTO t1 VALUES (1,'foo','abc'),(2,'bar','def'); +SELECT MAX(t2.pk) FROM t1 t2 INNER JOIN t1 t3 ON t2.f1 = t3.f1 WHERE t2.pk <= 4; +MAX(t2.pk) +2 +drop table t1; +CREATE TABLE t1 ( +pk1 INT, +pk2 INT, +f1 VARCHAR(3), +f2 VARCHAR(1021), +PRIMARY KEY (pk1,pk2), +KEY(f2) +) ENGINE=InnoDB CHARSET utf8 ROW_FORMAT= DYNAMIC; +INSERT INTO t1 VALUES (1,2,'2','abc'),(2,3,'3','def'); +explain format= json +select * from t1 force index(f2) where pk1 <= 5 and pk2 <=5 and f2 = 'abc' and f1 <= '3'; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["f2"], + "key": "f2", + "key_length": "3070", + "used_key_parts": ["f2", "pk1"], + "rows": 1, + "filtered": 100, + "index_condition": "((t1.pk1 <= 5) and (t1.pk2 <= 5) and (t1.f2 = 'abc'))", + "attached_condition": "(t1.f1 <= '3')" + } + } +} +drop table t1; +CREATE TABLE t1 ( +f2 INT, +pk2 INT, +f1 VARCHAR(3), +pk1 VARCHAR(1000), +PRIMARY KEY (pk1,pk2), +KEY k1(pk1,f2) +) ENGINE=InnoDB CHARSET utf8 ROW_FORMAT= DYNAMIC; +INSERT INTO t1 VALUES (1,2,'2','abc'),(2,3,'3','def'); +explain format= json +select * from t1 force index(k1) where f2 <= 5 and pk2 <=5 and pk1 = 'abc' and f1 <= '3'; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": ["k1"], + "key": "k1", + "key_length": "3011", + "used_key_parts": ["pk1", "f2", "pk2"], + "rows": 1, + "filtered": 100, + "index_condition": "((t1.f2 <= 5) and (t1.pk2 <= 5) and (t1.pk1 = 'abc'))", + "attached_condition": "(t1.f1 <= '3')" + } + } +} +drop table t1; set optimizer_switch=@save_ext_key_optimizer_switch; +set global innodb_file_format = @save_innodb_file_format; +set global innodb_large_prefix = @save_innodb_large_prefix; SET SESSION STORAGE_ENGINE=DEFAULT; |