1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-31116 SIGSEGV in test_if_skip_sort_order|JOIN::optimize_stage2

test_if_skip_sort_order() should check that the 'select' pointer
(=tab->select) is not NULL before dereferencing it when invoking
the test_quick_select method.

The check was erroneously removed by:
1c88ac60cf Simple cleanup of removing QQ comments from sql_select.cc
This commit is contained in:
Dave Gosselin
2023-10-31 14:17:24 -04:00
committed by Dave Gosselin
parent 9cc179cc7e
commit 1f7ab85644
3 changed files with 20 additions and 1 deletions

View File

@ -296,3 +296,13 @@ a b c
6 2 26 6 2 26
6 3 36 6 3 36
drop table t1; drop table t1;
#
# MDEV-31116: SIGSEGV in test_if_skip_sort_order|JOIN::optimize_stage2
#
CREATE TABLE t1 (a BINARY (2),b BINARY (1),KEY(a)) ENGINE=innodb;
INSERT INTO t1 select 'ab', NULL from seq_1_to_14;
SELECT * FROM t1 WHERE a IN (SELECT a FROM t1 WHERE a >'') ORDER BY a LIMIT 1;
a b
ab NULL
DROP TABLE t1;
# End of 11.0 tests

View File

@ -250,3 +250,12 @@ explain select * from t1 force index(r) order by a,b limit 20;
explain select * from t1 force index(r) order by a desc,b limit 20; explain select * from t1 force index(r) order by a desc,b limit 20;
select * from t1 force index(r) order by a desc,b limit 20; select * from t1 force index(r) order by a desc,b limit 20;
drop table t1; drop table t1;
--echo #
--echo # MDEV-31116: SIGSEGV in test_if_skip_sort_order|JOIN::optimize_stage2
--echo #
CREATE TABLE t1 (a BINARY (2),b BINARY (1),KEY(a)) ENGINE=innodb;
INSERT INTO t1 select 'ab', NULL from seq_1_to_14;
SELECT * FROM t1 WHERE a IN (SELECT a FROM t1 WHERE a >'') ORDER BY a LIMIT 1;
DROP TABLE t1;
--echo # End of 11.0 tests

View File

@ -26478,7 +26478,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
!table->is_clustering_key(best_key))) !table->is_clustering_key(best_key)))
goto use_filesort; goto use_filesort;
if (table->opt_range_keys.is_set(best_key) && best_key != ref_key) if (select && table->opt_range_keys.is_set(best_key) && best_key != ref_key)
{ {
key_map tmp_map; key_map tmp_map;
tmp_map.clear_all(); // Force the creation of quick select tmp_map.clear_all(); // Force the creation of quick select