diff options
author | ramil/ram@mysql.com/myoffice.izhnet.ru <> | 2006-12-04 17:06:25 +0400 |
---|---|---|
committer | ramil/ram@mysql.com/myoffice.izhnet.ru <> | 2006-12-04 17:06:25 +0400 |
commit | c99556d5d44cf28524e442ed13e520fef901e017 (patch) | |
tree | 3e658877ab80c379c8ea6e5684dd70fee52186a4 | |
parent | c2aca91b7fde5a2127e6187dbefd6ad89df45d21 (diff) | |
download | mariadb-git-c99556d5d44cf28524e442ed13e520fef901e017.tar.gz |
fix for bug #23938: ISNULL on DATE AND CAST AS DATE returns false for null values
Set null_value in case of wrong data.
-rw-r--r-- | mysql-test/r/cast.result | 4 | ||||
-rw-r--r-- | mysql-test/t/cast.test | 8 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 3 |
3 files changed, 14 insertions, 1 deletions
diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index 101b9ac3f7e..23c38bb792c 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -278,3 +278,7 @@ double_val cast_val -1e+30 -9223372036854775808 1e+30 9223372036854775807 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 diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index b214cef10fa..7e8ef031e6b 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -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; 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 diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index c1bca7afc60..8687ccc5f10 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2507,7 +2507,10 @@ longlong Item_date_typecast::val_int() DBUG_ASSERT(fixed == 1); TIME ltime; if (args[0]->get_date(<ime, TIME_FUZZY_DATE)) + { + null_value= 1; return 0; + } return (longlong) (ltime.year * 10000L + ltime.month * 100 + ltime.day); } |