summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorramil@mysql.com <>2005-06-24 14:04:48 +0500
committerramil@mysql.com <>2005-06-24 14:04:48 +0500
commitb0e6db14c54a621bfcfafb3a65d87124e43c47aa (patch)
tree19613a2227e058872e7909d41f5cb75e2be435cf
parent66330a9d59d57c1454a8361cb01df3f88ed6d5e8 (diff)
downloadmariadb-git-b0e6db14c54a621bfcfafb3a65d87124e43c47aa.tar.gz
backport for #10568: Function 'LAST_DAY(date)' does not return NULL for invalid argument.
-rw-r--r--mysql-test/r/func_time.result15
-rw-r--r--mysql-test/t/func_time.test7
-rw-r--r--sql/item_timefunc.cc2
3 files changed, 23 insertions, 1 deletions
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index 4dd00ab74a1..fc872285acb 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -611,3 +611,18 @@ SELECT count(*) FROM t1 WHERE d>FROM_DAYS(TO_DAYS(@TMP)) AND d<=FROM_DAYS(TO_DAY
count(*)
3
DROP TABLE t1;
+select last_day('2005-00-00');
+last_day('2005-00-00')
+NULL
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '2005-00-00'
+select last_day('2005-00-01');
+last_day('2005-00-01')
+NULL
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '2005-00-01'
+select last_day('2005-01-00');
+last_day('2005-01-00')
+NULL
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '2005-01-00'
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index 0f495ef891d..9e2703da110 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -307,3 +307,10 @@ INSERT INTO t1 VALUES (NOW());
SELECT count(*) FROM t1 WHERE d>FROM_DAYS(TO_DAYS(@TMP)) AND d<=FROM_DAYS(TO_DAYS(@TMP)+1);
DROP TABLE t1;
+#
+# Bug #10568
+#
+
+select last_day('2005-00-00');
+select last_day('2005-00-01');
+select last_day('2005-01-00');
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index a3cf69035f3..0e1a8766e8f 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -2817,7 +2817,7 @@ String *Item_func_str_to_date::val_str(String *str)
bool Item_func_last_day::get_date(TIME *ltime, uint fuzzy_date)
{
- if (get_arg0_date(ltime,fuzzy_date))
+ if (get_arg0_date(ltime, fuzzy_date & ~TIME_FUZZY_DATE))
return 1;
uint month_idx= ltime->month-1;
ltime->day= days_in_month[month_idx];