mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge 10.3 into 10.4
This commit is contained in:
@ -1642,6 +1642,13 @@ JOIN::optimize_inner()
|
||||
if (optimize_constant_subqueries())
|
||||
DBUG_RETURN(1);
|
||||
|
||||
if (conds && conds->with_subquery())
|
||||
(void) conds->walk(&Item::cleanup_is_expensive_cache_processor,
|
||||
0, (void *) 0);
|
||||
if (having && having->with_subquery())
|
||||
(void) having->walk(&Item::cleanup_is_expensive_cache_processor,
|
||||
0, (void *) 0);
|
||||
|
||||
List<Item> eq_list;
|
||||
|
||||
if (setup_degenerate_jtbm_semi_joins(this, join_list, eq_list))
|
||||
@ -1687,6 +1694,13 @@ JOIN::optimize_inner()
|
||||
conds= optimize_cond(this, conds, join_list, FALSE,
|
||||
&cond_value, &cond_equal, OPT_LINK_EQUAL_FIELDS);
|
||||
|
||||
if (thd->is_error())
|
||||
{
|
||||
error= 1;
|
||||
DBUG_PRINT("error",("Error from optimize_cond"));
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
if (thd->lex->sql_command == SQLCOM_SELECT &&
|
||||
optimizer_flag(thd, OPTIMIZER_SWITCH_COND_PUSHDOWN_FOR_SUBQUERY))
|
||||
{
|
||||
@ -1752,13 +1766,6 @@ JOIN::optimize_inner()
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
if (unlikely(thd->is_error()))
|
||||
{
|
||||
error= 1;
|
||||
DBUG_PRINT("error",("Error from optimize_cond"));
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
{
|
||||
having= optimize_cond(this, having, join_list, TRUE,
|
||||
&having_value, &having_equal);
|
||||
@ -4618,8 +4625,8 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
|
||||
int ref_changed;
|
||||
do
|
||||
{
|
||||
more_const_tables_found:
|
||||
ref_changed = 0;
|
||||
more_const_tables_found:
|
||||
found_ref=0;
|
||||
|
||||
/*
|
||||
@ -4788,7 +4795,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (join->const_table_map & found_ref && ref_changed);
|
||||
} while (ref_changed);
|
||||
|
||||
join->sort_by_table= get_sort_by_table(join->order, join->group_list,
|
||||
join->select_lex->leaf_tables,
|
||||
@ -9025,8 +9032,13 @@ bool JOIN_TAB::keyuse_is_valid_for_access_in_chosen_plan(JOIN *join,
|
||||
st_select_lex *sjm_sel= emb_sj_nest->sj_subq_pred->unit->first_select();
|
||||
for (uint i= 0; i < sjm_sel->item_list.elements; i++)
|
||||
{
|
||||
if (sjm_sel->ref_pointer_array[i] == keyuse->val)
|
||||
return true;
|
||||
DBUG_ASSERT(sjm_sel->ref_pointer_array[i]->real_item()->type() == Item::FIELD_ITEM);
|
||||
if (keyuse->val->real_item()->type() == Item::FIELD_ITEM)
|
||||
{
|
||||
Field *field = ((Item_field*)sjm_sel->ref_pointer_array[i]->real_item())->field;
|
||||
if (field->eq(((Item_field*)keyuse->val->real_item())->field))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -9674,7 +9686,6 @@ static bool create_hj_key_for_table(JOIN *join, JOIN_TAB *join_tab,
|
||||
if (first_keyuse)
|
||||
{
|
||||
key_parts++;
|
||||
first_keyuse= FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -9684,7 +9695,7 @@ static bool create_hj_key_for_table(JOIN *join, JOIN_TAB *join_tab,
|
||||
if (curr->keypart == keyuse->keypart &&
|
||||
!(~used_tables & curr->used_tables) &&
|
||||
join_tab->keyuse_is_valid_for_access_in_chosen_plan(join,
|
||||
keyuse) &&
|
||||
curr) &&
|
||||
are_tables_local(join_tab, curr->used_tables))
|
||||
break;
|
||||
}
|
||||
@ -9692,6 +9703,7 @@ static bool create_hj_key_for_table(JOIN *join, JOIN_TAB *join_tab,
|
||||
key_parts++;
|
||||
}
|
||||
}
|
||||
first_keyuse= FALSE;
|
||||
keyuse++;
|
||||
} while (keyuse->table == table && keyuse->is_for_hash_join());
|
||||
if (!key_parts)
|
||||
|
Reference in New Issue
Block a user