diff options
author | Alexander Barkov <bar@mariadb.com> | 2018-08-11 06:47:48 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2018-08-11 06:47:48 +0400 |
commit | 2085f14a8dddf175765d97dcb5306bc2a0578b00 (patch) | |
tree | 24979de5af9a1fef91752d548be6a296e68338c1 /sql/sql_time.h | |
parent | 2966c1e422866f48b68e109ac9e27d52be77fb60 (diff) | |
download | mariadb-git-2085f14a8dddf175765d97dcb5306bc2a0578b00.tar.gz |
MDEV-16938 Move Item::get_time_with_conversion() to Time
The affected code is well covered by tests for MDEV-8766.
Adding only the missing part: the old mode OLD_MODE_ZERO_DATE_TIME_CAST
in combination with 0000-MM-00 and YYYY-00-00.
The old mode in combination with 0000-00-DD was already covered,
so was the new mode with all types of DATETIME values.
Diffstat (limited to 'sql/sql_time.h')
-rw-r--r-- | sql/sql_time.h | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/sql/sql_time.h b/sql/sql_time.h index cfa1468841b..8c6e58856e6 100644 --- a/sql/sql_time.h +++ b/sql/sql_time.h @@ -54,50 +54,6 @@ bool time_to_datetime(THD *thd, const MYSQL_TIME *tm, MYSQL_TIME *dt); bool time_to_datetime_with_warn(THD *thd, const MYSQL_TIME *tm, MYSQL_TIME *dt, ulonglong fuzzydate); -/* - Simply truncate the YYYY-MM-DD part to 0000-00-00 - and change time_type to MYSQL_TIMESTAMP_TIME -*/ -inline void datetime_to_time(MYSQL_TIME *ltime) -{ - DBUG_ASSERT(ltime->time_type == MYSQL_TIMESTAMP_DATE || - ltime->time_type == MYSQL_TIMESTAMP_DATETIME); - DBUG_ASSERT(ltime->neg == 0); - ltime->year= ltime->month= ltime->day= 0; - ltime->time_type= MYSQL_TIMESTAMP_TIME; -} - - -/** - Convert DATE/DATETIME to TIME(dec) - using CURRENT_DATE in a non-old mode, - or using simple truncation in old mode (OLD_MODE_ZERO_DATE_TIME_CAST). - - @param thd - the thread to get the variables.old_behaviour value from - @param dt - the DATE of DATETIME value to convert - @param[out] tm - store result here - @param dec - the desired scale. The fractional part of the result - is checked according to this parameter before returning - the conversion result. "dec" is important in the corner - cases near the max/min limits. - If the result is '838:59:59.999999' and the desired scale - is less than 6, an error is returned. - Note, dec is not important in the - OLD_MODE_ZERO_DATE_TIME_CAST old mode. - - - in case of OLD_MODE_ZERO_DATE_TIME_CAST - the TIME part is simply truncated and "false" is returned. - - otherwise, the result is calculated effectively similar to: - TIMEDIFF(dt, CAST(CURRENT_DATE AS DATETIME)) - If the difference fits into the supported TIME range, "false" is returned, - otherwise a warning is issued and "true" is returned. - - @return false - on success - @return true - on error -*/ -bool datetime_to_time_with_warn(THD *, const MYSQL_TIME *dt, - MYSQL_TIME *tm, uint dec); - inline void datetime_to_date(MYSQL_TIME *ltime) { |