1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Merge next-mr -> next-4284.

This commit is contained in:
Konstantin Osipov
2009-12-16 11:33:54 +03:00
115 changed files with 82821 additions and 150051 deletions

View File

@ -1076,6 +1076,10 @@ JOIN::optimize()
{
conds=new Item_int((longlong) 0,1); // Always false
}
/* Cache constant expressions in WHERE, HAVING, ON clauses. */
cache_const_exprs();
if (make_join_select(this, select, conds))
{
zero_result_cause=
@ -17148,6 +17152,41 @@ bool JOIN::change_result(select_result *res)
DBUG_RETURN(FALSE);
}
/**
Cache constant expressions in WHERE, HAVING, ON conditions.
*/
void JOIN::cache_const_exprs()
{
bool cache_flag= FALSE;
bool *analyzer_arg= &cache_flag;
/* No need in cache if all tables are constant. */
if (const_tables == tables)
return;
if (conds)
conds->compile(&Item::cache_const_expr_analyzer, (uchar **)&analyzer_arg,
&Item::cache_const_expr_transformer, (uchar *)&cache_flag);
cache_flag= FALSE;
if (having)
having->compile(&Item::cache_const_expr_analyzer, (uchar **)&analyzer_arg,
&Item::cache_const_expr_transformer, (uchar *)&cache_flag);
for (JOIN_TAB *tab= join_tab + const_tables; tab < join_tab + tables ; tab++)
{
if (*tab->on_expr_ref)
{
cache_flag= FALSE;
(*tab->on_expr_ref)->compile(&Item::cache_const_expr_analyzer,
(uchar **)&analyzer_arg,
&Item::cache_const_expr_transformer,
(uchar *)&cache_flag);
}
}
}
/**
@} (end of group Query_Optimizer)
*/