summaryrefslogtreecommitdiff
path: root/sql/field_conv.cc
diff options
context:
space:
mode:
authorunknown <gshchepa/uchum@gleb.loc>2007-07-12 00:03:08 +0500
committerunknown <gshchepa/uchum@gleb.loc>2007-07-12 00:03:08 +0500
commit0920c75b5efa164253c546f88e30b9b4fe686e6b (patch)
tree8bc00fad919ffc8392696ff918d7d605d1832883 /sql/field_conv.cc
parent3295d449c42464f40940e9e7d369fef5935f4c40 (diff)
downloadmariadb-git-0920c75b5efa164253c546f88e30b9b4fe686e6b.tar.gz
Fixed bug #29360.
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.
Diffstat (limited to 'sql/field_conv.cc')
-rw-r--r--sql/field_conv.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index a286255ec23..2df65b62de6 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -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());