[MDEV-17792] New class Timestamp and cleanups in Date, Datetime, Field for rounding Created: 2018-11-22  Updated: 2018-11-22  Resolved: 2018-11-22

Status: Closed
Project: MariaDB Server
Component/s: Temporal Types
Fix Version/s: 10.4.1

Type: Task Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-16991 Rounding vs truncation for TIME, DATE... Closed

 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().


Generated at Thu Feb 08 08:39:08 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.