Commit 00eb6284 authored by Alexander Nozdrin's avatar Alexander Nozdrin

Cherry-pick patch for Bug#56120 from mysql-5.5-bugfixing.

parent f62bf940
...@@ -1715,7 +1715,7 @@ drop table t1; ...@@ -1715,7 +1715,7 @@ drop table t1;
# #
End of 5.1 tests End of 5.1 tests
# #
# Bug#55648: Server crash on MIX/MAX on maximum time value # Bug#55648: Server crash on MIN/MAX on maximum time value
# #
CREATE TABLE t1(c1 TIME NOT NULL); CREATE TABLE t1(c1 TIME NOT NULL);
INSERT INTO t1 VALUES('837:59:59'); INSERT INTO t1 VALUES('837:59:59');
...@@ -1725,3 +1725,13 @@ MAX(c1) ...@@ -1725,3 +1725,13 @@ MAX(c1)
838:59:59 838:59:59
DROP TABLE t1; DROP TABLE t1;
# End of the bug#55648 # End of the bug#55648
#
# Bug#56120: Failed assertion on MIN/MAX on negative time value
#
CREATE TABLE t1(c1 TIME NOT NULL);
INSERT INTO t1 VALUES('-00:00:01');
SELECT MAX(c1),MIN(c1) FROM t1;
MAX(c1) MIN(c1)
-00:00:01 -00:00:01
DROP TABLE t1;
# End of the bug#56120
...@@ -1086,7 +1086,7 @@ drop table t1; ...@@ -1086,7 +1086,7 @@ drop table t1;
--echo End of 5.1 tests --echo End of 5.1 tests
--echo # --echo #
--echo # Bug#55648: Server crash on MIX/MAX on maximum time value --echo # Bug#55648: Server crash on MIN/MAX on maximum time value
--echo # --echo #
CREATE TABLE t1(c1 TIME NOT NULL); CREATE TABLE t1(c1 TIME NOT NULL);
INSERT INTO t1 VALUES('837:59:59'); INSERT INTO t1 VALUES('837:59:59');
...@@ -1095,3 +1095,12 @@ SELECT MAX(c1) FROM t1; ...@@ -1095,3 +1095,12 @@ SELECT MAX(c1) FROM t1;
DROP TABLE t1; DROP TABLE t1;
--echo # End of the bug#55648 --echo # End of the bug#55648
--echo #
--echo # Bug#56120: Failed assertion on MIN/MAX on negative time value
--echo #
CREATE TABLE t1(c1 TIME NOT NULL);
INSERT INTO t1 VALUES('-00:00:01');
SELECT MAX(c1),MIN(c1) FROM t1;
DROP TABLE t1;
--echo # End of the bug#56120
...@@ -7510,9 +7510,14 @@ String *Item_cache_datetime::val_str(String *str) ...@@ -7510,9 +7510,14 @@ String *Item_cache_datetime::val_str(String *str)
return NULL; return NULL;
if (cached_field_type == MYSQL_TYPE_TIME) if (cached_field_type == MYSQL_TYPE_TIME)
{ {
ulonglong time= int_value; longlong time= int_value;
DBUG_ASSERT(time <= TIME_MAX_VALUE);
set_zero_time(&ltime, MYSQL_TIMESTAMP_TIME); set_zero_time(&ltime, MYSQL_TIMESTAMP_TIME);
if (time < 0)
{
time= -time;
ltime.neg= TRUE;
}
DBUG_ASSERT(time <= TIME_MAX_VALUE);
ltime.second= time % 100; ltime.second= time % 100;
time/= 100; time/= 100;
ltime.minute= time % 100; ltime.minute= time % 100;
......
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