1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

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.
This commit is contained in:
Ramil Kalimullin
2008-10-24 13:00:03 +05:00
parent a4890f896c
commit adf630dcee
4 changed files with 53 additions and 12 deletions

View File

@ -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;
if (typelib->count < from_lib->count)
return 0;
for (uint i=0 ; i < from_lib->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;
return compare_enum_values(((Field_enum*) field)->typelib);
}
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],
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