The special `zero' enum value was coerced to the normal
empty string enum value during a field-to-field copy.
This bug affected CREATE ... SELECT statements and
SELECT aggregate GROUP BY enum field statements.

Also this bug made unnecessary warnings during
the execution of CREATE ... SELECT statements:
Warning       1265    Data truncated for column...


sql/field_conv.cc:
  Fixed bug #29360.
  The field_conv function has been modified to properly convert
  the special `zero' enum value between enum fields.
mysql-test/t/type_enum.test:
  Updated test case for bug #29360.
mysql-test/r/type_enum.result:
  Updated test case for bug #29360.
mysql-test/r/type_ranges.result:
  Updated test case for bug #29360.
This commit is contained in:
unknown 2007-07-12 00:03:08 +05:00
commit 0920c75b5e
4 changed files with 49 additions and 9 deletions

View file

@ -790,11 +790,17 @@ int field_conv(Field *to,Field *from)
blob->value.copy();
return blob->store(blob->value.ptr(),blob->value.length(),from->charset());
}
if ((from->result_type() == STRING_RESULT &&
(to->result_type() == STRING_RESULT ||
(from->real_type() != FIELD_TYPE_ENUM &&
from->real_type() != FIELD_TYPE_SET))) ||
to->type() == FIELD_TYPE_DECIMAL)
if (from->real_type() == FIELD_TYPE_ENUM &&
to->real_type() == FIELD_TYPE_ENUM &&
from->val_int() == 0)
{
((Field_enum *)(to))->store_type(0);
}
else if ((from->result_type() == STRING_RESULT &&
(to->result_type() == STRING_RESULT ||
(from->real_type() != FIELD_TYPE_ENUM &&
from->real_type() != FIELD_TYPE_SET))) ||
to->type() == FIELD_TYPE_DECIMAL)
{
char buff[MAX_FIELD_WIDTH];
String result(buff,sizeof(buff),from->charset());