1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-21683 Server crashes in get_quick_keys with not_null_range_scan

ANding of the range built from inferred NOT NULL conditions and the range
built from other conditions used in WHERE/ON clauses may produce an
IMPOSSIBLE range. The code of MDEV-15777 did not take into account this
possibility.
This commit is contained in:
Igor Babaev
2020-02-10 21:19:28 -08:00
parent 83e75b39b3
commit 41541a7c48
4 changed files with 66 additions and 6 deletions

View File

@ -2106,7 +2106,6 @@ drop table t1,ten,t2;
--echo # MDEV-15777: Use inferred IS NOT NULL predicates in the range optimizer
--echo #
set @save_optimizer_switch= @@optimizer_switch;
set @@optimizer_switch='not_null_range_scan=on';
create table ten(a int);
insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
@ -2280,6 +2279,29 @@ drop table t1,t2;
drop table ten,one_k;
set @@optimizer_switch= @save_optimizer_switch;
--echo #
--echo # MDEV-21683: ANDing of the range from inferred NOT NULL condition and
--echo # the range from other conditions produces IMPOSSIBLE range
--echo #
SET @save_optimizer_switch= @@optimizer_switch;
CREATE TABLE t1 (a INT, KEY(a));
INSERT INTO t1 VALUES (8),(9);
CREATE TABLE t2 (pk INT, b INT, PRIMARY KEY(pk));
INSERT INTO t2 VALUES (1,1),(2,2);
SET optimizer_switch = 'not_null_range_scan=on';
let $q=
SELECT * FROM t1 LEFT JOIN t2 ON a = pk WHERE b >= 0 AND pk IS NULL;
eval EXPLAIN EXTENDED $q;
eval $q;
DROP TABLE t1, t2;
SET @@optimizer_switch= @save_optimizer_switch;
--echo #
--echo # End of 10.5 tests
--echo #