As a part of preparatory work for MDEV-4912, we'll add a new virtual method in Type_handler:
virtual Item_cache *Item_get_cache(THD *thd, const Item *item) const;
|
and split this code into implementations of the new virtual method:
Item_cache* Item_cache::get_cache(THD *thd, const Item *item,
|
const Item_result type)
|
{
|
MEM_ROOT *mem_root= thd->mem_root;
|
switch (type) {
|
case INT_RESULT:
|
return new (mem_root) Item_cache_int(thd, item->field_type());
|
case REAL_RESULT:
|
return new (mem_root) Item_cache_real(thd);
|
case DECIMAL_RESULT:
|
return new (mem_root) Item_cache_decimal(thd);
|
case STRING_RESULT:
|
return new (mem_root) Item_cache_str(thd, item);
|
case ROW_RESULT:
|
return new (mem_root) Item_cache_row(thd);
|
case TIME_RESULT:
|
return new (mem_root) Item_cache_temporal(thd, item->field_type());
|
}
|
return 0; // Impossible
|
}
|
This will allow data type plugins to create their own versions of Item_cache, to optimize comparison with constants.