Commit 10408782 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-9215 Detect cmp_type() and result_type() from field_type()

Part8: Derive Item_copy from Type_handler_hybrid_field_type
parent 192c748c
......@@ -4539,25 +4539,20 @@ class Item_int_with_ref :public Item_int
from Item_).
*/
class Item_copy :public Item
class Item_copy :public Item,
public Type_handler_hybrid_field_type
{
protected:
/**
Stores the type of the resulting field that would be used to store the data
Type_handler_hybrid_field_type is used to
store the type of the resulting field that would be used to store the data
in the cache. This is to avoid calls to the original item.
*/
enum enum_field_types cached_field_type;
/** The original item that is copied */
Item *item;
/**
Stores the result type of the original item, so it can be returned
without calling the original item's method
*/
Item_result cached_result_type;
/**
Constructor of the Item_copy class
......@@ -4570,8 +4565,7 @@ class Item_copy :public Item
null_value=maybe_null=item->maybe_null;
Type_std_attributes::set(item);
name=item->name;
cached_field_type= item->field_type();
cached_result_type= item->result_type();
set_handler_by_field_type(item->field_type());
fixed= item->fixed;
}
......@@ -4596,8 +4590,13 @@ class Item_copy :public Item
Item *get_item() { return item; }
/** All of the subclasses should have the same type tag */
enum Type type() const { return COPY_STR_ITEM; }
enum_field_types field_type() const { return cached_field_type; }
enum Item_result result_type () const { return cached_result_type; }
enum_field_types field_type() const
{ return Type_handler_hybrid_field_type::field_type(); }
enum Item_result result_type () const
{ return Type_handler_hybrid_field_type::result_type(); }
enum Item_result cmp_type () const
{ return Type_handler_hybrid_field_type::cmp_type(); }
void make_field(THD *thd, Send_field *field) { item->make_field(thd, field); }
table_map used_tables() const { return (table_map) 1L; }
......
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