summaryrefslogtreecommitdiff
path: root/sql/item_timefunc.cc
diff options
context:
space:
mode:
authorunknown <ramil/ram@mysql.com/myoffice.izhnet.ru>2006-10-17 16:30:49 +0500
committerunknown <ramil/ram@mysql.com/myoffice.izhnet.ru>2006-10-17 16:30:49 +0500
commit4c02f402d48b64c8044832f45845db73b3c9bd9f (patch)
tree9cfa840cb4c5a125046f9f1f74defd0342a3787c /sql/item_timefunc.cc
parent0ace2b44ba0410e901d18c5315837647c8436c1d (diff)
downloadmariadb-git-4c02f402d48b64c8044832f45845db73b3c9bd9f.tar.gz
Fix for bug #22229: Bug in DATE_ADD()
From the manual: date arithmetic operations require complete dates and do not work with incomplete dates such as '2006-07-00' or badly malformed dates. mysql-test/r/func_time.result: Fix for bug #22229: Bug in DATE_ADD() - test result. mysql-test/t/func_time.test: Fix for bug #22229: Bug in DATE_ADD() - test case. sql/item_timefunc.cc: Fix for bug #22229: Bug in DATE_ADD() - Item_func_str_to_date::get_date() should return NULL if TIME_NO_ZERO_DATE flag is set and year||month||day is 0.
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r--sql/item_timefunc.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 48d6458bd88..5b6f238b85f 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -3193,7 +3193,9 @@ bool Item_func_str_to_date::get_date(TIME *ltime, uint fuzzy_date)
date_time_format.format.str= (char*) format->ptr();
date_time_format.format.length= format->length();
if (extract_date_time(&date_time_format, val->ptr(), val->length(),
- ltime, cached_timestamp_type, 0, "datetime"))
+ ltime, cached_timestamp_type, 0, "datetime") ||
+ ((fuzzy_date & TIME_NO_ZERO_DATE) &&
+ (ltime->year == 0 || ltime->month == 0 || ltime->day == 0)))
goto null_date;
if (cached_timestamp_type == MYSQL_TIMESTAMP_TIME && ltime->day)
{