summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authorRamil Kalimullin <ramil@mysql.com>2008-10-24 13:00:03 +0500
committerRamil Kalimullin <ramil@mysql.com>2008-10-24 13:00:03 +0500
commit256f41edfe87bf92807d9c9500ae627a0045ef5e (patch)
treeebe76f83e6b0ae5c7d6e772bb43fd4bdee6218ed /sql/field.cc
parent8e6277fb1c3c6ac156305c987e0f2c17a54c16e7 (diff)
downloadmariadb-git-256f41edfe87bf92807d9c9500ae627a0045ef5e.tar.gz
Fix for bug#23113: Different behavior on altering ENUM fields between 5.0 and 5.1
Problem: mysqld doesn't detect that enum data must be reinserted performing 'ALTER TABLE' in some cases. Fix: reinsert data altering an enum field if enum values are changed. mysql-test/r/alter_table.result: Fix for bug#23113: Different behavior on altering ENUM fields between 5.0 and 5.1 - test result. mysql-test/t/alter_table.test: Fix for bug#23113: Different behavior on altering ENUM fields between 5.0 and 5.1 - test case. sql/field.cc: Fix for bug#23113: Different behavior on altering ENUM fields between 5.0 and 5.1 - Field_enum::is_equal() introduced, which is called to detect that a field is changing by 'ALTER TABLE'. sql/field.h: Fix for bug#23113: Different behavior on altering ENUM fields between 5.0 and 5.1 - Field_enum::is_equal() introduced, which is called to detect that a field is changing by 'ALTER TABLE'.
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc35
1 files changed, 25 insertions, 10 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 16bf0fdb070..a03beb4e8af 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -8783,28 +8783,43 @@ bool Field::eq_def(Field *field)
return 1;
}
+
/**
@return
returns 1 if the fields are equally defined
*/
+
bool Field_enum::eq_def(Field *field)
{
if (!Field::eq_def(field))
return 0;
- TYPELIB *from_lib=((Field_enum*) field)->typelib;
+ return compare_enum_values(((Field_enum*) field)->typelib);
+}
- if (typelib->count < from_lib->count)
- return 0;
- for (uint i=0 ; i < from_lib->count ; i++)
+
+bool Field_enum::compare_enum_values(TYPELIB *values)
+{
+ if (typelib->count != values->count)
+ return FALSE;
+ for (uint i= 0; i < typelib->count; i++)
if (my_strnncoll(field_charset,
- (const uchar*)typelib->type_names[i],
- strlen(typelib->type_names[i]),
- (const uchar*)from_lib->type_names[i],
- strlen(from_lib->type_names[i])))
- return 0;
- return 1;
+ (const uchar*) typelib->type_names[i],
+ typelib->type_lengths[i],
+ (const uchar*) values->type_names[i],
+ values->type_lengths[i]))
+ return FALSE;
+ return TRUE;
+}
+
+
+uint Field_enum::is_equal(Create_field *new_field)
+{
+ if (!Field_str::is_equal(new_field))
+ return 0;
+ return compare_enum_values(new_field->interval);
}
+
/**
@return
returns 1 if the fields are equally defined