diff options
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/sql/field.cc b/sql/field.cc index 3dc1375dff3..e7e8ec736ef 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -304,14 +304,11 @@ bool Field::field_cast_compatible(Field::field_cast_enum type) { DBUG_ASSERT(type != FIELD_CAST_STOP); Field::field_cast_enum *array= field_cast_array[field_cast_type()]; - uint i= 0; - Field::field_cast_enum tp; - do + while (*array != FIELD_CAST_STOP) { - tp= array[i++]; - if (tp == type) + if (*(array++) == type) return 1; - } while (tp != FIELD_CAST_STOP); + } return 0; } @@ -4438,13 +4435,9 @@ char *Field_string::pack(char *to, const char *from, uint max_length) while (end > from && end[-1] == ' ') end--; length= (end-from); + *to++= (char) (uchar) length; if (field_length > 255) - { - int2store(to, length); - to+= 2; - } - else - *to++= (char) (uchar) length; + *to++= (char) (uchar) (length >> 8); memcpy(to, from, (int) length); return to+length; } @@ -4459,13 +4452,9 @@ char *Field_string::pack_key(char *to, const char *from, uint max_length) set_if_smaller(length, char_length); while (length && from[length-1] == ' ') length--; + *to++= (char) (uchar) length; if (field_length > 255) - { - int2store(to, length); - to+= 2; - } - else - *to++= (char) (uchar) length; + *to++= (char) (uchar) (length >> 8); memcpy(to, from, length); return to+length; } |