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

Add class Type_numeric_attributes

    XMLWordPrintable

    Details

      Description

      We should eventually remove DTCollation from non-string items, as it's always initialized to DTCollation_numeric() and therefore wastes memory.

      As a step to this, let's move the following members from Type_std_attributes:

      • max_length
      • decimals
      • unsigned_flag

      into a new class Type_numeric_attributes and derive Type_std_attributes from it.

      Let's also add a new virtual method in Field:

      virtual Type_numeric_attributes type_numeric_attributes() const;
      

      and turn Field::type_std_attributes() from a virtual to a non-virtual method like this:

        Type_std_attributes type_std_attributes() const
        {
          return Type_std_attributes(type_numeric_attributes(), dtcollation());
        }
      

      All former Type_std_attributes methods that operate on only the moved members should also move to class Type_numeric_attributes.

      As a result, the classes will look about like this:

      class Type_numeric_attributes
      {
      public:
        static uint count_unsigned(Item **item, uint nitems);
        static uint32 find_max_char_length(Item **item, uint nitems);
        static uint32 find_max_octet_length(Item **item, uint nitems);
        static int find_max_decimal_int_part(Item **item, uint nitems);
        static uint find_max_decimals(Item **item, uint nitems);
      public:
        /*
          The maximum value length in characters multiplied by collation->mbmaxlen.
          Almost always it's the maximum value length in bytes.
        */
        uint32 max_length;
        uint decimals;
        bool unsigned_flag;
      public:
        Type_numeric_attributes()
         :max_length(0), decimals(0), unsigned_flag(false)
        { }
        Type_numeric_attributes(uint32 max_length_arg, uint decimals_arg,
                                bool unsigned_flag_arg)
         :max_length(max_length_arg),
          decimals(decimals_arg),
          unsigned_flag(unsigned_flag_arg)
        { }
      protected:
        void aggregate_numeric_attributes_real(Item **item, uint nitems);
        void aggregate_numeric_attributes_decimal(Item **item, uint nitems,
                                                  bool unsigned_arg);
      };
      

      class Type_std_attributes: public Type_numeric_attributes
      {
      public:
        DTCollation collation;
        Type_std_attributes()
         :collation(&my_charset_bin, DERIVATION_COERCIBLE)
        { }
        Type_std_attributes(const Type_numeric_attributes &nattr,
                            const DTCollation &dtc)
         :Type_numeric_attributes(nattr), collation(dtc)
        { }
        ...
      };
      

        Attachments

          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: