Commit 8c79e090 authored by Varun Gupta's avatar Varun Gupta

Minor fix to tests

parent 30a63d6e
......@@ -1617,7 +1617,7 @@ x b b a
6 4 4 4
DROP TABLE t0,t1,t2,t3;
#
# Const table should not form the sort-nest
# Const tables should not form the sort-nest
#
CREATE TABLE t1 (i1 integer NOT NULL PRIMARY KEY);
CREATE TABLE t2 (i2 integer NOT NULL PRIMARY KEY);
......@@ -1775,7 +1775,7 @@ CREATE TABLE t2 as SELECT * from t1;
set use_sort_nest=1;
EXPLAIN SELECT *
FROM t1,t2
WHERE t1.a=t2.a and t1.b= 4
WHERE t1.a=t2.a and t1.b= 4
ORDER BY t1.b DESC
LIMIT 5;
id select_type table type possible_keys key key_len ref rows Extra
......@@ -1783,7 +1783,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 10 Using where
SELECT *
FROM t1,t2
WHERE t1.a=t2.a and t1.b= 4
WHERE t1.a=t2.a and t1.b= 4
ORDER BY t1.b DESC
LIMIT 5;
a b a b
......
This diff is collapsed.
......@@ -64,48 +64,30 @@ INSERT INTO t1 VALUES (1,'a'), (2,'b'), (3,'c'), (4,'d');
# Should use index condition
#
set use_sort_nest= 1;
SELECT * FROM t1
WHERE a BETWEEN 1 and 2
ORDER BY a
LIMIT 2;
SELECT * FROM t1 WHERE a BETWEEN 1 and 2 ORDER BY a LIMIT 2;
a b
1 a
2 b
EXPLAIN SELECT * FROM t1
WHERE a BETWEEN 1 and 2
ORDER BY a
LIMIT 2;
EXPLAIN SELECT * FROM t1 WHERE a BETWEEN 1 and 2 ORDER BY a LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition
set use_sort_nest= 0;
EXPLAIN SELECT * FROM t1
WHERE a BETWEEN 1 and 2
ORDER BY a
LIMIT 2;
EXPLAIN SELECT * FROM t1 WHERE a BETWEEN 1 and 2 ORDER BY a LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition
#
# Should not use index condition as ORDER by DESC is used
#
set use_sort_nest= 1;
EXPLAIN SELECT * FROM t1
WHERE a BETWEEN 1 and 2
ORDER BY a DESC
LIMIT 2;
EXPLAIN SELECT * FROM t1 WHERE a BETWEEN 1 and 2 ORDER BY a DESC LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where
SELECT * FROM t1
WHERE a BETWEEN 1 and 2
ORDER BY a DESC
LIMIT 2;
SELECT * FROM t1 WHERE a BETWEEN 1 and 2 ORDER BY a DESC LIMIT 2;
a b
2 b
1 a
set use_sort_nest= 0;
EXPLAIN SELECT * FROM t1
WHERE a BETWEEN 1 and 2
ORDER BY a DESC
LIMIT 2;
EXPLAIN SELECT * FROM t1 WHERE a BETWEEN 1 and 2 ORDER BY a DESC LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where
drop table t1;
......@@ -123,9 +105,7 @@ insert into t2 select a, b, c from t1;
# Using range scan
#
set use_sort_nest= 1;
SELECT *
FROM
t1,t2
SELECT * FROM t1,t2
WHERE
t1.a=2 AND t2.b > 8 AND
t1.b=t2.b
......@@ -133,9 +113,7 @@ ORDER BY t1.b LIMIT 10;
a b c a b c
2 9 3 2 9 3
2 10 4 2 10 4
EXPLAIN SELECT *
FROM
t1,t2
EXPLAIN SELECT * FROM t1,t2
WHERE
t1.a=2 AND t2.b > 8 AND
t1.b=t2.b
......@@ -144,9 +122,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a,a_b a_b 10 NULL 2 Using index condition
1 SIMPLE t2 ref b b 5 test.t1.b 1
set use_sort_nest= 0;
EXPLAIN SELECT *
FROM
t1,t2
EXPLAIN SELECT * FROM t1,t2
WHERE
t1.a=2 AND t2.b > 8 AND
t1.b=t2.b
......@@ -158,9 +134,7 @@ id select_type table type possible_keys key key_len ref rows Extra
# Using ref access
#
set use_sort_nest= 1;
SELECT *
FROM
t1,t2
SELECT * FROM t1,t2
WHERE
t1.a=2 AND t2.c >= 1 AND
t1.b=t2.b
......@@ -169,9 +143,7 @@ a b c a b c
2 8 2 2 8 2
2 9 3 2 9 3
2 10 4 2 10 4
EXPLAIN SELECT *
FROM
t1,t2
EXPLAIN SELECT * FROM t1,t2
WHERE
t1.a=2 AND t2.c >= 1 AND
t1.b=t2.b
......@@ -180,9 +152,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a,a_b a_b 5 const 3 Using index condition; Using where
1 SIMPLE t2 ref b,c b 5 test.t1.b 1 Using where
set use_sort_nest= 0;
EXPLAIN SELECT *
FROM
t1,t2
EXPLAIN SELECT * FROM t1,t2
WHERE
t1.a=2 AND t2.c >= 1 AND
t1.b=t2.b
......@@ -217,21 +187,15 @@ id select_type table type possible_keys key key_len ref rows Extra
# Index idx2 to be used for index scan(USE INDEX is used)
#
set use_sort_nest=1;
SELECT * from t1 USE INDEX(idx2)
WHERE b > 0
ORDER BY t1.a LIMIT 2;
SELECT * from t1 USE INDEX(idx2) WHERE b > 0 ORDER BY t1.a LIMIT 2;
a b c
1 1 1
2 2 2
EXPLAIN SELECT * from t1 USE INDEX(idx2)
WHERE b > 0
ORDER BY t1.a LIMIT 2;
EXPLAIN SELECT * from t1 USE INDEX(idx2) WHERE b > 0 ORDER BY t1.a LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx2 10 NULL 2 Using where
set use_sort_nest=0;
EXPLAIN SELECT * from t1 USE INDEX(idx2)
WHERE b > 0
ORDER BY t1.a LIMIT 2;
EXPLAIN SELECT * from t1 USE INDEX(idx2) WHERE b > 0 ORDER BY t1.a LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx2 10 NULL 2 Using where
#
......
......@@ -56,10 +56,7 @@ INSERT INTO t1 VALUES (1,'a'), (2,'b'), (3,'c'), (4,'d');
--echo # Should use index condition
--echo #
let $query= SELECT * FROM t1
WHERE a BETWEEN 1 and 2
ORDER BY a
LIMIT 2;
let $query= SELECT * FROM t1 WHERE a BETWEEN 1 and 2 ORDER BY a LIMIT 2;
set use_sort_nest= 1;
eval $query;
......@@ -72,10 +69,7 @@ eval EXPLAIN $query;
--echo # Should not use index condition as ORDER by DESC is used
--echo #
let $query= SELECT * FROM t1
WHERE a BETWEEN 1 and 2
ORDER BY a DESC
LIMIT 2;
let $query= SELECT * FROM t1 WHERE a BETWEEN 1 and 2 ORDER BY a DESC LIMIT 2;
set use_sort_nest= 1;
eval EXPLAIN $query;
......@@ -102,13 +96,13 @@ insert into t2 select a, b, c from t1;
--echo #
--echo # Using range scan
--echo #
let $query= SELECT *
FROM
t1,t2
WHERE
t1.a=2 AND t2.b > 8 AND
t1.b=t2.b
ORDER BY t1.b LIMIT 10;
let $query=
SELECT * FROM t1,t2
WHERE
t1.a=2 AND t2.b > 8 AND
t1.b=t2.b
ORDER BY t1.b LIMIT 10;
set use_sort_nest= 1;
eval $query;
......@@ -120,13 +114,12 @@ eval EXPLAIN $query;
--echo #
--echo # Using ref access
--echo #
let $query= SELECT *
FROM
t1,t2
WHERE
t1.a=2 AND t2.c >= 1 AND
t1.b=t2.b
ORDER BY t1.b LIMIT 10;
let $query=
SELECT * FROM t1,t2
WHERE
t1.a=2 AND t2.c >= 1 AND
t1.b=t2.b
ORDER BY t1.b LIMIT 10;
set use_sort_nest= 1;
eval $query;
......@@ -165,9 +158,7 @@ eval EXPLAIN $query;
--echo # Index idx2 to be used for index scan(USE INDEX is used)
--echo #
let $query= SELECT * from t1 USE INDEX(idx2)
WHERE b > 0
ORDER BY t1.a LIMIT 2;
let $query= SELECT * from t1 USE INDEX(idx2) WHERE b > 0 ORDER BY t1.a LIMIT 2;
set use_sort_nest=1;
eval $query;
eval EXPLAIN $query;
......@@ -179,9 +170,11 @@ eval EXPLAIN $query;
--echo # Index idx2 to be used for index scan(USE INDEX for ORDER BY is used)
--echo #
let $query= SELECT * from t1 USE INDEX FOR ORDER BY(idx2)
WHERE b > 0
ORDER BY t1.a LIMIT 2;
let $query=
SELECT * from t1 USE INDEX FOR ORDER BY(idx2)
WHERE b > 0
ORDER BY t1.a LIMIT 2;
set use_sort_nest=1;
eval $query;
eval EXPLAIN $query;
......@@ -193,9 +186,11 @@ eval EXPLAIN $query;
--echo # Use Filesort as idx3 does not resolve ORDER BY clause
--echo #
let $query= SELECT * from t1 USE INDEX FOR ORDER BY(idx3)
WHERE b > 0
ORDER BY t1.a LIMIT 2;
let $query=
SELECT * from t1 USE INDEX FOR ORDER BY(idx3)
WHERE b > 0
ORDER BY t1.a LIMIT 2;
set use_sort_nest=1;
eval $query;
eval EXPLAIN $query;
......@@ -207,9 +202,11 @@ eval EXPLAIN $query;
--echo # Using index idx2 as idx1 is ignored
--echo #
let $query= SELECT * from t1 IGNORE INDEX(idx1)
WHERE b > 0
ORDER BY t1.a LIMIT 2;
let $query=
SELECT * from t1 IGNORE INDEX(idx1)
WHERE b > 0
ORDER BY t1.a LIMIT 2;
set use_sort_nest=1;
eval $query;
eval EXPLAIN $query;
......@@ -221,9 +218,11 @@ eval EXPLAIN $query;
--echo # Use index idx2 for sorting, it is forced here
--echo #
let $query= SELECT * from t1 FORCE INDEX(idx2)
WHERE b > 0
ORDER BY t1.a LIMIT 2;
let $query=
SELECT * from t1 FORCE INDEX(idx2)
WHERE b > 0
ORDER BY t1.a LIMIT 2;
set use_sort_nest=1;
eval $query;
eval EXPLAIN $query;
......@@ -235,9 +234,10 @@ eval EXPLAIN $query;
--echo # Use FILESORT as idx3 cannot resolve ORDER BY clause
--echo #
let $query= SELECT * from t1 FORCE INDEX FOR ORDER BY(idx3)
WHERE b > 0
ORDER BY t1.a LIMIT 2;
let $query=
SELECT * from t1 FORCE INDEX FOR ORDER BY(idx3)
WHERE b > 0
ORDER BY t1.a LIMIT 2;
set use_sort_nest=1;
eval $query;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment