summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authorunknown <ramil@mysql.com>2005-03-10 17:08:45 +0400
committerunknown <ramil@mysql.com>2005-03-10 17:08:45 +0400
commit1690bab938e46f5a8c018c05c17c88d4076b3b8b (patch)
tree4ff40f4239fbd787fa231b72d868fed42d9562e3 /sql/field.cc
parent83fa3560bc13734b2d92c84064d836fd2e05bc8d (diff)
downloadmariadb-git-1690bab938e46f5a8c018c05c17c88d4076b3b8b.tar.gz
a fix (bug #9029 Traditional: Wrong SQLSTATE returned for string truncation).
sql/field.cc: a fix (bug #9029 Traditional: Wrong SQLSTATE returned for string truncation). Should issue ER_DATA_TOO_LONG in 'traditional' mode when data truncated.
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc20
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, &not_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;
}