diff --git a/sql/item.cc b/sql/item.cc index 617a612aeea..5a448ef0e63 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -9322,9 +9322,8 @@ Item *Item_cache_int::convert_to_basic_const_item(THD *thd) } -Item_cache_temporal::Item_cache_temporal(THD *thd, - enum_field_types field_type_arg): - Item_cache_int(thd, field_type_arg) +Item_cache_temporal::Item_cache_temporal(THD *thd, const Type_handler *handler) + :Item_cache_int(thd, handler) { if (mysql_timestamp_type() == MYSQL_TIMESTAMP_ERROR) set_handler(&type_handler_datetime2); @@ -9470,7 +9469,7 @@ void Item_cache_temporal::store_packed(longlong val_arg, Item *example_arg) Item *Item_cache_temporal::clone_item(THD *thd) { Item_cache_temporal *item= new (thd->mem_root) - Item_cache_temporal(thd, Item_cache_temporal::field_type()); + Item_cache_temporal(thd, Item_cache_temporal::type_handler()); item->store_packed(value, example); return item; } diff --git a/sql/item.h b/sql/item.h index 7ccbbb4264b..e483ddecd15 100644 --- a/sql/item.h +++ b/sql/item.h @@ -5537,7 +5537,7 @@ protected: public: Item_cache(THD *thd): Item_basic_constant(thd), - Type_handler_hybrid_field_type(MYSQL_TYPE_STRING), + Type_handler_hybrid_field_type(&type_handler_string), example(0), cached_field(0), value_cached(0) { @@ -5546,9 +5546,9 @@ public: null_value= 1; } protected: - Item_cache(THD *thd, enum_field_types field_type_arg): + Item_cache(THD *thd, const Type_handler *handler): Item_basic_constant(thd), - Type_handler_hybrid_field_type(field_type_arg), + Type_handler_hybrid_field_type(handler), example(0), cached_field(0), value_cached(0) { @@ -5668,10 +5668,10 @@ class Item_cache_int: public Item_cache protected: longlong value; public: - Item_cache_int(THD *thd): Item_cache(thd, MYSQL_TYPE_LONGLONG), + Item_cache_int(THD *thd): Item_cache(thd, &type_handler_longlong), value(0) {} - Item_cache_int(THD *thd, enum_field_types field_type_arg): - Item_cache(thd, field_type_arg), value(0) {} + Item_cache_int(THD *thd, const Type_handler *handler): + Item_cache(thd, handler), value(0) {} double val_real(); longlong val_int(); @@ -5689,7 +5689,7 @@ public: class Item_cache_temporal: public Item_cache_int { public: - Item_cache_temporal(THD *thd, enum_field_types field_type_arg); + Item_cache_temporal(THD *thd, const Type_handler *handler); String* val_str(String *str); my_decimal *val_decimal(my_decimal *); longlong val_int(); @@ -5717,7 +5717,7 @@ class Item_cache_real: public Item_cache { double value; public: - Item_cache_real(THD *thd): Item_cache(thd, MYSQL_TYPE_DOUBLE), + Item_cache_real(THD *thd): Item_cache(thd, &type_handler_double), value(0) {} double val_real(); @@ -5737,7 +5737,7 @@ class Item_cache_decimal: public Item_cache protected: my_decimal decimal_value; public: - Item_cache_decimal(THD *thd): Item_cache(thd, MYSQL_TYPE_NEWDECIMAL) {} + Item_cache_decimal(THD *thd): Item_cache(thd, &type_handler_newdecimal) {} double val_real(); longlong val_int(); @@ -5759,7 +5759,7 @@ class Item_cache_str: public Item_cache public: Item_cache_str(THD *thd, const Item *item): - Item_cache(thd, item->field_type()), value(0), + Item_cache(thd, item->type_handler()), value(0), is_varbinary(item->type() == FIELD_ITEM && Item_cache_str::field_type() == MYSQL_TYPE_VARCHAR && !((const Item_field *) item)->field->has_charset()) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index f7f3f991cde..d21f946ebbf 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -735,8 +735,8 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg, { if (!thd) thd= current_thd; - - Item_cache_temporal *cache= new (thd->mem_root) Item_cache_temporal(thd, f_type); + const Type_handler *h= Type_handler::get_handler_by_field_type(f_type); + Item_cache_temporal *cache= new (thd->mem_root) Item_cache_temporal(thd, h); cache->store_packed(value, item); *cache_arg= cache; *item_arg= cache_arg; diff --git a/sql/sql_type.cc b/sql/sql_type.cc index fbf6c0900e0..54645a96982 100644 --- a/sql/sql_type.cc +++ b/sql/sql_type.cc @@ -2050,7 +2050,7 @@ Type_handler_row::Item_get_cache(THD *thd, const Item *item) const Item_cache * Type_handler_int_result::Item_get_cache(THD *thd, const Item *item) const { - return new (thd->mem_root) Item_cache_int(thd, item->field_type()); + return new (thd->mem_root) Item_cache_int(thd, item->type_handler()); } Item_cache * @@ -2074,7 +2074,7 @@ Type_handler_string_result::Item_get_cache(THD *thd, const Item *item) const Item_cache * Type_handler_temporal_result::Item_get_cache(THD *thd, const Item *item) const { - return new (thd->mem_root) Item_cache_temporal(thd, item->field_type()); + return new (thd->mem_root) Item_cache_temporal(thd, item->type_handler()); } /*************************************************************************/ @@ -4290,7 +4290,7 @@ Item *Type_handler_time_common:: longlong value= item->val_time_packed(); if (item->null_value) return new (thd->mem_root) Item_null(thd, item->name.str); - cache= new (thd->mem_root) Item_cache_temporal(thd, field_type()); + cache= new (thd->mem_root) Item_cache_temporal(thd, this); if (cache) cache->store_packed(value, item); return cache; @@ -4304,7 +4304,7 @@ Item *Type_handler_temporal_with_date:: longlong value= item->val_datetime_packed(); if (item->null_value) return new (thd->mem_root) Item_null(thd, item->name.str); - cache= new (thd->mem_root) Item_cache_temporal(thd, field_type()); + cache= new (thd->mem_root) Item_cache_temporal(thd, this); if (cache) cache->store_packed(value, item); return cache;