summaryrefslogtreecommitdiff
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
commit3a35610d9714a3ef47600504f04daa4cba3b4d35 (patch)
tree34b7232dca92925081a7d7669d7ff2e60873aa4e
parentb858bd2da8f87175e09ad41ac2cceba0372af3ba (diff)
downloadmariadb-git-3a35610d9714a3ef47600504f04daa4cba3b4d35.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.
-rw-r--r--mysql-test/r/type_enum.result7
-rw-r--r--mysql-test/t/type_enum.test8
-rw-r--r--sql/field.cc2
3 files changed, 17 insertions, 0 deletions
diff --git a/mysql-test/r/type_enum.result b/mysql-test/r/type_enum.result
index 2683201e25e..0b420c42cc7 100644
--- a/mysql-test/r/type_enum.result
+++ b/mysql-test/r/type_enum.result
@@ -1779,3 +1779,10 @@ create table t1(exhausting_charset enum('ABCDEFGHIJKLMNOPQRSTUVWXYZ','
 !"','#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~','xx\','yy\','zz'));
ERROR 42000: Field separator argument is not what is expected; check the manual
End of 4.1 tests
+create table t1(f1 set('a','b'), index(f1));
+insert into t1 values(''),(''),('a'),('b');
+select * from t1 where f1='';
+f1
+
+
+drop table t1;
diff --git a/mysql-test/t/type_enum.test b/mysql-test/t/type_enum.test
index 4b3429d9ea0..45da469cf2d 100644
--- a/mysql-test/t/type_enum.test
+++ b/mysql-test/t/type_enum.test
@@ -157,3 +157,11 @@ create table t1(exhausting_charset enum('ABCDEFGHIJKLMNOPQRSTUVWXYZ','
 !"','#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~','xx\','yy\','zz'));
--echo End of 4.1 tests
+
+#
+# Bug#28729: Field_enum wrongly reported an error while storing an empty string.
+#
+create table t1(f1 set('a','b'), index(f1));
+insert into t1 values(''),(''),('a'),('b');
+select * from t1 where f1='';
+drop table t1;
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);