Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
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
- blocks
-
MDEV-16991 Rounding vs truncation for TIME, DATETIME, TIMESTAMP
-
- Closed
-
Activity
Field | Original Value | New Value |
---|---|---|
Link |
This issue blocks |
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(). |
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(). |
Summary | New class Timestamp and and cleanups in Date, Datetime, Field for rounding | New class Timestamp and cleanups in Date, Datetime, Field for rounding |
issue.field.resolutiondate | 2018-11-22 10:53:56.0 | 2018-11-22 10:53:56.974 |
Fix Version/s | 10.4.1 [ 23228 ] | |
Fix Version/s | 10.4 [ 22408 ] | |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Workflow | MariaDB v3 [ 90815 ] | MariaDB v4 [ 133766 ] |