diff options
author | Alexander Barkov <bar@mariadb.com> | 2020-07-28 17:32:19 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2020-07-28 23:29:08 +0400 |
commit | 5b3b53ce36b9a05832af3a19ae8d846b6669a1f5 (patch) | |
tree | af8b06547a4466125138314a61db6e69ee743d78 /include/my_time.h | |
parent | 69cf6302f30e9bca7d2b0903c29fc1b26b09bcc7 (diff) | |
download | mariadb-git-5b3b53ce36b9a05832af3a19ae8d846b6669a1f5.tar.gz |
MDEV-23311 CEILING() and FLOOR() convert temporal input to numbers, unlike ROUND() and TRUNCATE()
Fixing functions CEILING and FLOOR to return
- TIME for TIME input
- DATETIME for DATETIME and TIMESTAMP input
Diffstat (limited to 'include/my_time.h')
-rw-r--r-- | include/my_time.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/my_time.h b/include/my_time.h index bad2b8bf4b0..b7b54db5586 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -233,9 +233,16 @@ static inline long my_time_fraction_remainder(long nr, uint decimals) DBUG_ASSERT(decimals <= TIME_SECOND_PART_DIGITS); return nr % (long) log_10_int[TIME_SECOND_PART_DIGITS - decimals]; } +static inline void my_datetime_trunc(MYSQL_TIME *ltime, uint decimals) +{ + ltime->second_part-= my_time_fraction_remainder(ltime->second_part, decimals); +} static inline void my_time_trunc(MYSQL_TIME *ltime, uint decimals) { ltime->second_part-= my_time_fraction_remainder(ltime->second_part, decimals); + if (!ltime->second_part && ltime->neg && + !ltime->hour && !ltime->minute && !ltime->second) + ltime->neg= FALSE; } static inline void my_timeval_trunc(struct timeval *tv, uint decimals) { |