mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Added item.real_type() for easy access to the underlaying types for Item_ref and Item_cache_wrapper()
This allows us to simplify and speed up some tests and also remove get_cached_item() sql/item.h: Added item.real_type() Removed get_cached_item() sql/opt_range.cc: Simplify test sql/sql_select.cc: Simplify test sql/sql_show.cc: Simplify test
This commit is contained in:
11
sql/item.h
11
sql/item.h
@ -609,6 +609,12 @@ public:
|
|||||||
virtual enum_field_types string_field_type() const;
|
virtual enum_field_types string_field_type() const;
|
||||||
virtual enum_field_types field_type() const;
|
virtual enum_field_types field_type() const;
|
||||||
virtual enum Type type() const =0;
|
virtual enum Type type() const =0;
|
||||||
|
/*
|
||||||
|
real_type() is the type of base item. This is same as type() for
|
||||||
|
most items, except Item_ref() and Item_cache_wrapper() where it
|
||||||
|
shows the type for the underlaying item.
|
||||||
|
*/
|
||||||
|
virtual enum Type real_type() const { return type(); }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Return information about function monotonicity. See comment for
|
Return information about function monotonicity. See comment for
|
||||||
@ -1185,7 +1191,6 @@ public:
|
|||||||
bool eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs);
|
bool eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs);
|
||||||
|
|
||||||
Item* set_expr_cache(THD *thd, List<Item*> &depends_on);
|
Item* set_expr_cache(THD *thd, List<Item*> &depends_on);
|
||||||
virtual Item *get_cached_item() { return NULL; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -2437,6 +2442,8 @@ public:
|
|||||||
Item_ref(THD *thd, Item_ref *item)
|
Item_ref(THD *thd, Item_ref *item)
|
||||||
:Item_ident(thd, item), result_field(item->result_field), ref(item->ref) {}
|
:Item_ident(thd, item), result_field(item->result_field), ref(item->ref) {}
|
||||||
enum Type type() const { return REF_ITEM; }
|
enum Type type() const { return REF_ITEM; }
|
||||||
|
enum Type real_type() const { return ref ? (*ref)->type() :
|
||||||
|
REF_ITEM; }
|
||||||
bool eq(const Item *item, bool binary_cmp) const
|
bool eq(const Item *item, bool binary_cmp) const
|
||||||
{
|
{
|
||||||
Item *it= ((Item *) item)->real_item();
|
Item *it= ((Item *) item)->real_item();
|
||||||
@ -2628,7 +2635,7 @@ public:
|
|||||||
|
|
||||||
const char *func_name() const { return "<expr_cache>"; }
|
const char *func_name() const { return "<expr_cache>"; }
|
||||||
enum Type type() const { return EXPR_CACHE_ITEM; }
|
enum Type type() const { return EXPR_CACHE_ITEM; }
|
||||||
virtual Item *get_cached_item() { return orig_item; }
|
enum Type real_type() const { return orig_item->type(); }
|
||||||
|
|
||||||
bool set_cache(THD *thd, List<Item*> &depends_on);
|
bool set_cache(THD *thd, List<Item*> &depends_on);
|
||||||
|
|
||||||
|
@ -11707,9 +11707,7 @@ check_group_min_max_predicates(COND *cond, Item_field *min_max_arg_item,
|
|||||||
the MIN/MAX argument field, and disallow the optimization only if this is
|
the MIN/MAX argument field, and disallow the optimization only if this is
|
||||||
so.
|
so.
|
||||||
*/
|
*/
|
||||||
if (cond_type == Item::SUBSELECT_ITEM ||
|
if (cond->real_type() == Item::SUBSELECT_ITEM)
|
||||||
(cond->get_cached_item() &&
|
|
||||||
cond->get_cached_item()->type() == Item::SUBSELECT_ITEM))
|
|
||||||
DBUG_RETURN(FALSE);
|
DBUG_RETURN(FALSE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -12055,9 +12055,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
|
|||||||
{
|
{
|
||||||
if (item->used_tables() & OUTER_REF_TABLE_BIT)
|
if (item->used_tables() & OUTER_REF_TABLE_BIT)
|
||||||
item->update_used_tables();
|
item->update_used_tables();
|
||||||
if (type == Item::SUBSELECT_ITEM ||
|
if ((item->real_type() == Item::SUBSELECT_ITEM) ||
|
||||||
(item->get_cached_item() &&
|
|
||||||
item->get_cached_item()->type() == Item::SUBSELECT_ITEM ) ||
|
|
||||||
(item->used_tables() & ~OUTER_REF_TABLE_BIT))
|
(item->used_tables() & ~OUTER_REF_TABLE_BIT))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -17989,9 +17987,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((real_pos->type() == Item::FUNC_ITEM ||
|
else if ((real_pos->type() == Item::FUNC_ITEM ||
|
||||||
real_pos->type() == Item::SUBSELECT_ITEM ||
|
real_pos->real_type() == Item::SUBSELECT_ITEM ||
|
||||||
(real_pos->get_cached_item() &&
|
|
||||||
real_pos->get_cached_item()->type() == Item::SUBSELECT_ITEM) ||
|
|
||||||
real_pos->type() == Item::CACHE_ITEM ||
|
real_pos->type() == Item::CACHE_ITEM ||
|
||||||
real_pos->type() == Item::COND_ITEM) &&
|
real_pos->type() == Item::COND_ITEM) &&
|
||||||
!real_pos->with_sum_func)
|
!real_pos->with_sum_func)
|
||||||
|
@ -3003,10 +3003,7 @@ bool uses_only_table_name_fields(Item *item, TABLE_LIST *table)
|
|||||||
else if (item->type() == Item::REF_ITEM)
|
else if (item->type() == Item::REF_ITEM)
|
||||||
return uses_only_table_name_fields(item->real_item(), table);
|
return uses_only_table_name_fields(item->real_item(), table);
|
||||||
|
|
||||||
if ((item->type() == Item::SUBSELECT_ITEM ||
|
if (item->real_type() == Item::SUBSELECT_ITEM && !item->const_item())
|
||||||
(item->get_cached_item() &&
|
|
||||||
item->get_cached_item()->type() == Item::SUBSELECT_ITEM))
|
|
||||||
&& !item->const_item())
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
Reference in New Issue
Block a user