[MDEV-12588] Add Type_handler::type_handler_for_tmp_table() and Type_handler::type_handler_for_union() Created: 2017-04-25  Updated: 2017-05-02  Resolved: 2017-04-27

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Fix Version/s: 10.3.1

Type: Task Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: datatype

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed
Relates
relates to MDEV-12656 Crash in CREATE..SELECT..UNION with a... Closed

 Description   

The code in the following methods:

Item::make_string_field()
Item::tmp_table_field_from_field_type()
Item_type_holder::make_field_by_type()

is not friendly to new data types, because it has conditions on field_type.

To make the code more friendly, we'll add two new virtual methods in Type_handler:

virtual const Type_handler *type_handler_for_tmp_table(const Item *) const;
virtual const Type_handler *type_handler_for_union(const Item *) const;

This will simplify the code a lot:

  • Item::make_string_field() will be gone
  • Item_func_group_concat::make_string_field() will be gone
  • Item::tmp_table_field_from_field_type() will simplify to:

    Field *tmp_table_field_from_field_type(TABLE *table)
    {
      const Type_handler *h= type_handler()->type_handler_for_tmp_table(this);
      return h->make_and_init_table_field(&name, Record_addr(maybe_null),
                                          *this, table);
    }
    

  • Item_type_holder::make_field_by_type() will be renamed to create_tmp_field} and simplify to:

    Field *create_tmp_field(bool group, TABLE *table)
    {
      return Item_type_holder::type_handler()->
             make_and_init_table_field(&name, Record_addr(maybe_null),
                                       *this, table);
    }
    

  • The TIME_RESULT, STRING_RESULT, DECIMAL_RESULT branches in Item::create_tmp_field() will be simplified to:

    case TIME_RESULT:
    case DECIMAL_RESULT:
    case STRING_RESULT:
      new_field= tmp_table_field_from_field_type(table);
    



 Comments   
Comment by Oleksandr Byelkin [ 2017-04-27 ]

OK to push.

Comment by Alexander Barkov [ 2017-04-27 ]

Pushed to bb-10.2-ext

Generated at Thu Feb 08 07:58:53 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.