fix for double or decimal to datetime conversion

This commit is contained in:
Sergei Golubchik 2011-05-26 18:11:26 +02:00
commit 34c9428871
3 changed files with 7 additions and 1 deletions

View file

@ -87,6 +87,11 @@ Warning 1292 Truncated incorrect time value: '-3020399.9999999'
select 20010101000203.000000004 + interval 1 day;
20010101000203.000000004 + interval 1 day
2001-01-02 00:02:03.000000
Warnings:
Warning 1292 Truncated incorrect datetime value: '20010101000203.000000004'
select 20010101000203.4 + interval 1 day;
20010101000203.4 + interval 1 day
2001-01-02 00:02:03.4
set @a=cast('2011-01-02 12:13:14' as datetime);
select @a + interval 1 minute;
@a + interval 1 minute

View file

@ -33,6 +33,7 @@ drop table t1;
select sec_to_time(3020399.99999), sec_to_time(3020399.999999), sec_to_time(3020399.9999999);
select sec_to_time(-3020399.99999), sec_to_time(-3020399.999999), sec_to_time(-3020399.9999999);
select 20010101000203.000000004 + interval 1 day;
select 20010101000203.4 + interval 1 day;
#
# precision of expressions
#

View file

@ -984,7 +984,7 @@ bool Item::get_date(MYSQL_TIME *ltime,uint fuzzydate)
{
if (field_type() == MYSQL_TYPE_TIME)
fuzzydate|= TIME_TIME_ONLY;
if (result_type() == STRING_RESULT || fuzzydate & TIME_TIME_ONLY)
if (result_type() != INT_RESULT || fuzzydate & TIME_TIME_ONLY)
{
char buff[40];
String tmp(buff,sizeof(buff), &my_charset_bin),*res;