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

Remove Item::get_temporal_with_sql_mode() and val_xxx_from_date()

    XMLWordPrintable

Details

    Description

      Item::get_temporal_with_sql_mode() has a test for field_type(). This is not friendly for new data types.

      Under terms of this task we'll do the following:

      • Remove Item::get_temporal_with_sql_mode()
      • Remove these methods from Item:

          my_decimal *val_decimal_from_date(my_decimal *decimal_value);
          my_decimal *val_decimal_from_time(my_decimal *decimal_value);
          longlong val_int_from_date();
          double val_real_from_date();
          String *val_string_from_date(String *str);
        

      • Introduce to_double(), to_longlong(), to_decimal(), to_string() methods in Time, Date, Datetime
      • The code that previously used val_xxx_from_date() will be changed to instantiate Time, Date or Datetime, then call these new methods to_xxx().
      • Remove Item_temporal_func and derive Item_timefunc, Item_datefunc, Item_datetimefunc directly from Item_func, with simultaneous adding val_xxx() methods like this (in case of Item_datetimefunc):

          longlong val_int() { return Datetime(this).to_longlong(); }
          double val_real() { return Datetime(this).to_double(); }
          String *val_str(String *to) { return Datetime(this).to_string(to, decimals); }
          my_decimal *val_decimal(my_decimal *to) { return Datetime(this).to_decimal(to); }
        

      • Remove Item_temporal_typecast and derive Item_time_typecast, Item_date_typecast, Item_datetime_typecast directly from the corresponding Item_(timefunc|datefunc|datetimefunc). This is to avoid code duplication in val_xxx().
      • Remove this code from Item_temporal_literal:

          bool get_date_with_sql_mode(MYSQL_TIME *to);
          String *val_str(String *str)
          { return val_string_from_date(str); }
          longlong val_int()
          { return val_int_from_date(); }
          double val_real()
          { return val_real_from_date(); }
          my_decimal *val_decimal(my_decimal *decimal_value)
          { return  val_decimal_from_date(decimal_value); }
        

        and add a Time, Date, Datetime based code into Item_(time|date|datetime)_literal instead.

      • Do the same changes in Item_cache_(time|date|datetime)
      • Add classes Handler_temporal, Handler_temporal_string, Handler_date, Handler_time, Handler_datetime into Item_handled_func and reorganize Func_handler_xxx in item_timefunc.h to derive from these new classes.
      • Add class Temporal_hybrid - a MYSQL_TIME based class, but (unlike Time,Date,Datetime) without automatic timestamp type conversion. Use it in Handler_temporal_string, which will be the parent class for Func_handler_add_time_xxx and Func_handler_date_add_interval_xxx.

      After this change there will be four classes to get MYSQL_TIME from an Item:

      • Time - with automatic conversion to MYSQL_TIMESTAMP_TIME
      • Date - with automatic conversion to MYSQL_TIMESTAMP_DATE
      • Datetime - with automatic conversion to MYSQL_TIMESTAMP_DATE
      • Temporal_hybrid - without automatic timestamp type conversion

      All these four classes will have methods:

      • to_longlong
      • to_double
      • to_string
      • to_decimal

      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.