[MDEV-25407] EXISTS subquery with correlation in ON expression crashes Created: 2021-04-13  Updated: 2021-04-20  Resolved: 2021-04-16

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6
Fix Version/s: 10.2.38, 10.3.29, 10.4.19, 10.5.10, 10.6.0

Type: Bug Priority: Major
Reporter: Sergei Petrunia Assignee: Sergei Petrunia
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-25380 JSON_TABLE: Assertion `join->best_rea... Closed

 Description   

This is a followup to MDEV-25380.

sql/item_subselect.cc has this comment in Item_subselect::walk():

      /* TODO: why does this walk WHERE/HAVING but not ON expressions of outer joins? */

This is a testcase for it:

create table ten(a int primary key);
insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table one_k(a int primary key);
insert into one_k select a.a + b.a* 10 + c.a * 100 from ten a, ten b, ten c;
create table t1 (a int, b int);
insert into t1 select a,a from ten;
create table t2 (a int, b int);
insert into t2 select a,a from one_k;
create table t3 as select * from t2;
explain
select *  from t1  
where 
exists (select t2.a from t2 left join t3 on (t3.b=t1.b) where t2.a=t1.a);

Crashes with:

mariadbd: /home/psergey/dev-git2/10.5-cp2/sql/sql_select.cc:8820: bool greedy_search(JOIN*, table_map, uint, uint, uint): Assertion `join->best_read < double(1.79769313486231570814527423731704357e+308L)' failed.



 Comments   
Comment by Sergei Petrunia [ 2021-04-13 ]

http://lists.askmonty.org/pipermail/commits/2021-April/014553.html

Comment by Sergei Petrunia [ 2021-04-13 ]

The fix follows the same approach as MDEV-25380. Sanja, please review.

Comment by Oleksandr Byelkin [ 2021-04-16 ]

OK to push

Generated at Thu Feb 08 09:37:27 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.