sec_to_time() in the integer context was losing the sign of the result

This commit is contained in:
Sergei Golubchik 2011-09-01 14:23:03 +04:00
parent 26bd06feef
commit 11ebbabb08
3 changed files with 8 additions and 1 deletions

View file

@ -27,6 +27,10 @@ sec_to_time('9001.1') sec_to_time('1234567890123.123')
02:30:01.100000 838:59:59.999999
Warnings:
Warning 1292 Truncated incorrect time value: '1234567890123.123'
select sec_to_time(-9001.1), sec_to_time(-9001.1) / 1,
sec_to_time(-9001.1) / 1e0, sec_to_time(-9001) div 1;
sec_to_time(-9001.1) sec_to_time(-9001.1) / 1 sec_to_time(-9001.1) / 1e0 sec_to_time(-9001) div 1
-02:30:01.1 -23001.10000 -23001.1 -23001
select sec_to_time(90011e-1), sec_to_time(1234567890123e30);
sec_to_time(90011e-1) sec_to_time(1234567890123e30)
02:30:01.100000 838:59:59.999999

View file

@ -18,6 +18,8 @@ select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22"),
select sec_to_time(9001.1), time_to_sec('15:12:22.123456'), time_to_sec(15.5566778899);
select sec_to_time(time_to_sec('-838:59:59'));
select sec_to_time('9001.1'), sec_to_time('1234567890123.123');
select sec_to_time(-9001.1), sec_to_time(-9001.1) / 1,
sec_to_time(-9001.1) / 1e0, sec_to_time(-9001) div 1;
--replace_result e+042 e+42
select sec_to_time(90011e-1), sec_to_time(1234567890123e30);
select sec_to_time(1234567890123), sec_to_time('99999999999999999999999999999');

View file

@ -1370,7 +1370,8 @@ longlong Item_temporal_func::val_int()
MYSQL_TIME ltime;
if (get_date(&ltime, TIME_FUZZY_DATE))
return 0;
return (longlong)TIME_to_ulonglong(&ltime);
longlong v= TIME_to_ulonglong(&ltime);
return ltime.neg ? -v : v;
}