[MDEV-19618] crash in insert select with sub query Created: 2019-05-28  Updated: 2019-06-05  Resolved: 2019-05-28

Status: Closed
Project: MariaDB Server
Component/s: Data Manipulation - Insert, Data Manipulation - Subquery
Affects Version/s: None
Fix Version/s: 10.2.25, 10.3.16, 10.4.6

Type: Bug Priority: Blocker
Reporter: Michael Widenius Assignee: Oleksandr Byelkin
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates MDEV-18896 Crash in convert_join_subqueries_to_s... Closed

 Description   

Test case:
create table t1 (a1 varchar(25));
create table t2 (a2 varchar(25)) ;
insert into t1 select 'xxx' from dual where 'xxx' in (select a2 from t2);
drop table t1,t2;

Causes convert_subq_to_jtbm() at:
for (tl= (TABLE_LIST*)(parent_lex->table_list.first); tl->next_local; tl= tl->next_local)

Because parent_lex->table_list.first is 0



 Comments   
Comment by Oleksandr Byelkin [ 2019-05-28 ]

Fixed by 2c9844a438c5f0bddcb037a1e05978118f48abb6

I checked that the same fix it in 10.3

diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index e1eb65079f2..be262c6638b 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -519,7 +519,7 @@ bool is_materialization_applicable(THD *thd, Item_in_subselect *in_subs,
   if (optimizer_flag(thd, OPTIMIZER_SWITCH_MATERIALIZATION) &&      // 0
         !child_select->is_part_of_union() &&                          // 1
         parent_unit->first_select()->leaf_tables.elements &&          // 2
-        child_select->outer_select()->leaf_tables.elements &&         // 2A
+        child_select->outer_select()->table_list.first &&         // 2A
         subquery_types_allow_materialization(in_subs) &&
         (in_subs->is_top_level_item() ||                               //3
          optimizer_flag(thd,

Generated at Thu Feb 08 08:53:03 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.