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

Add class Type_ext_attributes and Type_handler::join_type_ext_attributes()

    Details

    • Type: Task
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Won't Fix
    • Fix Version/s: N/A
    • Component/s: OTHER
    • Labels:
      None

      Description

      Some data types have extended attrubutes:

      • ENUM/SET have TYPELIB
      • GEOMETRY has geometry type and SRID
        These data types are handled in a very different way all around the code.

      This task will introduce new classes:

      class Type_typelib_attributes
      {
      public:
        TYPELIB *typelib;
      ...
      };
      

      class Type_geom_attributes
      {
      public:
        geometry_type geom_type;
        uint srid;
      ...
      };
      

      class Type_ext_attributes: public Type_geom_attributes,
                                 public Type_typelib_attributes
      {
      ...
      }
      

      • Type_geom_attributes
      • Type_ext_attributes (a child of Type_typelib_attributes and Type_geom_attributes)

      and a new method in Type_handler with this prototype:

      virtual bool join_type_ext_attributes(Type_ext_attributes *attr,
                                             Item *item) const;
      

      The intent is to handle extended data type attributes in a unified way, and remove a few tests for field_type() against MYSQL_TYPE_GEOMETRY, MYSQL_TYPE_SET, MYSQL_TYPE_ENUM.

      The new class Type_ext_attributes will be reused in classes Column_definition, Item_hybrid_func and Item_type_holder, instead of declaring ENUM and GEOMETRY related attributes in every class separately. So these class definitions will change to:

      class Column_definition: public Sql_alloc,
                               public Type_ext_attributes
      {};
       
      class Item_hybrid_func: public Item_func,
                              public Type_handler_hybrid_field_type,
                              public Type_ext_attributes
      { };
       
      class Item_type_holder: public Item,
                              public Type_handler_hybrid_real_field_type,
                              public Type_ext_attributes
      
      

      This means that Column_definition::interval will be renamed to Column_definition::typelib. This will cause changes in a few dozen of lines. But this is OK. We'll eventually have the INTERVAL data type (as in the SQL Standard), so the old name would be confusing. The new name is better.

      Also, this means that Item_type_holder::enum_set_typelib will be renamed to Item_type_holder::typelib. But this will cause changes only in a few lines.

      Note, the new class Type_ext_attributes will be used in a few field creation methods in Type_handler later.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: