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

Split Item_type_holder::display_length into virtual methods in Type_handler

    XMLWordPrintable

Details

    Description

      The method Item_type_holder::display_length(Item *) has this switch:

        switch (item->field_type())
      

      This is not friendly to pluggable data types.

      We'll introduce a new Type_handler virtual method:

      virtual uint32 max_display_length(const Item *item) const;
      

      and move the pieces from Item_type_holder::display_length(Item *) into implementations of various Type_handler_xxx::max_display_length().

      Additionally, instead of doing cast to Item_field:

      uint32 Item_type_holder::display_length(Item *item)
      {
        if (item->type() == Item::FIELD_ITEM)
          return ((Item_field *)item)->max_disp_length();
        return ...; // the implementation for non-field Items
      }
      

      we'll remove the method Item_type_holder::display_length() and introduce a new virtual method in Item:

       virtual uint32 max_display_length() const
       {
         return type_handler()->max_display_length(this);
       }
      

      Notice the default implementation will use max_display_length() of the underlying data type handler.
      Item_field will override this implementation and read the result from the underlying field:

      uint32 max_display_length() const { return field->max_display_length(); }
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.