Commit 380ec909 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-12710 Fix Item_cache constructors to accept Type_handler instead of enum_field_types

parent 26fa7232
...@@ -9322,9 +9322,8 @@ Item *Item_cache_int::convert_to_basic_const_item(THD *thd) ...@@ -9322,9 +9322,8 @@ Item *Item_cache_int::convert_to_basic_const_item(THD *thd)
} }
Item_cache_temporal::Item_cache_temporal(THD *thd, Item_cache_temporal::Item_cache_temporal(THD *thd, const Type_handler *handler)
enum_field_types field_type_arg): :Item_cache_int(thd, handler)
Item_cache_int(thd, field_type_arg)
{ {
if (mysql_timestamp_type() == MYSQL_TIMESTAMP_ERROR) if (mysql_timestamp_type() == MYSQL_TIMESTAMP_ERROR)
set_handler(&type_handler_datetime2); set_handler(&type_handler_datetime2);
...@@ -9470,7 +9469,7 @@ void Item_cache_temporal::store_packed(longlong val_arg, Item *example_arg) ...@@ -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 *Item_cache_temporal::clone_item(THD *thd)
{ {
Item_cache_temporal *item= new (thd->mem_root) 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); item->store_packed(value, example);
return item; return item;
} }
......
...@@ -5537,7 +5537,7 @@ class Item_cache: public Item_basic_constant, ...@@ -5537,7 +5537,7 @@ class Item_cache: public Item_basic_constant,
public: public:
Item_cache(THD *thd): Item_cache(THD *thd):
Item_basic_constant(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), example(0), cached_field(0),
value_cached(0) value_cached(0)
{ {
...@@ -5546,9 +5546,9 @@ class Item_cache: public Item_basic_constant, ...@@ -5546,9 +5546,9 @@ class Item_cache: public Item_basic_constant,
null_value= 1; null_value= 1;
} }
protected: protected:
Item_cache(THD *thd, enum_field_types field_type_arg): Item_cache(THD *thd, const Type_handler *handler):
Item_basic_constant(thd), Item_basic_constant(thd),
Type_handler_hybrid_field_type(field_type_arg), Type_handler_hybrid_field_type(handler),
example(0), cached_field(0), example(0), cached_field(0),
value_cached(0) value_cached(0)
{ {
...@@ -5668,10 +5668,10 @@ class Item_cache_int: public Item_cache ...@@ -5668,10 +5668,10 @@ class Item_cache_int: public Item_cache
protected: protected:
longlong value; longlong value;
public: 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) {} value(0) {}
Item_cache_int(THD *thd, enum_field_types field_type_arg): Item_cache_int(THD *thd, const Type_handler *handler):
Item_cache(thd, field_type_arg), value(0) {} Item_cache(thd, handler), value(0) {}
double val_real(); double val_real();
longlong val_int(); longlong val_int();
...@@ -5689,7 +5689,7 @@ class Item_cache_int: public Item_cache ...@@ -5689,7 +5689,7 @@ class Item_cache_int: public Item_cache
class Item_cache_temporal: public Item_cache_int class Item_cache_temporal: public Item_cache_int
{ {
public: 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); String* val_str(String *str);
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
longlong val_int(); longlong val_int();
...@@ -5717,7 +5717,7 @@ class Item_cache_real: public Item_cache ...@@ -5717,7 +5717,7 @@ class Item_cache_real: public Item_cache
{ {
double value; double value;
public: 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) {} value(0) {}
double val_real(); double val_real();
...@@ -5737,7 +5737,7 @@ class Item_cache_decimal: public Item_cache ...@@ -5737,7 +5737,7 @@ class Item_cache_decimal: public Item_cache
protected: protected:
my_decimal decimal_value; my_decimal decimal_value;
public: 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(); double val_real();
longlong val_int(); longlong val_int();
...@@ -5759,7 +5759,7 @@ class Item_cache_str: public Item_cache ...@@ -5759,7 +5759,7 @@ class Item_cache_str: public Item_cache
public: public:
Item_cache_str(THD *thd, const Item *item): 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 && is_varbinary(item->type() == FIELD_ITEM &&
Item_cache_str::field_type() == MYSQL_TYPE_VARCHAR && Item_cache_str::field_type() == MYSQL_TYPE_VARCHAR &&
!((const Item_field *) item)->field->has_charset()) !((const Item_field *) item)->field->has_charset())
......
...@@ -735,8 +735,8 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg, ...@@ -735,8 +735,8 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
{ {
if (!thd) if (!thd)
thd= current_thd; thd= current_thd;
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, f_type); Item_cache_temporal *cache= new (thd->mem_root) Item_cache_temporal(thd, h);
cache->store_packed(value, item); cache->store_packed(value, item);
*cache_arg= cache; *cache_arg= cache;
*item_arg= cache_arg; *item_arg= cache_arg;
......
...@@ -2050,7 +2050,7 @@ Type_handler_row::Item_get_cache(THD *thd, const Item *item) const ...@@ -2050,7 +2050,7 @@ Type_handler_row::Item_get_cache(THD *thd, const Item *item) const
Item_cache * Item_cache *
Type_handler_int_result::Item_get_cache(THD *thd, const Item *item) const 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 * Item_cache *
...@@ -2074,7 +2074,7 @@ Type_handler_string_result::Item_get_cache(THD *thd, const Item *item) const ...@@ -2074,7 +2074,7 @@ Type_handler_string_result::Item_get_cache(THD *thd, const Item *item) const
Item_cache * Item_cache *
Type_handler_temporal_result::Item_get_cache(THD *thd, const Item *item) const 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:: ...@@ -4290,7 +4290,7 @@ Item *Type_handler_time_common::
longlong value= item->val_time_packed(); longlong value= item->val_time_packed();
if (item->null_value) if (item->null_value)
return new (thd->mem_root) Item_null(thd, item->name.str); 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) if (cache)
cache->store_packed(value, item); cache->store_packed(value, item);
return cache; return cache;
...@@ -4304,7 +4304,7 @@ Item *Type_handler_temporal_with_date:: ...@@ -4304,7 +4304,7 @@ Item *Type_handler_temporal_with_date::
longlong value= item->val_datetime_packed(); longlong value= item->val_datetime_packed();
if (item->null_value) if (item->null_value)
return new (thd->mem_root) Item_null(thd, item->name.str); 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) if (cache)
cache->store_packed(value, item); cache->store_packed(value, item);
return cache; return cache;
......
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