mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into magare.gmz:/home/kgeorge/mysql/autopush/B30788-5.0-opt
This commit is contained in:
@ -217,6 +217,7 @@ static void select_describe(JOIN *join, bool need_tmp_table,bool need_order,
|
||||
bool distinct, const char *message=NullS);
|
||||
static Item *remove_additional_cond(Item* conds);
|
||||
static void add_group_and_distinct_keys(JOIN *join, JOIN_TAB *join_tab);
|
||||
static bool test_if_ref(Item_field *left_item,Item *right_item);
|
||||
|
||||
|
||||
/*
|
||||
@ -681,9 +682,6 @@ err:
|
||||
without "checking NULL", remove the predicates that were pushed down
|
||||
into the subquery.
|
||||
|
||||
We can remove the equalities that will be guaranteed to be true by the
|
||||
fact that subquery engine will be using index lookup.
|
||||
|
||||
If the subquery compares scalar values, we can remove the condition that
|
||||
was wrapped into trig_cond (it will be checked when needed by the subquery
|
||||
engine)
|
||||
@ -693,6 +691,12 @@ err:
|
||||
and non-NULL values, we'll do a full table scan and will rely on the
|
||||
equalities corresponding to non-NULL parts of left tuple to filter out
|
||||
non-matching records.
|
||||
|
||||
TODO: We can remove the equalities that will be guaranteed to be true by the
|
||||
fact that subquery engine will be using index lookup. This must be done only
|
||||
for cases where there are no conversion errors of significance, e.g. 257
|
||||
that is searched in a byte. But this requires homogenization of the return
|
||||
codes of all Field*::store() methods.
|
||||
*/
|
||||
|
||||
void JOIN::remove_subq_pushed_predicates(Item **where)
|
||||
@ -700,17 +704,13 @@ void JOIN::remove_subq_pushed_predicates(Item **where)
|
||||
if (conds->type() == Item::FUNC_ITEM &&
|
||||
((Item_func *)this->conds)->functype() == Item_func::EQ_FUNC &&
|
||||
((Item_func *)conds)->arguments()[0]->type() == Item::REF_ITEM &&
|
||||
((Item_func *)conds)->arguments()[1]->type() == Item::FIELD_ITEM)
|
||||
((Item_func *)conds)->arguments()[1]->type() == Item::FIELD_ITEM &&
|
||||
test_if_ref ((Item_field *)((Item_func *)conds)->arguments()[1],
|
||||
((Item_func *)conds)->arguments()[0]))
|
||||
{
|
||||
*where= 0;
|
||||
return;
|
||||
}
|
||||
if (conds->type() == Item::COND_ITEM &&
|
||||
((class Item_func *)this->conds)->functype() ==
|
||||
Item_func::COND_AND_FUNC)
|
||||
{
|
||||
*where= remove_additional_cond(conds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1236,7 +1236,7 @@ JOIN::optimize()
|
||||
{
|
||||
if (!having)
|
||||
{
|
||||
Item *where= 0;
|
||||
Item *where= conds;
|
||||
if (join_tab[0].type == JT_EQ_REF &&
|
||||
join_tab[0].ref.items[0]->name == in_left_expr_name)
|
||||
{
|
||||
@ -11892,8 +11892,12 @@ static bool test_if_ref(Item_field *left_item,Item *right_item)
|
||||
Item *ref_item=part_of_refkey(field->table,field);
|
||||
if (ref_item && ref_item->eq(right_item,1))
|
||||
{
|
||||
right_item= right_item->real_item();
|
||||
if (right_item->type() == Item::FIELD_ITEM)
|
||||
return (field->eq_def(((Item_field *) right_item)->field));
|
||||
/* remove equalities injected by IN->EXISTS transformation */
|
||||
else if (right_item->type() == Item::CACHE_ITEM)
|
||||
return ((Item_cache *)right_item)->eq_def (field);
|
||||
if (right_item->const_item() && !(right_item->is_null()))
|
||||
{
|
||||
/*
|
||||
|
Reference in New Issue
Block a user