Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-12588

Add Type_handler::type_handler_for_tmp_table() and Type_handler::type_handler_for_union()

    Details

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                bar Alexander Barkov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: