diff options
author | unknown <ramil@mysql.com> | 2005-06-01 17:09:46 +0500 |
---|---|---|
committer | unknown <ramil@mysql.com> | 2005-06-01 17:09:46 +0500 |
commit | 44af4dbdf12f32ee5cb2be6d747c02b32912bf06 (patch) | |
tree | e65fd2d7d6b7221768c75e55daf08aeae3361b68 | |
parent | 3f7b0f708e046d0a5ffe0ef96c1f52471be7b397 (diff) | |
download | mariadb-git-44af4dbdf12f32ee5cb2be6d747c02b32912bf06.tar.gz |
A fix (bug #10568: Function 'LAST_DAY(date)' does not return NULL for invalid argument).
sql/item_timefunc.cc:
A fix (bug #10568: Function 'LAST_DAY(date)' does not return NULL for invalid argument).
Return error for partial dates as well.
-rw-r--r-- | mysql-test/r/func_time.result | 15 | ||||
-rw-r--r-- | mysql-test/t/func_time.test | 8 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 2 |
3 files changed, 24 insertions, 1 deletions
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 4293ef5bd85..58f9271dce9 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -688,3 +688,18 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: Note 1003 select timestamp_diff(WEEK,_latin1'2001-02-01',_latin1'2001-05-01') AS `a1`,timestamp_diff(SECOND_FRAC,_latin1'2001-02-01 12:59:59.120000',_latin1'2001-05-01 12:58:58.119999') AS `a2` +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 80ddb205110..b44215c97b1 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -336,3 +336,11 @@ DROP TABLE t1; explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1, timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2; + +# +# 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 3b6ca48fadd..16882e56d88 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -3015,7 +3015,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]; |