1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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

This commit is contained in:
Alexander Barkov
2017-05-06 13:34:16 +04:00
parent 26fa7232cf
commit 380ec90905
4 changed files with 19 additions and 20 deletions

View File

@ -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;
}

View File

@ -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())

View File

@ -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;

View File

@ -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;