summaryrefslogtreecommitdiff
path: root/sql/field_conv.cc
diff options
context:
space:
mode:
authorgshchepa/uchum@gleb.loc <>2007-07-12 00:03:08 +0500
committergshchepa/uchum@gleb.loc <>2007-07-12 00:03:08 +0500
commit13844b2533862ba6c746e3233e7693a90162c9ea (patch)
tree8bc00fad919ffc8392696ff918d7d605d1832883 /sql/field_conv.cc
parentf3d270df69d1df1e9711e6c828c38539f20046f9 (diff)
downloadmariadb-git-13844b2533862ba6c746e3233e7693a90162c9ea.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...
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());