summaryrefslogtreecommitdiff
path: root/sql/sql_time.cc
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2018-12-16 02:21:41 +0400
committerAlexey Botchkov <holyfoot@askmonty.org>2018-12-16 02:21:41 +0400
commitc4ab352b670618bb478138cfbf3ed195317b3ccb (patch)
tree3dc86ad7d504865798871ae869ab5bac40e804b2 /sql/sql_time.cc
parent0a2edddbf4f4737863edf51970cbbaa91e72e11f (diff)
downloadmariadb-git-c4ab352b670618bb478138cfbf3ed195317b3ccb.tar.gz
MDEV-14576 Include full name of object in message about incorrect value for column.
The error message modified. Then the TABLE_SHARE::error_table_name() implementation taken from 10.3, to be used as a name of the table in this message.
Diffstat (limited to 'sql/sql_time.cc')
-rw-r--r--sql/sql_time.cc44
1 files changed, 29 insertions, 15 deletions
diff --git a/sql/sql_time.cc b/sql/sql_time.cc
index cdb9f4e5b79..53e380f59c8 100644
--- a/sql/sql_time.cc
+++ b/sql/sql_time.cc
@@ -223,7 +223,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;
@@ -240,7 +240,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;
}
@@ -329,7 +329,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););
@@ -353,7 +353,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;
@@ -387,14 +387,15 @@ static bool number_to_time_with_warn(bool neg, ulonglong nr, ulong sec_part,
Sql_condition::WARN_LEVEL_WARN, str,
res < 0 ? MYSQL_TIMESTAMP_ERROR
: mysql_type_to_time_type(f_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;
@@ -408,28 +409,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);
}
@@ -856,7 +859,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;
@@ -875,10 +878,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)
@@ -1205,7 +1219,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)
@@ -1369,7 +1383,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;