summaryrefslogtreecommitdiffstats
path: root/sql/item_timefunc.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 13:22:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 13:22:53 +0000
commit347c164c35eddab388009470e6848cb361ac93f8 (patch)
tree2c0c44eac690f510bb0a35b2a13b36d606b77b6b /sql/item_timefunc.cc
parentReleasing progress-linux version 1:10.11.7-4~progress7.99u1. (diff)
downloadmariadb-347c164c35eddab388009470e6848cb361ac93f8.tar.xz
mariadb-347c164c35eddab388009470e6848cb361ac93f8.zip
Merging upstream version 1:10.11.8.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r--sql/item_timefunc.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index db38e44d..0ac75f90 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -2942,7 +2942,7 @@ bool Item_extract::fix_length_and_dec(THD *thd)
switch (int_type) {
case INTERVAL_YEAR: set_date_length(4); break; // YYYY
case INTERVAL_YEAR_MONTH: set_date_length(6); break; // YYYYMM
- case INTERVAL_QUARTER: set_date_length(2); break; // 1..4
+ case INTERVAL_QUARTER: set_date_length(1); break; // 1..4
case INTERVAL_MONTH: set_date_length(2); break; // MM
case INTERVAL_WEEK: set_date_length(2); break; // 0..52
case INTERVAL_DAY: set_day_length(daylen); break; // DD
@@ -3507,6 +3507,24 @@ bool Item_func_timediff::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzy
if (l_time1.neg != l_time2.neg)
l_sign= -l_sign;
+ if (l_time1.time_type == MYSQL_TIMESTAMP_TIME)
+ {
+ /*
+ In case of TIME-alike arguments:
+ TIMEDIFF('38:59:59', '839:00:00')
+ let's truncate extra fractional seconds that might appear if the argument
+ values were out of the supported TIME range. For example, args[n]->get_time()
+ for the string literal '839:00:00' returns TIME'838:59:59.999999'.
+ The fractional part must be truncated according to this->decimals,
+ to avoid returning more fractional seconds than it was detected
+ during this->fix_length_and_dec().
+ Note, the thd rounding mode should not be important here, as we're removing
+ redundant digits from the maximum possible value: '838:59:59.999999'.
+ */
+ my_time_trunc(&l_time1, decimals);
+ my_time_trunc(&l_time2, decimals);
+ }
+
if (calc_time_diff(&l_time1, &l_time2, l_sign, &l_time3, fuzzydate))
return (null_value= 1);