Commit 622115ee authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: extend Item_cache::get_cache() to accept f_type

Do not assume that it's always item->field_type() - this is not the case
in temporal comparisons (e.g. when comparing DATETIME column with a TIME
literal).
parent 24d6cd7d
...@@ -9543,12 +9543,6 @@ int stored_field_cmp_to_item(THD *thd, Field *field, Item *item) ...@@ -9543,12 +9543,6 @@ int stored_field_cmp_to_item(THD *thd, Field *field, Item *item)
return 0; return 0;
} }
Item_cache* Item_cache::get_cache(THD *thd, const Item *item)
{
return get_cache(thd, item, item->cmp_type());
}
/** /**
Get a cache item of given type. Get a cache item of given type.
...@@ -9559,12 +9553,12 @@ Item_cache* Item_cache::get_cache(THD *thd, const Item *item) ...@@ -9559,12 +9553,12 @@ Item_cache* Item_cache::get_cache(THD *thd, const Item *item)
*/ */
Item_cache* Item_cache::get_cache(THD *thd, const Item *item, Item_cache* Item_cache::get_cache(THD *thd, const Item *item,
const Item_result type) const Item_result type, const enum_field_types f_type)
{ {
MEM_ROOT *mem_root= thd->mem_root; MEM_ROOT *mem_root= thd->mem_root;
switch (type) { switch (type) {
case INT_RESULT: case INT_RESULT:
return new (mem_root) Item_cache_int(thd, item->field_type()); return new (mem_root) Item_cache_int(thd, f_type);
case REAL_RESULT: case REAL_RESULT:
return new (mem_root) Item_cache_real(thd); return new (mem_root) Item_cache_real(thd);
case DECIMAL_RESULT: case DECIMAL_RESULT:
...@@ -9574,7 +9568,7 @@ Item_cache* Item_cache::get_cache(THD *thd, const Item *item, ...@@ -9574,7 +9568,7 @@ Item_cache* Item_cache::get_cache(THD *thd, const Item *item,
case ROW_RESULT: case ROW_RESULT:
return new (mem_root) Item_cache_row(thd); return new (mem_root) Item_cache_row(thd);
case TIME_RESULT: case TIME_RESULT:
return new (mem_root) Item_cache_temporal(thd, item->field_type()); return new (mem_root) Item_cache_temporal(thd, f_type);
} }
return 0; // Impossible return 0; // Impossible
} }
......
...@@ -5551,8 +5551,17 @@ class Item_cache: public Item_basic_constant, ...@@ -5551,8 +5551,17 @@ class Item_cache: public Item_basic_constant,
enum Item_result cmp_type () const enum Item_result cmp_type () const
{ return Type_handler_hybrid_field_type::cmp_type(); } { return Type_handler_hybrid_field_type::cmp_type(); }
static Item_cache* get_cache(THD *thd, const Item *item); static Item_cache* get_cache(THD *thd, const Item* item,
static Item_cache* get_cache(THD *thd, const Item* item, const Item_result type); const Item_result type, const enum_field_types f_type);
static Item_cache* get_cache(THD *thd, const Item* item,
const Item_result type)
{
return get_cache(thd, item, type, item->field_type());
}
static Item_cache* get_cache(THD *thd, const Item *item)
{
return get_cache(thd, item, item->cmp_type());
}
virtual void keep_array() {} virtual void keep_array() {}
virtual void print(String *str, enum_query_type query_type); virtual void print(String *str, enum_query_type query_type);
bool eq_def(const Field *field) bool eq_def(const Field *field)
......
...@@ -90,8 +90,7 @@ class Item_row: public Item, ...@@ -90,8 +90,7 @@ class Item_row: public Item,
Item_result cmp_type() const { return ROW_RESULT; } Item_result cmp_type() const { return ROW_RESULT; }
enum_field_types field_type() const enum_field_types field_type() const
{ {
DBUG_ASSERT(0); return MYSQL_TYPE_NULL;
return MYSQL_TYPE_DOUBLE;
} }
void update_used_tables() void update_used_tables()
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment