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

Split Item_type_holder::display_length into virtual methods in Type_handler

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

            bar Alexander Barkov created issue -
            bar Alexander Barkov made changes -
            Field Original Value New Value
            bar Alexander Barkov made changes -
            Description The method {{Item_type_holder::display_length(Item *)}} has this {{switch}}:
            {code:cpp}
              switch (item->field_type())
            {code}

            This is not friendly to pluggable data types.

            We'll introduce a new virtual method:
            {code:cpp}
            virtual uint32 max_display_length(const Item *item) const;
            {code}
            and move the pieces from {{Item_type_holder::display_length(Item *)}} into implementations of various {{Type_handler_xxx::max_display_length}}.
            The method {{Item_type_holder::display_length(Item *)}} has this {{switch}}:
            {code:cpp}
              switch (item->field_type())
            {code}

            This is not friendly to pluggable data types.

            We'll introduce a new Type_handler virtual method:
            {code:cpp}
            virtual uint32 max_display_length(const Item *item) const;
            {code}
            and move the pieces from {{Item_type_holder::display_length(Item *)}} into implementations of various {{Type_handler_xxx::max_display_length}}.
            bar Alexander Barkov made changes -
            Description The method {{Item_type_holder::display_length(Item *)}} has this {{switch}}:
            {code:cpp}
              switch (item->field_type())
            {code}

            This is not friendly to pluggable data types.

            We'll introduce a new Type_handler virtual method:
            {code:cpp}
            virtual uint32 max_display_length(const Item *item) const;
            {code}
            and move the pieces from {{Item_type_holder::display_length(Item *)}} into implementations of various {{Type_handler_xxx::max_display_length}}.
            The method {{Item_type_holder::display_length(Item *)}} has this {{switch}}:
            {code:cpp}
              switch (item->field_type())
            {code}

            This is not friendly to pluggable data types.

            We'll introduce a new Type_handler virtual method:
            {code:cpp}
            virtual uint32 max_display_length(const Item *item) const;
            {code}
            and move the pieces from {{Item_type_holder::display_length(Item *)}} into implementations of various {{Type_handler_xxx::max_display_length()}}.
            bar Alexander Barkov made changes -
            Description The method {{Item_type_holder::display_length(Item *)}} has this {{switch}}:
            {code:cpp}
              switch (item->field_type())
            {code}

            This is not friendly to pluggable data types.

            We'll introduce a new Type_handler virtual method:
            {code:cpp}
            virtual uint32 max_display_length(const Item *item) const;
            {code}
            and move the pieces from {{Item_type_holder::display_length(Item *)}} into implementations of various {{Type_handler_xxx::max_display_length()}}.
            The method {{Item_type_holder::display_length(Item *)}} has this {{switch}}:
            {code:cpp}
              switch (item->field_type())
            {code}

            This is not friendly to pluggable data types.

            We'll introduce a new Type_handler virtual method:
            {code:cpp}
            virtual uint32 max_display_length(const Item *item) const;
            {code}
            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}}:
            {code:cpp}
            uint32 Item_type_holder::display_length(Item *item)
            {
              if (item->type() == Item::FIELD_ITEM)
                return ((Item_field *)item)->max_disp_length();
              // the implementation non-field Items
            }
            {code}
            we'll remove the method {{Item_type_holder::display_length()}} and introduce a new virtual method in Item:
            {code:cpp}
             virtual uint32 max_display_length() const
             {
               return type_handler()->max_display_length(this);
             }
            {code}
            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:
            {code:cpp}
            uint32 max_display_length() const { return field->max_display_length(); }
            {code}
            bar Alexander Barkov made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            bar Alexander Barkov made changes -
            Description The method {{Item_type_holder::display_length(Item *)}} has this {{switch}}:
            {code:cpp}
              switch (item->field_type())
            {code}

            This is not friendly to pluggable data types.

            We'll introduce a new Type_handler virtual method:
            {code:cpp}
            virtual uint32 max_display_length(const Item *item) const;
            {code}
            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}}:
            {code:cpp}
            uint32 Item_type_holder::display_length(Item *item)
            {
              if (item->type() == Item::FIELD_ITEM)
                return ((Item_field *)item)->max_disp_length();
              // the implementation non-field Items
            }
            {code}
            we'll remove the method {{Item_type_holder::display_length()}} and introduce a new virtual method in Item:
            {code:cpp}
             virtual uint32 max_display_length() const
             {
               return type_handler()->max_display_length(this);
             }
            {code}
            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:
            {code:cpp}
            uint32 max_display_length() const { return field->max_display_length(); }
            {code}
            The method {{Item_type_holder::display_length(Item *)}} has this {{switch}}:
            {code:cpp}
              switch (item->field_type())
            {code}

            This is not friendly to pluggable data types.

            We'll introduce a new Type_handler virtual method:
            {code:cpp}
            virtual uint32 max_display_length(const Item *item) const;
            {code}
            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}}:
            {code:cpp}
            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
            }
            {code}
            we'll remove the method {{Item_type_holder::display_length()}} and introduce a new virtual method in Item:
            {code:cpp}
             virtual uint32 max_display_length() const
             {
               return type_handler()->max_display_length(this);
             }
            {code}
            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:
            {code:cpp}
            uint32 max_display_length() const { return field->max_display_length(); }
            {code}
            bar Alexander Barkov made changes -
            Assignee Alexander Barkov [ bar ] Nirbhay Choubey [ nirbhay_c ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            nirbhay_c Nirbhay Choubey (Inactive) made changes -
            Assignee Nirbhay Choubey [ nirbhay_c ] Alexander Barkov [ bar ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            bar Alexander Barkov made changes -
            Fix Version/s 10.3.0 [ 22127 ]
            Fix Version/s 10.3 [ 22126 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            bar Alexander Barkov made changes -
            Labels datatype
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 78754 ] MariaDB v4 [ 133072 ]

            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.