summaryrefslogtreecommitdiff
path: root/mysql-test/t/order_by.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t/order_by.test')
-rw-r--r--mysql-test/t/order_by.test24
1 files changed, 24 insertions, 0 deletions
diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test
index 36b6015c5d8..2ea169d950d 100644
--- a/mysql-test/t/order_by.test
+++ b/mysql-test/t/order_by.test
@@ -1468,3 +1468,27 @@ SELECT * FROM t1 FORCE INDEX FOR JOIN (a), t2 WHERE t1.a < 2 ORDER BY t1.a;
DROP TABLE t1, t2;
--echo End of 5.1 tests
+
+
+--echo #
+--echo # Bug #38745: MySQL 5.1 optimizer uses filesort for ORDER BY
+--echo # when it should use index
+--echo #
+
+CREATE TABLE t1 (i1 integer NOT NULL PRIMARY KEY);
+CREATE TABLE t2 (i2 integer NOT NULL PRIMARY KEY);
+CREATE TABLE t3 (i3 integer);
+
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12);
+INSERT INTO t2 SELECT * FROM t1;
+
+EXPLAIN EXTENDED
+SELECT t1.*, t2.* FROM t1 JOIN t2 ON t1.i1 = t2.i2
+ LEFT JOIN t3 ON t2.i2 = t3.i3
+ ORDER BY t1.i1 LIMIT 5;
+
+SELECT t1.*, t2.* FROM t1 JOIN t2 ON t1.i1 = t2.i2
+ LEFT JOIN t3 ON t2.i2 = t3.i3
+ ORDER BY t1.i1 LIMIT 5;
+
+DROP TABLE t1, t2, t3;