summaryrefslogtreecommitdiff
path: root/sql/field_conv.cc
diff options
context:
space:
mode:
authorunknown <gshchepa/uchum@gleb.loc>2007-06-27 03:41:50 +0500
committerunknown <gshchepa/uchum@gleb.loc>2007-06-27 03:41:50 +0500
commit7fbf6303d264a84bd225e0113a910459a067e3d0 (patch)
tree790fb430c7654eb9815829f13e5dd0dc1b1abe72 /sql/field_conv.cc
parentbe684dc0ee86be11af02f918bd9063baa637a753 (diff)
downloadmariadb-git-7fbf6303d264a84bd225e0113a910459a067e3d0.tar.gz
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. sql/field_conv.cc: 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. mysql-test/t/type_enum.test: Updated test case for bug #29251. mysql-test/r/type_enum.result: Updated test case for bug #29251.
Diffstat (limited to 'sql/field_conv.cc')
-rw-r--r--sql/field_conv.cc17
1 files changed, 16 insertions, 1 deletions
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 59b550572c3..4a7935a4be7 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -311,6 +311,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_int(Copy_field *copy)
{
longlong value=copy->from_field->val_int();
@@ -538,7 +547,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;