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

Split Item::temporal_precision() into virtual methods in Type_handler

    XMLWordPrintable

Details

    Description

      This code:

      uint Item::temporal_precision(enum_field_types type_arg)
      {
        if (const_item() && result_type() == STRING_RESULT &&
            !is_temporal_type(field_type()))
        {
      ...
              !(type_arg == MYSQL_TYPE_TIME ?
               str_to_time(tmp->charset(), tmp->ptr(), tmp->length(),
                           &ltime, TIME_TIME_ONLY, &status) :
               str_to_datetime(tmp->charset(), tmp->ptr(), tmp->length(),
                               &ltime, TIME_FUZZY_DATES, &status)))
        }
      ...
        return MY_MIN(decimals, TIME_SECOND_PART_DIGITS);
      }
      

      as well as some pieces of the code calling Item::temporal_precision():

      class Item_temporal_typecast: public Item_temporal_func
      {
        ..
        void fix_length_and_dec_generic(uint int_part_len)
        {
          if (decimals == NOT_FIXED_DEC)
            decimals= args[0]->temporal_precision(field_type());
          fix_attributes_temporal(int_part_len, decimals);
          maybe_null= true;
        }
        ..
      }
      

      are not friendly to pluggable data types, because they use field_type().
      Also, we'll have to fix this code when adding TIMESTAMP WITH TIME ZONE and TIME WITH TIME ZONE.

      To make the code safe for new data types, we'll split this code into two methods in Type_handler:

      +  virtual uint Item_time_precision(Item *item) const;
      +  virtual uint Item_datetime_precision(Item *item) const;
      

      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.