Below is the list of changes that have just been committed into a local
4.1 repository of uchum. When uchum does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-06-27 03:38:14+05:00, gshchepa@stripped +3 -0
Fixed bug #29251.
Sometimes special 0 ENUM values was ALTERed to normal
empty string ENUM values.
Special 0 ENUM value has the same string representation
as normal ENUM value defined as '' (empty string).
The do_field_string function was used to convert
ENUM data at an ALTER TABLE request, but this
function doesn't care about numerical "indices" of
ENUM values, i.e. do_field_string doesn't distinguish
a special 0 value from an empty string value.
A new copy function called do_field_enum has been added to
copy special 0 ENUM values without conversion to an empty
string.
mysql-test/r/type_enum.result@stripped, 2007-06-27 03:38:10+05:00, gshchepa@stripped +23 -0
Updated test case for bug #29251.
mysql-test/t/type_enum.test@stripped, 2007-06-27 03:38:09+05:00, gshchepa@stripped +17 -0
Updated test case for bug #29251.
sql/field_conv.cc@stripped, 2007-06-27 03:38:07+05:00, gshchepa@stripped +16 -1
Fixed bug #29251.
The Copy_field::get_copy_func method has been modified to
return a pointer to the do_field_enum function if a conversion
between two columns of incompatible enum types is required.
The do_field_enum function has been added for the correct
conversion of special 0 enum values.
diff -Nrup a/mysql-test/r/type_enum.result b/mysql-test/r/type_enum.result
--- a/mysql-test/r/type_enum.result 2007-02-12 17:31:43 +04:00
+++ b/mysql-test/r/type_enum.result 2007-06-27 03:38:10 +05:00
@@ -1778,4 +1778,27 @@ drop table t1;
create table t1(exhausting_charset enum('ABCDEFGHIJKLMNOPQRSTUVWXYZ','
ERROR 42000: Field separator argument is not what is expected; check the manual
+CREATE TABLE t1 (
+id INT AUTO_INCREMENT PRIMARY KEY,
+c1 ENUM('a', '', 'b')
+);
+INSERT INTO t1 (c1) VALUES (0), ('a'), (''), ('b');
+Warnings:
+Warning 1265 Data truncated for column 'c1' at row 1
+SELECT id, c1 + 0, c1 FROM t1;
+id c1 + 0 c1
+1 0
+2 1 a
+3 2
+4 3 b
+ALTER TABLE t1 CHANGE c1 c1 ENUM('a', '') NOT NULL;
+Warnings:
+Warning 1265 Data truncated for column 'c1' at row 4
+SELECT id, c1 + 0, c1 FROM t1;
+id c1 + 0 c1
+1 0
+2 1 a
+3 2
+4 0
+DROP TABLE t1;
End of 4.1 tests
diff -Nrup a/mysql-test/t/type_enum.test b/mysql-test/t/type_enum.test
--- a/mysql-test/t/type_enum.test 2007-02-12 17:31:43 +04:00
+++ b/mysql-test/t/type_enum.test 2007-06-27 03:38:09 +05:00
@@ -156,4 +156,21 @@ drop table t1;
create table t1(exhausting_charset enum('ABCDEFGHIJKLMNOPQRSTUVWXYZ','
+#
+# Bug #29251: MySQL coerces special 0 enum values to normal '' value
+# when ALTERing the column
+#
+
+CREATE TABLE t1 (
+ id INT AUTO_INCREMENT PRIMARY KEY,
+ c1 ENUM('a', '', 'b')
+);
+INSERT INTO t1 (c1) VALUES (0), ('a'), (''), ('b');
+SELECT id, c1 + 0, c1 FROM t1;
+
+ALTER TABLE t1 CHANGE c1 c1 ENUM('a', '') NOT NULL;
+SELECT id, c1 + 0, c1 FROM t1;
+
+DROP TABLE t1;
+
--echo End of 4.1 tests
diff -Nrup a/sql/field_conv.cc b/sql/field_conv.cc
--- a/sql/field_conv.cc 2007-02-01 18:00:23 +04:00
+++ b/sql/field_conv.cc 2007-06-27 03:38:07 +05:00
@@ -311,6 +311,15 @@ static void do_field_string(Copy_field *
}
+static void do_field_enum(Copy_field *copy)
+{
+ if (copy->from_field->val_int() == 0)
+ ((Field_enum *) copy->to_field)->store_type((ulonglong) 0);
+ else
+ do_field_string(copy);
+}
+
+
static void do_field_int(Copy_field *copy)
{
longlong value=copy->from_field->val_int();
@@ -538,7 +547,13 @@ void (*Copy_field::get_copy_func(Field *
to->real_type() == FIELD_TYPE_SET)
{
if (!to->eq_def(from))
- return do_field_string;
+ {
+ if (from->real_type() == MYSQL_TYPE_ENUM &&
+ to->real_type() == MYSQL_TYPE_ENUM)
+ return do_field_enum;
+ else
+ return do_field_string;
+ }
}
else if (to->charset() != from->charset())
return do_field_string;
Thread |
---|
• bk commit into 4.1 tree (gshchepa:1.2670) BUG#29251 | gshchepa | 27 Jun |