diff options
author | unknown <igor@olga.mysql.com> | 2007-06-30 16:24:09 -0700 |
---|---|---|
committer | unknown <igor@olga.mysql.com> | 2007-06-30 16:24:09 -0700 |
commit | 8dcd5fca6977a8aafb0dd874b348e0078eafda94 (patch) | |
tree | 5c5791f99f377362ada084e6a977b0dd39f605c0 | |
parent | a89259fad8ca301d882a26f41104abd4619a127c (diff) | |
parent | 7fbf6303d264a84bd225e0113a910459a067e3d0 (diff) | |
download | mariadb-git-8dcd5fca6977a8aafb0dd874b348e0078eafda94.tar.gz |
Merge olga.mysql.com:/home/igor/mysql-4.1-opt
into olga.mysql.com:/home/igor/mysql-5.0-opt
mysql-test/r/type_enum.result:
Auto merged
mysql-test/t/type_enum.test:
Auto merged
sql/field_conv.cc:
SCCS merged
-rw-r--r-- | mysql-test/r/type_enum.result | 23 | ||||
-rw-r--r-- | mysql-test/t/type_enum.test | 17 | ||||
-rw-r--r-- | sql/field_conv.cc | 17 |
3 files changed, 56 insertions, 1 deletions
diff --git a/mysql-test/r/type_enum.result b/mysql-test/r/type_enum.result index 0b420c42cc7..f537b7140ba 100644 --- a/mysql-test/r/type_enum.result +++ b/mysql-test/r/type_enum.result @@ -1778,6 +1778,29 @@ drop table t1; 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 +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 create table t1(f1 set('a','b'), index(f1)); insert into t1 values(''),(''),('a'),('b'); diff --git a/mysql-test/t/type_enum.test b/mysql-test/t/type_enum.test index 45da469cf2d..ecc945a3157 100644 --- a/mysql-test/t/type_enum.test +++ b/mysql-test/t/type_enum.test @@ -156,6 +156,23 @@ drop table t1; create table t1(exhausting_charset enum('ABCDEFGHIJKLMNOPQRSTUVWXYZ','
!"','#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~','xx\','yy\','zz')); +# +# 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 --git a/sql/field_conv.cc b/sql/field_conv.cc index 410db357510..a286255ec23 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -307,6 +307,15 @@ static void do_field_string(Copy_field *copy) } +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_varbinary_pre50(Copy_field *copy) { char buff[MAX_FIELD_WIDTH]; @@ -662,7 +671,13 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_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; |