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

MDEV-16104 Server crash in JOIN::fix_all_splittings_in_plan

upon select with view and subqueries

This bug occurred when a splittable materialized derived/view
were used inside another splittable materialized derived/view.
The bug happened because the function JOIN::fix_all_splittings_in_plan()
was called at the very beginning of the optimization phase 2 at
the moment when the plan structure of the embedding derived/view
were not valid. The proper position for this call is the very
end of the optimization phase 1.
This commit is contained in:
Igor Babaev
2018-05-08 23:32:11 -07:00
parent 2deb17fd54
commit fc0f5adb7f
3 changed files with 68 additions and 3 deletions

View File

@ -1853,6 +1853,18 @@ JOIN::optimize_inner()
DBUG_RETURN(1);
}
/*
If a splittable materialized derived/view dt_i is embedded into
into another splittable materialized derived/view dt_o then
splitting plans for dt_i and dt_o are evaluated independently.
First the optimizer looks for the best splitting plan sp_i for dt_i.
It happens when non-splitting plans for dt_o are evaluated.
The cost of sp_i is considered as the cost of materialization of dt_i
when evaluating any splitting plan for dt_o.
*/
if (fix_all_splittings_in_plan())
DBUG_RETURN(1);
setup_subq_exit:
with_two_phase_optimization= check_two_phase_optimization(thd);
if (with_two_phase_optimization)
@ -9374,9 +9386,6 @@ bool JOIN::get_best_combination()
full_join=0;
hash_join= FALSE;
if (fix_all_splittings_in_plan())
DBUG_RETURN(TRUE);
fix_semijoin_strategies_for_picked_join_order(this);
JOIN_TAB_RANGE *root_range;