Commit 5aa793f7 authored by unknown's avatar unknown

backport for #10568: Function 'LAST_DAY(date)' does not return NULL for invalid argument.

parent 77dc5c42
...@@ -611,3 +611,18 @@ SELECT count(*) FROM t1 WHERE d>FROM_DAYS(TO_DAYS(@TMP)) AND d<=FROM_DAYS(TO_DAY ...@@ -611,3 +611,18 @@ SELECT count(*) FROM t1 WHERE d>FROM_DAYS(TO_DAYS(@TMP)) AND d<=FROM_DAYS(TO_DAY
count(*) count(*)
3 3
DROP TABLE t1; 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'
...@@ -307,3 +307,10 @@ INSERT INTO t1 VALUES (NOW()); ...@@ -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); SELECT count(*) FROM t1 WHERE d>FROM_DAYS(TO_DAYS(@TMP)) AND d<=FROM_DAYS(TO_DAYS(@TMP)+1);
DROP TABLE t1; DROP TABLE t1;
#
# Bug #10568
#
select last_day('2005-00-00');
select last_day('2005-00-01');
select last_day('2005-01-00');
...@@ -2817,7 +2817,7 @@ String *Item_func_str_to_date::val_str(String *str) ...@@ -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) 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; return 1;
uint month_idx= ltime->month-1; uint month_idx= ltime->month-1;
ltime->day= days_in_month[month_idx]; ltime->day= days_in_month[month_idx];
......
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