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

MDEV-29350 Crash when IN predicand is used in eliminated GROUP BY clause

This bug affected some queries with an IN/ALL/ANY predicand or an EXISTS
predicate whose subquery contained a GROUP BY clause that could be
eliminated. If this clause used a IN/ALL/ANY predicand whose left operand
was a single-value subquery then execution of the query caused a crash of
the server after invokation of remove_redundant_subquery_clauses().
The crash was caused by an attempt to exclude the unit for the single-value
subquery from the query tree for the second time by the function
Item_subselect::eliminate_subselect_processor().

This bug had been masked by the bug MDEV-28617 until a fix for the latter
that properly excluded units was pushed into 10.3.

Approved by Oleksandr Byelkin <sanja@mariadb.com>
This commit is contained in:
Igor Babaev
2022-08-24 11:07:09 -07:00
parent d1a80c42ee
commit 94e3f02db7
3 changed files with 192 additions and 1 deletions

View File

@ -2477,4 +2477,78 @@ eval $q3;
drop table t1,t2,t3;
--echo #
--echo # MDEV-29139: Redundant IN/ALL/ANY predicand in GROUP BY clause of
--echo # IN/ALL/ANY/EXISTS subquery
--echo #
create table t1 (a int);
create table t2 (b int);
create table t3 (c int);
create table t4 (d int);
insert into t1 values (3), (1);
insert into t2 values (3), (2);
insert into t3 values (4), (2);
insert into t4 values (1), (7);
let $q1=
select b from t2
where exists (select c from t3
group by (select a from t1 where a = 1) in (select d from t4));
eval explain extended $q1;
eval $q1;
eval prepare stmt from "$q1";
execute stmt;
execute stmt;
deallocate prepare stmt;
let $q2=
select b from t2
where exists (select c from t3
group by (select a from t1 where a = 1) >=
any (select d from t4));
eval explain extended $q2;
eval $q2;
let $q3=
select b from t2
where exists (select c from t3
group by (select a from t1 where a = 1) <
all (select d from t4));
eval explain extended $q3;
eval $q3;
let $q4=
select b from t2
where b in (select c from t3
group by (select a from t1 where a = 1) in (select d from t4));
eval explain extended $q4;
eval $q4;
let $q5=
select b from t2
where b >= any (select c from t3
group by (select a from t1 where a = 1) in
(select d from t4));
eval explain extended $q5;
eval $q5;
let $q6=
select b from t2
where b <= all (select c from t3
group by (select a from t1 where a = 1) in
(select d from t4));
eval explain extended $q6;
eval $q6;
drop table t1,t2,t3,t4;
--echo # End of 10.3 tests