mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Fixed bug lp:800679
Analysis: The failed assert ensured that the choice of subquery strategy is performed only for queries with at least one table. If there is a LIMIT 0 clause all tables are removed, and the subquery is neither optimized, nor executed during actual optimization. However, if the query is EXPLAIN-ed, the EXPLAIN execution path doesn't remove the query tables if there is a LIMIT 0 clause. As a result, the subquery optimization code is called, which violates the ASSERT condition. Solution: Transform the assert into a condition, and if the outer query has no tables assume that there will be at most one subquery execution. There is potentially a better solution by reengineering the EXPLAIN/optimize code, so that subquery optimization is not done if not needed. Such a solution would be a lot bigger and more complex than a bug fix.
This commit is contained in:
@@ -4360,7 +4360,7 @@ bool JOIN::choose_subquery_plan(table_map join_tables)
|
||||
by the IN predicate.
|
||||
*/
|
||||
outer_join= unit->outer_select() ? unit->outer_select()->join : NULL;
|
||||
if (outer_join)
|
||||
if (outer_join && outer_join->table_count > 0)
|
||||
{
|
||||
/*
|
||||
The index of the last JOIN_TAB in the outer JOIN where in_subs is
|
||||
@@ -4373,7 +4373,6 @@ bool JOIN::choose_subquery_plan(table_map join_tables)
|
||||
JOIN_TAB, and their join_tab_idx remains MAX_TABLES. Such predicates
|
||||
are evaluated for each complete row of the outer join.
|
||||
*/
|
||||
DBUG_ASSERT(outer_join->table_count > 0);
|
||||
max_outer_join_tab_idx= (in_subs->get_join_tab_idx() == MAX_TABLES) ?
|
||||
outer_join->table_count - 1:
|
||||
in_subs->get_join_tab_idx();
|
||||
|
Reference in New Issue
Block a user