2014-07-22 13:52:49 +02:00
|
|
|
#
|
|
|
|
# ORDER BY handling (e.g. filesort) tests that require innodb
|
|
|
|
#
|
|
|
|
-- source include/have_innodb.inc
|
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
drop table if exists t0,t1,t2,t3;
|
|
|
|
--enable_warnings
|
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # MDEV-6434: Wrong result (extra rows) with ORDER BY, multiple-column index, InnoDB
|
|
|
|
--echo #
|
|
|
|
|
|
|
|
CREATE TABLE t1 (a INT, b INT, c INT, d TEXT, KEY idx(a,b,c)) ENGINE=InnoDB;
|
|
|
|
|
|
|
|
INSERT INTO t1 (a,c) VALUES
|
|
|
|
(8, 9),(8, 10),(13, 15),(16, 17),(16, 18),(16, 19),(20, 21),
|
|
|
|
(20, 22),(20, 24),(20, 25),(20, 26),(20, 27),(20, 28);
|
|
|
|
|
|
|
|
SELECT * FROM t1 WHERE a = 8 AND (b = 1 OR b IS NULL) ORDER BY c;
|
|
|
|
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
2016-01-24 10:31:11 +01:00
|
|
|
--echo #
|
|
|
|
--echo # MDEV-9457: Poor query plan chosen for ORDER BY query by a recent 10.1
|
|
|
|
--echo #
|
|
|
|
create table t0 (a int);
|
|
|
|
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
|
|
|
|
|
|
|
create table t1 (
|
|
|
|
pk int primary key,
|
|
|
|
key1 int,
|
|
|
|
key2 int,
|
|
|
|
col1 char(255),
|
|
|
|
key(key1),
|
|
|
|
key(key2)
|
|
|
|
) engine=innodb;
|
|
|
|
|
|
|
|
set @a=-1;
|
|
|
|
insert into t1
|
|
|
|
select
|
|
|
|
@a:=@a+1,
|
|
|
|
@a,
|
|
|
|
@a,
|
|
|
|
repeat('abcd', 63)
|
|
|
|
from t0 A, t0 B, t0 C, t0 D;
|
|
|
|
|
|
|
|
--echo # The following must NOT use 'index' on PK.
|
|
|
|
--echo # It should use index_merge(key1,key2) + filesort
|
|
|
|
--replace_column 9 #
|
|
|
|
explain
|
|
|
|
select *
|
|
|
|
from t1
|
|
|
|
where key1<3 or key2<3
|
|
|
|
order by pk;
|
|
|
|
|
|
|
|
--replace_column 9 #
|
|
|
|
explain
|
|
|
|
select *
|
|
|
|
from t1
|
|
|
|
where key1<3 or key2<3;
|
|
|
|
|
|
|
|
drop table t0, t1;
|