mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Merge branch '11.0' into 11.1
This commit is contained in:
@@ -4910,7 +4910,7 @@ Item_cond::fix_fields(THD *thd, Item **ref)
|
||||
List_iterator<Item> li(list);
|
||||
Item *item;
|
||||
uchar buff[sizeof(char*)]; // Max local vars in function
|
||||
bool is_and_cond= functype() == Item_func::COND_AND_FUNC;
|
||||
|
||||
not_null_tables_cache= 0;
|
||||
used_tables_and_const_cache_init();
|
||||
|
||||
@@ -4952,52 +4952,24 @@ Item_cond::fix_fields(THD *thd, Item **ref)
|
||||
merge_sub_condition(li);
|
||||
item= *li.ref(); // may be substituted in fix_fields/merge_item_if_possible
|
||||
|
||||
used_tables_cache|= item->used_tables();
|
||||
if (item->can_eval_in_optimize() && !item->with_sp_var() &&
|
||||
!cond_has_datetime_is_null(item))
|
||||
{
|
||||
if (item->eval_const_cond() == is_and_cond && is_top_level_item())
|
||||
{
|
||||
/*
|
||||
a. This is "... AND true_cond AND ..."
|
||||
In this case, true_cond has no effect on cond_and->not_null_tables()
|
||||
b. This is "... OR false_cond/null cond OR ..."
|
||||
In this case, false_cond has no effect on cond_or->not_null_tables()
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
a. This is "... AND false_cond/null_cond AND ..."
|
||||
The whole condition is FALSE/UNKNOWN.
|
||||
b. This is "... OR const_cond OR ..."
|
||||
In this case, cond_or->not_null_tables()=0, because the condition
|
||||
const_cond might evaluate to true (regardless of whether some tables
|
||||
were NULL-complemented).
|
||||
*/
|
||||
not_null_tables_cache= (table_map) 0;
|
||||
and_tables_cache= (table_map) 0;
|
||||
}
|
||||
if (thd->is_error())
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
table_map tmp_table_map= item->not_null_tables();
|
||||
not_null_tables_cache|= tmp_table_map;
|
||||
and_tables_cache&= tmp_table_map;
|
||||
|
||||
const_item_cache= FALSE;
|
||||
}
|
||||
used_tables_and_const_cache_join(item);
|
||||
base_flags|= item->base_flags & item_base_t::MAYBE_NULL;
|
||||
with_flags|= item->with_flags;
|
||||
}
|
||||
if (fix_length_and_dec(thd))
|
||||
return TRUE;
|
||||
(void) eval_not_null_tables((void*) 0);
|
||||
|
||||
/*
|
||||
We have to set fixed as some other items will check it and fail if we
|
||||
do not. This can be changed when we properly check if fix_fields()
|
||||
fails in call cases.
|
||||
*/
|
||||
base_flags|= item_base_t::FIXED;
|
||||
if (fix_length_and_dec(thd) || thd->is_error())
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@brief
|
||||
Merge a lower-level condition pointed by the iterator into this Item_cond
|
||||
@@ -5047,6 +5019,9 @@ void Item_cond::merge_sub_condition(List_iterator<Item>& li)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Calculate not_null_tables_cache and and_tables_cache.
|
||||
*/
|
||||
|
||||
bool
|
||||
Item_cond::eval_not_null_tables(void *opt_arg)
|
||||
@@ -5054,15 +5029,17 @@ Item_cond::eval_not_null_tables(void *opt_arg)
|
||||
Item *item;
|
||||
bool is_and_cond= functype() == Item_func::COND_AND_FUNC;
|
||||
List_iterator<Item> li(list);
|
||||
bool found= 0;
|
||||
|
||||
not_null_tables_cache= (table_map) 0;
|
||||
and_tables_cache= ~(table_map) 0;
|
||||
while ((item=li++))
|
||||
{
|
||||
table_map tmp_table_map;
|
||||
if (item->can_eval_in_optimize() && !item->with_sp_var() &&
|
||||
!cond_has_datetime_is_null(item))
|
||||
if (item->can_eval_in_optimize() &&
|
||||
!item->with_sp_var() && !item->with_param() &&
|
||||
!cond_has_datetime_is_null(item) && is_top_level_item())
|
||||
{
|
||||
if (item->eval_const_cond() == is_and_cond && is_top_level_item())
|
||||
if (item->eval_const_cond() == is_and_cond)
|
||||
{
|
||||
/*
|
||||
a. This is "... AND true_cond AND ..."
|
||||
@@ -5081,14 +5058,19 @@ Item_cond::eval_not_null_tables(void *opt_arg)
|
||||
const_cond might evaluate to true (regardless of whether some tables
|
||||
were NULL-complemented).
|
||||
*/
|
||||
found= 1;
|
||||
not_null_tables_cache= (table_map) 0;
|
||||
and_tables_cache= (table_map) 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_table_map= item->not_null_tables();
|
||||
not_null_tables_cache|= tmp_table_map;
|
||||
table_map tmp_table_map= item->not_null_tables();
|
||||
if (!found)
|
||||
{
|
||||
/* We should not depend on the order of items */
|
||||
not_null_tables_cache|= tmp_table_map;
|
||||
}
|
||||
and_tables_cache&= tmp_table_map;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user