summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2007-05-30 23:28:14 +0400
committerunknown <evgen@moonbone.local>2007-05-30 23:28:14 +0400
commita7cf92bbce08d6e2f2ea670c4e02a649f49106d8 (patch)
tree34b7232dca92925081a7d7669d7ff2e60873aa4e /sql/field.cc
parentb79b49099310fdc068d7ddadcb7a168b9aaa674c (diff)
downloadmariadb-git-a7cf92bbce08d6e2f2ea670c4e02a649f49106d8.tar.gz
Bug#28729: Field_enum wrongly reported an error while storing an empty string.
ENUM fields internally store their values as integers and may use integer values as indexes to their values. Invalid values are mapped to zero value. When storing an empty string the ENUM field fails to find an appropriate value and tries to convert the provided string to integer. The conversion also fails and error is returned even if the thd->count_cuted_fields is set to CHECK_FIELD_IGNORE. This makes the range optimizer wrongly decide that an impossible range is present. Now the Field_enum::store() returns error while storing an empty string only if the thd->count_cuted_fields isn't set to CHECK_FIELD_IGNORE. sql/field.cc: Bug#28729: Field_enum wrongly reported an error while storing an empty string. Now the Field_enum::store() returns error while storing an empty string only if the thd->count_cuted_fields isn't set to CHECK_FIELD_IGNORE. mysql-test/r/type_enum.result: Added a test case for the bug#28729: Field_enum wrongly reported an error while storing an empty string. mysql-test/t/type_enum.test: Added a test case for the bug#28729: Field_enum wrongly reported an error while storing an empty string.
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 8186659ae89..8ff615ee798 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -7643,6 +7643,8 @@ int Field_enum::store(const char *from,uint length,CHARSET_INFO *cs)
tmp=0;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
}
+ if (!table->in_use->count_cuted_fields)
+ err= 0;
}
else
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);