Commit 665004c8 authored by unknown's avatar unknown

fix for bug #23938: ISNULL on DATE AND CAST AS DATE returns false for null values

Set null_value in case of wrong data.


mysql-test/r/cast.result:
  fix for bug #23938: ISNULL on DATE AND CAST AS DATE returns false for null values
    - test result.
mysql-test/t/cast.test:
  fix for bug #23938: ISNULL on DATE AND CAST AS DATE returns false for null values
    - test case.
sql/item_timefunc.cc:
  fix for bug #23938: ISNULL on DATE AND CAST AS DATE returns false for null values
    - set null_value in case of error.
parent 870b2e0a
...@@ -278,3 +278,7 @@ double_val cast_val ...@@ -278,3 +278,7 @@ double_val cast_val
-1e+30 -9223372036854775808 -1e+30 -9223372036854775808
1e+30 9223372036854775807 1e+30 9223372036854775807
DROP TABLE t1; DROP TABLE t1;
select isnull(date(NULL)), isnull(cast(NULL as DATE));
isnull(date(NULL)) isnull(cast(NULL as DATE))
1 1
End of 4.1 tests
...@@ -167,4 +167,10 @@ INSERT INTO t1 SET f1 = +1.0e+30 ; ...@@ -167,4 +167,10 @@ INSERT INTO t1 SET f1 = +1.0e+30 ;
SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1; SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1;
DROP TABLE t1; DROP TABLE t1;
# End of 4.1 tests #
# Bug #23938: cast(NULL as DATE)
#
select isnull(date(NULL)), isnull(cast(NULL as DATE));
--echo End of 4.1 tests
...@@ -2507,7 +2507,10 @@ longlong Item_date_typecast::val_int() ...@@ -2507,7 +2507,10 @@ longlong Item_date_typecast::val_int()
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
TIME ltime; TIME ltime;
if (args[0]->get_date(&ltime, TIME_FUZZY_DATE)) if (args[0]->get_date(&ltime, TIME_FUZZY_DATE))
{
null_value= 1;
return 0; return 0;
}
return (longlong) (ltime.year * 10000L + ltime.month * 100 + ltime.day); return (longlong) (ltime.year * 10000L + ltime.month * 100 + ltime.day);
} }
......
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