diff options
author | unknown <evgen@moonbone.local> | 2006-06-22 00:29:04 +0400 |
---|---|---|
committer | unknown <evgen@moonbone.local> | 2006-06-22 00:29:04 +0400 |
commit | 822e8866c7009d8d7bd25300f1cc4c09c110c640 (patch) | |
tree | f4a8dc3dfd444b56bbc2b026f7e319e27f959229 /sql | |
parent | fa83f8baa094ed45330afa0e2516eeb31e803b27 (diff) | |
download | mariadb-git-822e8866c7009d8d7bd25300f1cc4c09c110c640.tar.gz |
Fixed bug #14896.
This bug in Field_string::cmp resulted in a wrong comparison
with keys in partial indexes over multi-byte character fields.
Given field a is declared as a varchar(16) collate utf8_unicode_ci
INDEX(a(4)) gives us an example of such an index.
Wrong key comparisons could lead to wrong result sets if
the selected query execution plan used a range scan by
a partial index over a utf8 character field.
This also caused wrong results in many other cases.
mysql-test/t/ctype_utf8.test:
Added test cases for bug #14896.
mysql-test/r/ctype_utf8.result:
Added test cases for bug #14896.
sql/field.cc:
Fixed bug #14896.
This bug in Field_string::cmp resulted in a wrong comparison
with keys in partial indexes over multi-byte character fields.
Given field a is declared as a varchar(16) collate utf8_unicode_ci
INDEX(a(4)) gives us an example of such an index.
Wrong key comparisons could lead to wrong result sets if
the selected query execution plan used a range scan by
a partial index over a utf8 character field.
This also caused wrong results in many other cases.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/sql/field.cc b/sql/field.cc index ec4d4b4e4f5..3cb0c0d3a7c 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5072,17 +5072,6 @@ int Field_string::cmp(const char *a_ptr, const char *b_ptr) { uint a_len, b_len; - if (field_charset->strxfrm_multiply > 1) - { - /* - We have to remove end space to be able to compare multi-byte-characters - like in latin_de 'ae' and 0xe4 - */ - return field_charset->coll->strnncollsp(field_charset, - (const uchar*) a_ptr, field_length, - (const uchar*) b_ptr, - field_length); - } if (field_charset->mbmaxlen != 1) { uint char_len= field_length/field_charset->mbmaxlen; @@ -5091,8 +5080,13 @@ int Field_string::cmp(const char *a_ptr, const char *b_ptr) } else a_len= b_len= field_length; - return my_strnncoll(field_charset,(const uchar*) a_ptr, a_len, - (const uchar*) b_ptr, b_len); + /* + We have to remove end space to be able to compare multi-byte-characters + like in latin_de 'ae' and 0xe4 + */ + return field_charset->coll->strnncollsp(field_charset, + (const uchar*) a_ptr, a_len, + (const uchar*) b_ptr, b_len); } |