diff options
author | Alexander Barkov <bar@mnogosearch.org> | 2014-01-27 15:05:23 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mnogosearch.org> | 2014-01-27 15:05:23 +0400 |
commit | 0ad8eaeb56a049df2947516d3d7ec49301d8d09d (patch) | |
tree | 151f9c4560a15f39d039061a4877e8775b6dc792 /sql | |
parent | ba3d0b173a5610905b31b78367c50700e8032b0b (diff) | |
parent | 7ea9d1e692c69c8715d98a9dbc44289d47a65447 (diff) | |
download | mariadb-git-0ad8eaeb56a049df2947516d3d7ec49301d8d09d.tar.gz |
Merge 5.3 -> 5.5
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_func.cc | 12 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 21 | ||||
-rw-r--r-- | sql/sql_time.cc | 14 | ||||
-rw-r--r-- | sql/sql_time.h | 3 |
4 files changed, 27 insertions, 23 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index fe746a1cadb..453494b374f 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2947,11 +2947,6 @@ bool Item_func_min_max::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) } unpack_time(min_max, ltime); - if (!(fuzzy_date & TIME_TIME_ONLY) && - ((null_value= check_date_with_warn(ltime, fuzzy_date, - MYSQL_TIMESTAMP_ERROR)))) - return true; - if (compare_as_dates->field_type() == MYSQL_TYPE_DATE) { ltime->time_type= MYSQL_TIMESTAMP_DATE; @@ -2962,8 +2957,15 @@ bool Item_func_min_max::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) ltime->time_type= MYSQL_TIMESTAMP_TIME; ltime->hour+= (ltime->month * 32 + ltime->day) * 24; ltime->month= ltime->day= 0; + if (adjust_time_range_with_warn(ltime, + min(decimals, TIME_SECOND_PART_DIGITS))) + return (null_value= true); } + if (!(fuzzy_date & TIME_TIME_ONLY) && + ((null_value= check_date_with_warn(ltime, fuzzy_date, + MYSQL_TIMESTAMP_ERROR)))) + return true; return (null_value= 0); } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 4b10675c48d..9758d86213d 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2574,7 +2574,7 @@ bool Item_func_add_time::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) bool is_time= 0; long days, microseconds; longlong seconds; - int l_sign= sign, was_cut= 0; + int l_sign= sign; if (is_date) // TIMESTAMP function { @@ -2625,16 +2625,7 @@ bool Item_func_add_time::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) } ltime->hour+= days*24; - - MYSQL_TIME copy= *ltime; - ErrConvTime str(©); - - check_time_range(ltime, decimals, &was_cut); - if (was_cut) - make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, - &str, MYSQL_TIMESTAMP_TIME, NullS); - - return (null_value= 0); + return (null_value= adjust_time_range_with_warn(ltime, decimals)); } @@ -2672,7 +2663,7 @@ bool Item_func_timediff::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) DBUG_ASSERT(fixed == 1); longlong seconds; long microseconds; - int l_sign= 1, was_cut= 0; + int l_sign= 1; MYSQL_TIME l_time1,l_time2,l_time3; ErrConvTime str(&l_time3); @@ -2716,12 +2707,8 @@ bool Item_func_timediff::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) return (null_value= 1); *ltime= l_time3; - check_time_range(ltime, decimals, &was_cut); + return (null_value= adjust_time_range_with_warn(ltime, decimals)); - if (was_cut) - make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, - &str, MYSQL_TIMESTAMP_TIME, NullS); - return (null_value= 0); } /** diff --git a/sql/sql_time.cc b/sql/sql_time.cc index 2c89237c2d2..efcde017671 100644 --- a/sql/sql_time.cc +++ b/sql/sql_time.cc @@ -230,6 +230,20 @@ check_date_with_warn(const MYSQL_TIME *ltime, ulonglong fuzzy_date, } +bool +adjust_time_range_with_warn(MYSQL_TIME *ltime, uint dec) +{ + MYSQL_TIME copy= *ltime; + ErrConvTime str(©); + int warnings= 0; + if (check_time_range(ltime, dec, &warnings)) + return true; + if (warnings) + make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + &str, MYSQL_TIMESTAMP_TIME, NullS); + return false; +} + /* Convert a string to 8-bit representation, for use in str_to_time/str_to_date/str_to_date. diff --git a/sql/sql_time.h b/sql/sql_time.h index ab8f0e0b962..f9092769749 100644 --- a/sql/sql_time.h +++ b/sql/sql_time.h @@ -124,5 +124,6 @@ check_date(const MYSQL_TIME *ltime, ulonglong flags, int *was_cut) } bool check_date_with_warn(const MYSQL_TIME *ltime, ulonglong fuzzy_date, timestamp_type ts_type); - +bool adjust_time_range_with_warn(MYSQL_TIME *ltime, uint dec); + #endif /* SQL_TIME_INCLUDED */ |