Skip to content

Commit 1040878

Browse files
author
Alexander Barkov
committed
MDEV-9215 Detect cmp_type() and result_type() from field_type()
Part8: Derive Item_copy from Type_handler_hybrid_field_type
1 parent 192c748 commit 1040878

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

sql/item.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4539,25 +4539,20 @@ class Item_int_with_ref :public Item_int
45394539
from Item_).
45404540
*/
45414541

4542-
class Item_copy :public Item
4542+
class Item_copy :public Item,
4543+
public Type_handler_hybrid_field_type
45434544
{
45444545
protected:
45454546

45464547
/**
4547-
Stores the type of the resulting field that would be used to store the data
4548+
Type_handler_hybrid_field_type is used to
4549+
store the type of the resulting field that would be used to store the data
45484550
in the cache. This is to avoid calls to the original item.
45494551
*/
4550-
enum enum_field_types cached_field_type;
45514552

45524553
/** The original item that is copied */
45534554
Item *item;
45544555

4555-
/**
4556-
Stores the result type of the original item, so it can be returned
4557-
without calling the original item's method
4558-
*/
4559-
Item_result cached_result_type;
4560-
45614556
/**
45624557
Constructor of the Item_copy class
45634558
@@ -4570,8 +4565,7 @@ class Item_copy :public Item
45704565
null_value=maybe_null=item->maybe_null;
45714566
Type_std_attributes::set(item);
45724567
name=item->name;
4573-
cached_field_type= item->field_type();
4574-
cached_result_type= item->result_type();
4568+
set_handler_by_field_type(item->field_type());
45754569
fixed= item->fixed;
45764570
}
45774571

@@ -4596,8 +4590,13 @@ class Item_copy :public Item
45964590
Item *get_item() { return item; }
45974591
/** All of the subclasses should have the same type tag */
45984592
enum Type type() const { return COPY_STR_ITEM; }
4599-
enum_field_types field_type() const { return cached_field_type; }
4600-
enum Item_result result_type () const { return cached_result_type; }
4593+
4594+
enum_field_types field_type() const
4595+
{ return Type_handler_hybrid_field_type::field_type(); }
4596+
enum Item_result result_type () const
4597+
{ return Type_handler_hybrid_field_type::result_type(); }
4598+
enum Item_result cmp_type () const
4599+
{ return Type_handler_hybrid_field_type::cmp_type(); }
46014600

46024601
void make_field(THD *thd, Send_field *field) { item->make_field(thd, field); }
46034602
table_map used_tables() const { return (table_map) 1L; }

0 commit comments

Comments
 (0)