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

Unify make_table_field() and make_table_field_from_def() for integer and real types

    XMLWordPrintable

    Details

      Description

      In order to remove some duplicate code and simplify creating data type plugins, lets unify these Type_handler methods:

        virtual Field *make_table_field(MEM_ROOT *root,
                                        const LEX_CSTRING *name,
                                        const Record_addr &addr,
                                        const Type_all_attributes &attr,
                                        TABLE *table) const= 0;
      

      and

        virtual Field *
        make_table_field_from_def(TABLE_SHARE *share,
                                  MEM_ROOT *mem_root,
                                  const LEX_CSTRING *name,
                                  const Record_addr &addr,
                                  const Bit_addr &bit,
                                  const Column_definition_attributes *attr,
                                  uint32 flags) const= 0;
      

      for Type_handler_int_result and Type_handler_real_result descendants.

      Details

      Let's add a new constructor:

      Column_definition_attributes::
        Column_definition_attributes(const Type_all_attributes &attr)
       :length(attr.max_length),
        decimals(attr.decimals),
        unireg_check(Field::NONE),
        interval(attr.get_typelib()),
        charset(attr.collation.collation),
        srid(0),
        pack_flag(attr.unsigned_flag ? 0 : FIELDFLAG_DECIMAL)
      {}
      

      Let's remove these virtual method implementations:

      • Type_handler_tiny::make_table_field()
      • Type_handler_short::make_table_field()
      • Type_handler_long::make_table_field()
      • Type_handler_longlong::make_table_field()
      • Type_handler_int24::make_table_field()
      • Type_handler_year::make_table_field()
      • Type_handler_float::make_table_field()
      • Type_handler_double::make_table_field()

      Instead, let's add these two virtual method implementations:

      Field *Type_handler_int_result::make_table_field(MEM_ROOT *root,
                                                  const LEX_CSTRING *name,
                                                  const Record_addr &addr,
                                                  const Type_all_attributes &attr,
                                                  TABLE_SHARE *share) const
      {
        DBUG_ASSERT(is_unsigned() == attr.unsigned_flag);
        Column_definition_attributes dattr(attr);
        return make_table_field_from_def(share, root, name, addr,
                                         Bit_addr(), &dattr, 0);
      }
      

      Field *
      Type_handler_real_result::make_table_field(MEM_ROOT *root,
                                                 const LEX_CSTRING *name,
                                                 const Record_addr &addr,
                                                 const Type_all_attributes &attr,
                                                 TABLE_SHARE *share) const
      {
        Column_definition_attributes dattr(attr);
        return make_table_field_from_def(share, root, name, addr,
                                         Bit_addr(), &dattr, 0);
      }
      

      Note, later, in separate changes, we'll also unify the same methods for descendants of:

      • Type_handler_temporal_result
      • Type_handler_decimal_result
      • Type_handler_string_result

        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: