summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/cast.result4
-rw-r--r--mysql-test/t/cast.test8
-rw-r--r--sql/item_timefunc.cc3
3 files changed, 14 insertions, 1 deletions
diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result
index a07ca21652b..d8e50128902 100644
--- a/mysql-test/r/cast.result
+++ b/mysql-test/r/cast.result
@@ -348,6 +348,10 @@ Warnings:
Warning 1292 Truncated incorrect INTEGER value: '-1e+30'
Warning 1292 Truncated incorrect INTEGER value: '1e+30'
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
select cast('1.2' as decimal(3,2));
cast('1.2' as decimal(3,2))
1.20
diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test
index ecc92ed01d1..502c5781f1f 100644
--- a/mysql-test/t/cast.test
+++ b/mysql-test/t/cast.test
@@ -176,7 +176,13 @@ 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
#decimal-related additions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index a776d8a5ff7..7d9215b0fb3 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -2667,7 +2667,10 @@ longlong Item_date_typecast::val_int()
DBUG_ASSERT(fixed == 1);
TIME ltime;
if (args[0]->get_date(&ltime, TIME_FUZZY_DATE))
+ {
+ null_value= 1;
return 0;
+ }
return (longlong) (ltime.year * 10000L + ltime.month * 100 + ltime.day);
}