@@ -2018,6 +2018,60 @@ INSERT INTO t2 VALUES (1),(2);
20182018SELECT STRAIGHT_JOIN pk FROM t1 JOIN t2 ON a = pk WHERE b >= 'A' ORDER BY t2.pk LIMIT 8 OFFSET 1;
20192019pk
20202020DROP TABLE t1, t2;
2021+ #
2022+ # MDEV-30659 Server crash on EXPLAIN SELECT/SELECT on table with
2023+ # engine Aria for LooseScan Strategy
2024+ #
2025+ create table t1 (old_c1 integer, old_c2 integer, c1 integer,
2026+ c2 integer, c3 integer) engine=aria;
2027+ insert into t1(c1,c2,c3)
2028+ values (1,1,1), (1,2,2), (1,3,3),
2029+ (2,1,4), (2,2,5), (2,3,6),
2030+ (2,4,7), (2,5,8);
2031+ create index t1_c2 on t1 (c2,c1);
2032+ explain select * from t1 where t1.c2 in (select a.c2 from t1 a) and
2033+ c2 >= 3 order by c2;
2034+ id select_type table type possible_keys key key_len ref rows Extra
2035+ 1 PRIMARY a range t1_c2 t1_c2 5 NULL 5 Using where; Using index; LooseScan
2036+ 1 PRIMARY t1 ref t1_c2 t1_c2 5 test.a.c2 1
2037+ drop table t1;
2038+ create table t1 (old_c1 integer, old_c2 integer, c1 integer,
2039+ c2 integer, c3 integer) engine=aria;
2040+ create trigger trg_t1 before update on t1 for each row
2041+ begin
2042+ set new.old_c1=old.c1;
2043+ set new.old_c2=old.c2;
2044+ end;
2045+ /
2046+ insert into t1 (c1,c2,c3) values
2047+ (1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
2048+ create index t1_c2 on t1 (c2,c1);
2049+ analyze table t1 persistent for all;
2050+ Table Op Msg_type Msg_text
2051+ test.t1 analyze status Engine-independent statistics collected
2052+ test.t1 analyze status OK
2053+ create table t2 as select * from t1;
2054+ truncate table t1;
2055+ insert into t1 select * from t2;
2056+ explain select * from t1 where t1.c2 in (select a.c2 from t1 a) and c2 >= 3 order by c2;
2057+ id select_type table type possible_keys key key_len ref rows Extra
2058+ 1 PRIMARY a range t1_c2 t1_c2 5 NULL 5 Using where; Using index; LooseScan
2059+ 1 PRIMARY t1 ref t1_c2 t1_c2 5 test.a.c2 1
2060+ drop trigger trg_t1;
2061+ drop table t1,t2;
2062+ create table t1 (old_c1 integer, old_c2 integer, c1 integer,
2063+ c2 integer, c3 integer) engine=aria;
2064+ insert into t1 (c1,c2,c3) values
2065+ (1,1,1), (1,2,2), (1,3,3), (2,1,4), (2,2,5), (2,3,6), (2,4,7), (2,5,8);
2066+ create index t1_c2 on t1 (c2,c1);
2067+ create table t2 as select * from t1;
2068+ truncate table t1;
2069+ insert into t1 select * from t2;
2070+ explain select * from t1 where t1.c2 in (select a.c2 from t1 a) and c2 >= 3 order by c2;
2071+ id select_type table type possible_keys key key_len ref rows Extra
2072+ 1 PRIMARY a range t1_c2 t1_c2 5 NULL 5 Using where; Using index; LooseScan
2073+ 1 PRIMARY t1 ref t1_c2 t1_c2 5 test.a.c2 2
2074+ drop table t1,t2;
20212075set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
20222076set @tmp_ust= @@use_stat_tables;
20232077set @tmp_oucs= @@optimizer_use_condition_selectivity;
0 commit comments