#At file:///work/bzrroot/56120-bug-5.5-bugfixing/ based on revid:chris.powers@stripped
3190 Evgeny Potemkin 2010-08-20
Bug#56120: Failed assertion on MIX/MAX on negative time value
The Item_cache_datetime::val_str function wasn't taking into account that time
could be negative. This led to failed assertion.
Now Item_cache_datetime::val_str correctly converts negative time values
from integer to string representation.
@ mysql-test/r/func_group.result
Added a test case for the bug#56120.
@ mysql-test/t/func_group.test
Added a test case for the bug#56120.
@ sql/item.cc
Bug#56120: Failed assertion on MIX/MAX on negative time value
Now Item_cache_datetime::val_str correctly converts negative time values
from integer to string representation.
modified:
mysql-test/r/func_group.result
mysql-test/t/func_group.test
sql/item.cc
=== modified file 'mysql-test/r/func_group.result'
--- a/mysql-test/r/func_group.result 2010-08-02 12:36:41 +0000
+++ b/mysql-test/r/func_group.result 2010-08-20 18:19:13 +0000
@@ -1725,3 +1725,13 @@ MAX(c1)
838:59:59
DROP TABLE t1;
# End of the bug#55648
+#
+# Bug#56120: Failed assertion on MIX/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
=== modified file 'mysql-test/t/func_group.test'
--- a/mysql-test/t/func_group.test 2010-08-02 12:36:41 +0000
+++ b/mysql-test/t/func_group.test 2010-08-20 18:19:13 +0000
@@ -1095,3 +1095,12 @@ SELECT MAX(c1) FROM t1;
DROP TABLE t1;
--echo # End of the bug#55648
+--echo #
+--echo # Bug#56120: Failed assertion on MIX/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
+
=== modified file 'sql/item.cc'
--- a/sql/item.cc 2010-08-14 09:11:33 +0000
+++ b/sql/item.cc 2010-08-20 18:19:13 +0000
@@ -7510,9 +7510,15 @@ String *Item_cache_datetime::val_str(Str
return NULL;
if (cached_field_type == MYSQL_TYPE_TIME)
{
- ulonglong time= int_value;
- DBUG_ASSERT(time <= TIME_MAX_VALUE);
+ longlong time= int_value;
+ bool neg= (time < 0) ? TRUE : FALSE;
set_zero_time(<ime, MYSQL_TIMESTAMP_TIME);
+ if (neg)
+ {
+ time= -time;
+ ltime.neg= TRUE;
+ }
+ DBUG_ASSERT(time <= TIME_MAX_VALUE);
ltime.second= time % 100;
time/= 100;
ltime.minute= time % 100;
Attachment: [text/bzr-bundle] bzr/epotemkin@mysql.com-20100820181913-5d8fj8ur75w539t0.bundle
| Thread |
|---|
| • bzr commit into mysql-5.5-bugfixing branch (epotemkin:3190) Bug#56120 | Evgeny Potemkin | 20 Aug |