Skip to content

Commit

Permalink
MDEV-32612 Assertion `tab->select->quick' failed in test_if_skip_sort…
Browse files Browse the repository at this point in the history
…_order

Fixup for MDEV-31983, incorrect test for checking ability to use quick select.

Approved by Sergei Petrunia
  • Loading branch information
mariadb-RexJohnston committed Oct 28, 2023
1 parent 5b53342 commit ab6139d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
13 changes: 13 additions & 0 deletions mysql-test/main/subselect_mat.result
Expand Up @@ -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';
Expand Down
13 changes: 13 additions & 0 deletions mysql-test/main/subselect_sj_mat.result
Expand Up @@ -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
14 changes: 14 additions & 0 deletions mysql-test/main/subselect_sj_mat.test
Expand Up @@ -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
4 changes: 2 additions & 2 deletions sql/sql_select.cc
Expand Up @@ -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;
Expand Down

0 comments on commit ab6139d

Please sign in to comment.