diff options
author | Alexander Barkov <bar@mariadb.org> | 2013-06-18 13:14:46 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2013-06-18 13:14:46 +0400 |
commit | 7cc77106792a2683f85e57f501c3a3be066a02a5 (patch) | |
tree | d59bb3c68d0ccbca49be6c1e9136535906c14473 /sql/item_timefunc.cc | |
parent | be06b886a255e6d899341f55808172a219a85799 (diff) | |
parent | 4085836acf1b70738efe6d33a51e8d2ab9deb63f (diff) | |
download | mariadb-git-7cc77106792a2683f85e57f501c3a3be066a02a5.tar.gz |
Merging MDEV-4635 from 5.3.
Also, fixing a bug in STR_TO_DATE(). It erroneously returned
error in strict mode for dates like '0000-01-01'
(zero year, but non-zero month and day).
According to the manual:
- NO_ZERO_DATE disallows 0000-00-00 (all date parts are zeros)
- NO_ZERO_IN_DATE disallows zero month (YYYY-00-DD) or day (YYYY-MM-00).
0000-01-01 is a valid date, even in strict mode.
modified:
mysql-test/r/func_time.result
mysql-test/r/strict.result
mysql-test/t/func_time.test
mysql-test/t/strict.test
sql/item_timefunc.cc
sql/sql_time.h
pending merges:
Alexander Barkov 2013-06-17 MDEV-4635 Crash in UNIX_TIMESTAMP(STR_TO_DAT...
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r-- | sql/item_timefunc.cc | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 69a6dac5381..8f818b60ae7 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -415,8 +415,8 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, l_time->minute > 59 || l_time->second > 59) goto err; - if ((fuzzy_date & TIME_NO_ZERO_DATE) && - (l_time->year == 0 || l_time->month == 0 || l_time->day == 0)) + int was_cut; + if (check_date(l_time, fuzzy_date | TIME_INVALID_DATES, &was_cut)) goto err; if (val != val_end) @@ -866,7 +866,6 @@ longlong Item_func_to_days::val_int_endpoint(bool left_endp, bool *incl_endp) res=(longlong) calc_daynr(ltime.year,ltime.month,ltime.day); /* Set to NULL if invalid date, but keep the value */ null_value= check_date(<ime, - (ltime.year || ltime.month || ltime.day), (TIME_NO_ZERO_IN_DATE | TIME_NO_ZERO_DATE), &dummy); if (null_value) @@ -1190,7 +1189,7 @@ bool Item_func_unix_timestamp::get_timestamp_value(my_time_t *seconds, } MYSQL_TIME ltime; - if (get_arg0_date(<ime, 0)) + if (get_arg0_date(<ime, TIME_NO_ZERO_IN_DATE)) return 1; uint error_code; @@ -2432,8 +2431,7 @@ bool Item_date_typecast::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) ltime->time_type= MYSQL_TIMESTAMP_DATE; int unused; - if (check_date(ltime, ltime->year || ltime->month || ltime->day, - fuzzy_date, &unused)) + if (check_date(ltime, fuzzy_date, &unused)) { ErrConvTime str(ltime); make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, |