Commit c2509a15 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-13972 crash in Item_func_sec_to_time::get_date

parent e30b6a98
...@@ -4367,5 +4367,13 @@ NO_ENGINE_SUBSTITUTION ...@@ -4367,5 +4367,13 @@ NO_ENGINE_SUBSTITUTION
SET sql_mode=DEFAULT; SET sql_mode=DEFAULT;
SET NAMES utf8; SET NAMES utf8;
# #
# MDEV-13972 crash in Item_func_sec_to_time::get_date
#
SELECT SEC_TO_TIME(CONVERT(900*24*60*60 USING ucs2));
SEC_TO_TIME(CONVERT(900*24*60*60 USING ucs2))
838:59:59.999999
Warnings:
Warning 1292 Truncated incorrect time value: '77760000'
#
# End of 5.5 tests # End of 5.5 tests
# #
...@@ -2638,5 +2638,25 @@ a ...@@ -2638,5 +2638,25 @@ a
DROP TABLE t1; DROP TABLE t1;
SET sql_mode=DEFAULT; SET sql_mode=DEFAULT;
# #
# MDEV-13972 crash in Item_func_sec_to_time::get_date
#
DO TO_DAYS(SEC_TO_TIME(TIME(CEILING(UUID()))));
DO TO_DAYS(SEC_TO_TIME(MAKEDATE('',RAND(~('')))));
Warnings:
Warning 1292 Truncated incorrect INTEGER value: ''
Warning 1292 Truncated incorrect INTEGER value: ''
Warning 1292 Truncated incorrect INTEGER value: ''
Warning 1292 Truncated incorrect time value: '20000101'
SELECT TO_DAYS(SEC_TO_TIME(MAKEDATE(0,RAND(~0))));
TO_DAYS(SEC_TO_TIME(MAKEDATE(0,RAND(~0))))
0
Warnings:
Warning 1292 Truncated incorrect time value: '20000101'
SELECT SEC_TO_TIME(MAKEDATE(0,RAND(~0)));
SEC_TO_TIME(MAKEDATE(0,RAND(~0)))
838:59:59
Warnings:
Warning 1292 Truncated incorrect time value: '20000101'
#
# End of 5.5 tests # End of 5.5 tests
# #
...@@ -862,6 +862,13 @@ SELECT @@sql_mode; ...@@ -862,6 +862,13 @@ SELECT @@sql_mode;
SET sql_mode=DEFAULT; SET sql_mode=DEFAULT;
SET NAMES utf8; SET NAMES utf8;
--echo #
--echo # MDEV-13972 crash in Item_func_sec_to_time::get_date
--echo #
SELECT SEC_TO_TIME(CONVERT(900*24*60*60 USING ucs2));
--echo # --echo #
--echo # End of 5.5 tests --echo # End of 5.5 tests
--echo # --echo #
...@@ -1615,6 +1615,21 @@ SELECT * FROM t1; ...@@ -1615,6 +1615,21 @@ SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
SET sql_mode=DEFAULT; SET sql_mode=DEFAULT;
--echo #
--echo # MDEV-13972 crash in Item_func_sec_to_time::get_date
--echo #
# The below query can return warning sporadically
--disable_warnings
DO TO_DAYS(SEC_TO_TIME(TIME(CEILING(UUID()))));
--enable_warnings
DO TO_DAYS(SEC_TO_TIME(MAKEDATE('',RAND(~('')))));
SELECT TO_DAYS(SEC_TO_TIME(MAKEDATE(0,RAND(~0))));
SELECT SEC_TO_TIME(MAKEDATE(0,RAND(~0)));
--echo # --echo #
--echo # End of 5.5 tests --echo # End of 5.5 tests
--echo # --echo #
...@@ -1733,9 +1733,18 @@ bool Item_func_sec_to_time::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) ...@@ -1733,9 +1733,18 @@ bool Item_func_sec_to_time::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
ltime->hour= TIME_MAX_HOUR+1; ltime->hour= TIME_MAX_HOUR+1;
check_time_range(ltime, decimals, &unused); check_time_range(ltime, decimals, &unused);
make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, if (!err)
err->ptr(), err->length(), {
MYSQL_TIMESTAMP_TIME, NullS); ErrConvInteger err2(sec, unsigned_flag);
make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
&err2, MYSQL_TIMESTAMP_TIME, NullS);
}
else
{
ErrConvString err2(err);
make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
&err2, MYSQL_TIMESTAMP_TIME, NullS);
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment