diff options
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/sql/field.cc b/sql/field.cc index fd4d83a8b1c..a73c24d8f0d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5332,7 +5332,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs) uint32 not_used, copy_length; char buff[STRING_BUFFER_USUAL_SIZE]; String tmpstr(buff,sizeof(buff), &my_charset_bin); - enum MYSQL_ERROR::enum_warning_level level= MYSQL_ERROR::WARN_LEVEL_WARN; + bool lost_only_spaces= FALSE; /* Convert character set if necessary */ if (String::needs_conversion(length, cs, field_charset, ¬_used)) @@ -5370,11 +5370,18 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs) then don't reset level to NOTE. */ if (from == end && !error) - level= MYSQL_ERROR::WARN_LEVEL_NOTE; + lost_only_spaces= TRUE; error= 1; } if (error) - set_warning(level, WARN_DATA_TRUNCATED, 1); + { + if (lost_only_spaces) + set_warning(MYSQL_ERROR::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1); + else if (table->in_use->abort_on_warning) + set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1); + else + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + } return error; } @@ -5971,7 +5978,12 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) bmove(ptr+packlength,(char*) &from,sizeof(char*)); } if (error) - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + { + if (table->in_use->abort_on_warning) + set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1); + else + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + } return 0; } |