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

New class Timestamp and cleanups in Date, Datetime, Field for rounding

    XMLWordPrintable

Details

    Description

      • Introduce a new class Timestamp and move Timeval::trunc() to Timestamp.
        Later new methods like round() will be added to Timestamp.
        Add Field_timestamp::store_TIMESTAMP() and use it instead of
        store_TIMEVAL() in Field_timestamp methods.
      • Add data-type specific constructors for classes Time, Datetime
        for numeric data types: Longlong_hybrid, double, my_decimal*.
        Make old constructors (accepting Sec6) protected. It will make
        the caller code simpler. Fix Field_xxx::store_TIME_with_warning()
        and Field::store()in field.cc accordingly.
      • Add a new constructor Datetime(THD *thd, const timeval &tv).
        Move the code from Field_datetime::set_time() to this new
        constructor. It will be much easier to reuse this code this way.
      • Reorganize the code in static functions Field::do_field_temporal()
        and Field_time::do_field_time(). Add separate functions
        do_field_date() and do_field_datetime(). Modify
        do_field_temporal() to accept a new date_mode_t parameter.
        Reuse the new version of do_field_temporal() from all
        type specific methods: do_field_time(), do_field_date(),
        do_field_datetime().This will remove duplicate code for now.
        Later, do_field_date() and do_field_datetime() will pass
        different rounding flags.
      • Add a new constructor:

          Time(int *warn, bool neg, ulonglong hour,
               uint minute, const Sec6 &second);
        

        and move this code from Item_func_maketime::get_date():

          bzero(ltime, sizeof(*ltime));
          ltime->time_type= MYSQL_TIMESTAMP_TIME;
          ltime->neg= hour.neg();
         
          if (hour.abs() <= TIME_MAX_HOUR)
          {
            ltime->hour=   (uint) hour.abs();
            ltime->minute= (uint) minute;
            ltime->second= (uint) sec.sec();
            ltime->second_part= sec.usec();
          }
        

        to this new constructor. It will be easier to reuse this code this way.
        Later, nanosecond rounding will be added to Item_func_maketime::get_date().

      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.