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

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

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

            bar Alexander Barkov created issue -
            bar Alexander Barkov made changes -
            Field Original Value New Value
            bar Alexander Barkov made changes -
            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:
            {code:cpp}
              Time(int *warn, bool neg, ulonglong hour,
                   uint minute, const Sec6 &second);
            {code}
            and move this code from Item_func_maketime::get_date():
            {code:cpp}
              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();
              }
            {code}
            to this new constructor. It will be easier to reuse this code this way.
            Later, nanosecond rounding will be needed here.
            - 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:
            {code:cpp}
              Time(int *warn, bool neg, ulonglong hour,
                   uint minute, const Sec6 &second);
            {code}
            and move this code from Item_func_maketime::get_date():
            {code:cpp}
              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();
              }
            {code}
            to this new constructor. It will be easier to reuse this code this way.
            Later, nanosecond rounding will be added Item_func_maketime::get_date().
            bar Alexander Barkov made changes -
            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:
            {code:cpp}
              Time(int *warn, bool neg, ulonglong hour,
                   uint minute, const Sec6 &second);
            {code}
            and move this code from Item_func_maketime::get_date():
            {code:cpp}
              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();
              }
            {code}
            to this new constructor. It will be easier to reuse this code this way.
            Later, nanosecond rounding will be added Item_func_maketime::get_date().
            - 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:
            {code:cpp}
              Time(int *warn, bool neg, ulonglong hour,
                   uint minute, const Sec6 &second);
            {code}
            and move this code from Item_func_maketime::get_date():
            {code:cpp}
              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();
              }
            {code}
            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().
            bar Alexander Barkov made changes -
            Summary New class Timestamp and and cleanups in Date, Datetime, Field for rounding New class Timestamp and cleanups in Date, Datetime, Field for rounding
            bar Alexander Barkov made changes -
            issue.field.resolutiondate 2018-11-22 10:53:56.0 2018-11-22 10:53:56.974
            bar Alexander Barkov made changes -
            Fix Version/s 10.4.1 [ 23228 ]
            Fix Version/s 10.4 [ 22408 ]
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 90815 ] MariaDB v4 [ 133766 ]

            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.