diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-12-18 09:15:41 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-12-18 09:15:41 +0200 |
commit | 45531949ae115f2ba7b9450cc2386653483211ba (patch) | |
tree | 22809f3919c711d5030d2d0e55be969a7bc67e84 /sql/sql_time.cc | |
parent | 36b7f8f4b0e46e06cfcc29c221430a5b998e3b3f (diff) | |
parent | ed13a0d221256028299df4167280e97860ba2edc (diff) | |
download | mariadb-git-45531949ae115f2ba7b9450cc2386653483211ba.tar.gz |
Merge 10.2 into 10.3
Diffstat (limited to 'sql/sql_time.cc')
-rw-r--r-- | sql/sql_time.cc | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/sql/sql_time.cc b/sql/sql_time.cc index 35ef1e50c36..739a95ce9c8 100644 --- a/sql/sql_time.cc +++ b/sql/sql_time.cc @@ -297,7 +297,7 @@ check_date_with_warn(const MYSQL_TIME *ltime, ulonglong fuzzy_date, { ErrConvTime str(ltime); make_truncated_value_warning(current_thd, Sql_condition::WARN_LEVEL_WARN, - &str, ts_type, 0); + &str, ts_type, 0, 0); return true; } return false; @@ -314,7 +314,7 @@ adjust_time_range_with_warn(MYSQL_TIME *ltime, uint dec) return true; if (warnings) make_truncated_value_warning(current_thd, Sql_condition::WARN_LEVEL_WARN, - &str, MYSQL_TIMESTAMP_TIME, NullS); + &str, MYSQL_TIMESTAMP_TIME, 0, NullS); return false; } @@ -403,7 +403,7 @@ str_to_datetime_with_warn(CHARSET_INFO *cs, ret_val ? Sql_condition::WARN_LEVEL_WARN : Sql_condition::time_warn_level(status.warnings), str, length, flags & TIME_TIME_ONLY ? - MYSQL_TIMESTAMP_TIME : l_time->time_type, NullS); + MYSQL_TIMESTAMP_TIME : l_time->time_type, 0, NullS); DBUG_EXECUTE_IF("str_to_datetime_warn", push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, ER_YES, str);); @@ -427,7 +427,7 @@ str_to_datetime_with_warn(CHARSET_INFO *cs, static bool number_to_time_with_warn(bool neg, ulonglong nr, ulong sec_part, MYSQL_TIME *ltime, ulonglong fuzzydate, const ErrConv *str, - const char *field_name) + const TABLE_SHARE *s, const char *field_name) { int was_cut; longlong res; @@ -460,14 +460,15 @@ static bool number_to_time_with_warn(bool neg, ulonglong nr, ulong sec_part, make_truncated_value_warning(current_thd, Sql_condition::WARN_LEVEL_WARN, str, res < 0 ? MYSQL_TIMESTAMP_ERROR : ts_type, - field_name); + s, field_name); } return res < 0; } bool double_to_datetime_with_warn(double value, MYSQL_TIME *ltime, - ulonglong fuzzydate, const char *field_name) + ulonglong fuzzydate, + const TABLE_SHARE *s, const char *field_name) { const ErrConvDouble str(value); bool neg= value < 0; @@ -481,28 +482,30 @@ bool double_to_datetime_with_warn(double value, MYSQL_TIME *ltime, longlong nr= static_cast<ulonglong>(floor(value)); uint sec_part= static_cast<ulong>((value - floor(value))*TIME_SECOND_PART_FACTOR); return number_to_time_with_warn(neg, nr, sec_part, ltime, fuzzydate, &str, - field_name); + s, field_name); } bool decimal_to_datetime_with_warn(const my_decimal *value, MYSQL_TIME *ltime, - ulonglong fuzzydate, const char *field_name) + ulonglong fuzzydate, + const TABLE_SHARE *s, const char *field_name) { const ErrConvDecimal str(value); ulonglong nr; ulong sec_part; bool neg= my_decimal2seconds(value, &nr, &sec_part); return number_to_time_with_warn(neg, nr, sec_part, ltime, fuzzydate, &str, - field_name); + s, field_name); } bool int_to_datetime_with_warn(bool neg, ulonglong value, MYSQL_TIME *ltime, - ulonglong fuzzydate, const char *field_name) + ulonglong fuzzydate, + const TABLE_SHARE *s, const char *field_name) { const ErrConvInteger str(neg ? - (longlong) value : (longlong) value, !neg); return number_to_time_with_warn(neg, value, 0, ltime, - fuzzydate, &str, field_name); + fuzzydate, &str, s, field_name); } @@ -930,7 +933,7 @@ void make_truncated_value_warning(THD *thd, Sql_condition::enum_warning_level level, const ErrConv *sval, timestamp_type time_type, - const char *field_name) + const TABLE_SHARE *s, const char *field_name) { char warn_buff[MYSQL_ERRMSG_SIZE]; const char *type_str; @@ -949,10 +952,21 @@ void make_truncated_value_warning(THD *thd, break; } if (field_name) + { + const char *db_name= s->db.str; + const char *table_name= s->error_table_name(); + + if (!db_name) + db_name= ""; + if (!table_name) + table_name= ""; + cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff), ER_THD(thd, ER_TRUNCATED_WRONG_VALUE_FOR_FIELD), - type_str, sval->ptr(), field_name, + type_str, sval->ptr(), + db_name, table_name, field_name, (ulong) thd->get_stmt_da()->current_row_for_warning()); + } else { if (time_type > MYSQL_TIMESTAMP_ERROR) @@ -1279,7 +1293,7 @@ make_date_with_warn(MYSQL_TIME *ltime, ulonglong fuzzy_date, /* e.g. negative time */ ErrConvTime str(ltime); make_truncated_value_warning(current_thd, Sql_condition::WARN_LEVEL_WARN, - &str, ts_type, 0); + &str, ts_type, 0, 0); return true; } if ((ltime->time_type= ts_type) == MYSQL_TIMESTAMP_DATE) @@ -1443,7 +1457,7 @@ time_to_datetime_with_warn(THD *thd, { ErrConvTime str(from); make_truncated_value_warning(thd, Sql_condition::WARN_LEVEL_WARN, - &str, MYSQL_TIMESTAMP_DATETIME, 0); + &str, MYSQL_TIMESTAMP_DATETIME, 0, 0); return true; } return false; |