diff options
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/sql/field.cc b/sql/field.cc index 3695268a888..d6f9797071b 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -161,6 +161,14 @@ static bool test_if_real(const char *str,int length, CHARSET_INFO *cs) } +static inline uint field_length_without_space(const char *ptr, uint length) +{ + const char *end= ptr+length; + while (end > ptr && end[-1] == ' ') + end--; + return (uint) (end-ptr); +} + /**************************************************************************** ** Functions for the base classes ** This is an unpacked number. @@ -3604,11 +3612,11 @@ bool Field_newdate::get_date(TIME *ltime,bool fuzzydate) if (is_null()) return 1; uint32 tmp=(uint32) uint3korr(ptr); - bzero((char*) ltime,sizeof(*ltime)); ltime->day= tmp & 31; ltime->month= (tmp >> 5) & 15; ltime->year= (tmp >> 9); ltime->time_type=TIMESTAMP_DATE; + ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0; return (!fuzzydate && (!ltime->month || !ltime->day)) ? 1 : 0; } @@ -3969,9 +3977,23 @@ String *Field_string::val_str(String *val_buffer __attribute__((unused)), int Field_string::cmp(const char *a_ptr, const char *b_ptr) { +#ifdef USE_STRCOLL + if (field_charset->mbmaxlen > 1) + { + /* + We have to remove end space to be able to compare multi-byte-characters + like in latin_de 'ae' and 0xe4 + */ + uint a_length= field_length_without_space(a_ptr, field_length); + uint b_length= field_length_without_space(b_ptr, field_length); + return my_strnncoll(field_charset, + (const uchar*) a_ptr, a_length, + (const uchar*) b_ptr, b_length); + } +#endif return my_strnncoll(field_charset, - (const uchar*)a_ptr,field_length, - (const uchar*)b_ptr,field_length); + (const uchar*) a_ptr, field_length, + (const uchar*) b_ptr, field_length); } void Field_string::sort_string(char *to,uint length) |