mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#56814 Explain + subselect + fulltext crashes server
create_sort_index() function overwrites original JOIN_TAB::type field. At re-execution of subquery overwritten JOIN_TAB::type(JT_ALL) is used instead of JT_FT. It misleads test_if_skip_sort_order() and the function tries to find suitable key for the order that should not be allowed for FULLTEXT(JT_FT) table. The fix is to restore JOIN_TAB strucures for subselect on re-execution for EXPLAIN. Additional fix: Update TABLE::maybe_null field which affects list_contains_unique_index() behaviour as it could have the value(maybe_null==TRUE) based on the assumption that this join is outer (see setup_table_map() func). mysql-test/r/explain.result: test case mysql-test/t/explain.test: test case sql/item_subselect.cc: Make subquery uncacheable in case of EXPLAIN. It allows to keep original JOIN_TAB::type(see JOIN::save_join_tab) and restore it on re-execution. sql/sql_select.cc: -restore JOIN_TAB strucures for subselect on re-execution for EXPLAIN -Update TABLE::maybe_null field as it could have the value(maybe_null==TRUE) based on the assumption that this join is outer(see setup_table_map() func). This change is not related to the crash problem but affects EXPLAIN results in the test case.
This commit is contained in:
@ -2490,6 +2490,13 @@ mysql_select(THD *thd, Item ***rref_pointer_array,
|
||||
{
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
/*
|
||||
Original join tabs might be overwritten at first
|
||||
subselect execution. So we need to restore them.
|
||||
*/
|
||||
Item_subselect *subselect= select_lex->master_unit()->item;
|
||||
if (subselect && subselect->is_uncacheable() && join->reinit())
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -8825,6 +8832,13 @@ simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top)
|
||||
that reject nulls => the outer join can be replaced by an inner join.
|
||||
*/
|
||||
table->outer_join= 0;
|
||||
/*
|
||||
Update TABLE::maybe_null field as it could have
|
||||
the value(maybe_null==TRUE) based on the assumption
|
||||
that this join is outer(see setup_table_map() func).
|
||||
*/
|
||||
if (table->table)
|
||||
table->table->maybe_null= FALSE;
|
||||
if (table->on_expr)
|
||||
{
|
||||
/* Add on expression to the where condition. */
|
||||
|
Reference in New Issue
Block a user