diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2014-09-30 19:22:27 +0400 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2014-09-30 19:22:27 +0400 |
commit | 605b48d3e311e783ff60644dd468bbabb9a4a15c (patch) | |
tree | 5a2e1009c6334934ff339131e9225f3cf187dd4a | |
parent | 0b15557c8fec3de5c3ef3cce2b5ff9340159751f (diff) | |
download | mariadb-git-bb-10.1-orderby-fixes.tar.gz |
MDEV-6814: Server crashes in calculate_key_len on query with ORDER BYbb-10.1-orderby-fixes
- if test_if_skip_sort_order() decides to switch to using an index, or
switch from using ref to using quick select, it should set all
members accordingly.
-rw-r--r-- | mysql-test/r/order_by_optimizer_innodb.result | 8 | ||||
-rw-r--r-- | mysql-test/t/order_by_optimizer_innodb.test | 8 | ||||
-rw-r--r-- | sql/sql_select.cc | 1 |
3 files changed, 17 insertions, 0 deletions
diff --git a/mysql-test/r/order_by_optimizer_innodb.result b/mysql-test/r/order_by_optimizer_innodb.result index 423e43ea5a2..f3167db4b9a 100644 --- a/mysql-test/r/order_by_optimizer_innodb.result +++ b/mysql-test/r/order_by_optimizer_innodb.result @@ -47,6 +47,14 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range PRIMARY,ux_pk1_fd5 ux_pk1_fd5 13 NULL 137 Using where drop table t0,t1, t2; # +# MDEV-6814: Server crashes in calculate_key_len on query with ORDER BY +# +CREATE TABLE t1 (f1 INT, f2 INT, f3 INT, KEY(f2),KEY(f2,f1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,5,0),(2,6,0); +SELECT * FROM t1 WHERE f1 < 3 AND f2 IS NULL ORDER BY f1; +f1 f2 f3 +DROP TABLE t1; +# # MDEV-6796: Unable to skip filesort when using implicit extended key # CREATE TABLE t1 ( diff --git a/mysql-test/t/order_by_optimizer_innodb.test b/mysql-test/t/order_by_optimizer_innodb.test index de0a0a9abcd..90430d11549 100644 --- a/mysql-test/t/order_by_optimizer_innodb.test +++ b/mysql-test/t/order_by_optimizer_innodb.test @@ -43,6 +43,14 @@ EXPLAIN SELECT * FROM t2 WHERE pk1=9 AND fd5 < 500 ORDER B drop table t0,t1, t2; --echo # +--echo # MDEV-6814: Server crashes in calculate_key_len on query with ORDER BY +--echo # +CREATE TABLE t1 (f1 INT, f2 INT, f3 INT, KEY(f2),KEY(f2,f1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,5,0),(2,6,0); +SELECT * FROM t1 WHERE f1 < 3 AND f2 IS NULL ORDER BY f1; +DROP TABLE t1; + +--echo # --echo # MDEV-6796: Unable to skip filesort when using implicit extended key --echo # diff --git a/sql/sql_select.cc b/sql/sql_select.cc index cf29abcf101..1cf7b851671 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -20177,6 +20177,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, tab->ref.key= -1; tab->ref.key_parts= 0; tab->use_quick= 1; + best_key= new_ref_key; /* We don't restore select->cond as we want to use the original condition as index condition pushdown is not |