The crash is caused by the following execution scenario:
PREPARE command:
> parent subquery calls convert_join_subqueries_to_semi_joins()
- it switches to statement' Arena. (AA)
- subquery is converted into a non-mergeable semi-join nest,
> convert_subq_to_jtbm()
> it calls child_join->optimize()
(this is necessary because of how JOIN::choose_subquery_plan() works.
in particular, it may figure out that Materialization is not applicable after all
and this information needs to be returned to convert_subq_to_jtbm() so that
it aborts the conversion)
> child_join->optimize() works:
- switches to statement arena *AGAIN* (BB)
- it calls simplify_joins(), which converts the outer join into inner.
- while doing the above, it creates an Item_cond_and() object. The object is added into thd->free_list.
From this point, the execution proceeds normally, except that double activation (at (AA) and (BB) ) and de-activation of statement mem_root leaves the Item_cond_and un-recorded in Statement's free_list.
As a consequence of this, Item_cond_and->cleanup() is never called, and on next execution we get situation
where
The crash is caused by the following execution scenario:
PREPARE command: join_subqueries _to_semi_ joins() subq_to_ jtbm() >optimize( ) subquery_ plan() works. subq_to_ jtbm() so that >optimize( ) works:
thd->free_ list.
> parent subquery calls convert_
- it switches to statement' Arena. (AA)
- subquery is converted into a non-mergeable semi-join nest,
> convert_
> it calls child_join-
(this is necessary because of how JOIN::choose_
in particular, it may figure out that Materialization is not applicable after all
and this information needs to be returned to convert_
it aborts the conversion)
> child_join-
- switches to statement arena *AGAIN* (BB)
- it calls simplify_joins(), which converts the outer join into inner.
- while doing the above, it creates an Item_cond_and() object. The object is added into
From this point, the execution proceeds normally, except that double activation (at (AA) and (BB) ) and de-activation of statement mem_root leaves the Item_cond_and un-recorded in Statement's free_list. and->cleanup( ) is never called, and on next execution we get situation
As a consequence of this, Item_cond_
where
Item_cond_ and->fixed= TRUE and->list- >nth_element( 0)->fixed= FALSE and->list- >nth_element( 1)->fixed= FALSE
Item_cond_
Item_cond_
this causes us to assert when accessing one of Item_cond_and's chlldren.