diff --git a/mysql-test/main/subselect_mat.result b/mysql-test/main/subselect_mat.result index c5b201c6f46..286b3d40ac1 100644 --- a/mysql-test/main/subselect_mat.result +++ b/mysql-test/main/subselect_mat.result @@ -2699,6 +2699,19 @@ INSERT INTO t3 VALUES ('2012-11-11',5),('2012-12-12',6); UPDATE t1, t2 SET t1.a = 26 WHERE t2.b IN (SELECT MIN(d) FROM t3 WHERE c >= '2012-01'); ERROR 22007: Incorrect datetime value: '2012-01' for column `test`.`t3`.`c` at row 1 DROP TABLE t1, t2, t3; +# +# MDEV-32612 Assertion `tab->select->quick' failed in test_if_skip_sort_order +# +CREATE TABLE t1 (l_orderkey int, l_linenumber int, l_quantity double, +PRIMARY KEY (l_orderkey,l_linenumber), KEY (l_orderkey), +KEY (l_orderkey,l_quantity)) engine=MyISAM; +INSERT INTO t1 VALUES (290,1,35),(290,2,2); +SELECT * FROM t1 +WHERE l_quantity = 31 +AND (l_quantity = 50 OR l_orderkey = 41) +ORDER BY l_orderkey, l_linenumber; +l_orderkey l_linenumber l_quantity +DROP TABLE t1; # end of 10.6 tests set @subselect_mat_test_optimizer_switch_value=null; set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off'; diff --git a/mysql-test/main/subselect_sj_mat.result b/mysql-test/main/subselect_sj_mat.result index 5d09af61892..277ce9a4408 100644 --- a/mysql-test/main/subselect_sj_mat.result +++ b/mysql-test/main/subselect_sj_mat.result @@ -2741,4 +2741,17 @@ INSERT INTO t3 VALUES ('2012-11-11',5),('2012-12-12',6); UPDATE t1, t2 SET t1.a = 26 WHERE t2.b IN (SELECT MIN(d) FROM t3 WHERE c >= '2012-01'); ERROR 22007: Incorrect datetime value: '2012-01' for column `test`.`t3`.`c` at row 1 DROP TABLE t1, t2, t3; +# +# MDEV-32612 Assertion `tab->select->quick' failed in test_if_skip_sort_order +# +CREATE TABLE t1 (l_orderkey int, l_linenumber int, l_quantity double, +PRIMARY KEY (l_orderkey,l_linenumber), KEY (l_orderkey), +KEY (l_orderkey,l_quantity)) engine=MyISAM; +INSERT INTO t1 VALUES (290,1,35),(290,2,2); +SELECT * FROM t1 +WHERE l_quantity = 31 +AND (l_quantity = 50 OR l_orderkey = 41) +ORDER BY l_orderkey, l_linenumber; +l_orderkey l_linenumber l_quantity +DROP TABLE t1; # end of 10.6 tests diff --git a/mysql-test/main/subselect_sj_mat.test b/mysql-test/main/subselect_sj_mat.test index 0b5cfd6ab7b..7a218bde172 100644 --- a/mysql-test/main/subselect_sj_mat.test +++ b/mysql-test/main/subselect_sj_mat.test @@ -2436,4 +2436,18 @@ UPDATE t1, t2 SET t1.a = 26 WHERE t2.b IN (SELECT MIN(d) FROM t3 WHERE c >= '201 # Cleanup DROP TABLE t1, t2, t3; +--echo # +--echo # MDEV-32612 Assertion `tab->select->quick' failed in test_if_skip_sort_order +--echo # + +CREATE TABLE t1 (l_orderkey int, l_linenumber int, l_quantity double, + PRIMARY KEY (l_orderkey,l_linenumber), KEY (l_orderkey), + KEY (l_orderkey,l_quantity)) engine=MyISAM; +INSERT INTO t1 VALUES (290,1,35),(290,2,2); +SELECT * FROM t1 +WHERE l_quantity = 31 +AND (l_quantity = 50 OR l_orderkey = 41) +ORDER BY l_orderkey, l_linenumber; +DROP TABLE t1; + --echo # end of 10.6 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0c8432afd91..a351322e76b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -24750,14 +24750,14 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, tab->join->unit-> lim.get_select_limit(), TRUE, TRUE, FALSE, FALSE); - if (res != SQL_SELECT::OK) + // if we cannot use quick select + if (res != SQL_SELECT::OK || !tab->select->quick) { if (res == SQL_SELECT::ERROR) *fatal_error= true; select->cond= save_cond; goto use_filesort; } - DBUG_ASSERT(tab->select->quick); tab->type= JT_ALL; tab->ref.key= -1; tab->ref.key_parts= 0;