diff options
-rw-r--r-- | mysql-test/r/func_time.result | 3 | ||||
-rw-r--r-- | mysql-test/t/func_time.test | 6 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 4 |
3 files changed, 12 insertions, 1 deletions
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 25c910a711a..9b843858d3f 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -1076,3 +1076,6 @@ fmtddate field2 Sep-4 12:00AM abcd DROP TABLE testBug8868; SET NAMES DEFAULT; +select str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE; +str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE +NULL diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 2b3fb86829d..1692da3cefe 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -620,3 +620,9 @@ SELECT DATE_FORMAT(field1,'%b-%e %l:%i%p') as fmtddate, field2 FROM testBug8868; DROP TABLE testBug8868; SET NAMES DEFAULT; + +# +# Bug #22229: bug in DATE_ADD() +# + +select str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE; 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) { |