diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 22 | ||||
-rw-r--r-- | sql/field.h | 8 | ||||
-rw-r--r-- | sql/key.cc | 3 | ||||
-rw-r--r-- | sql/table.cc | 2 |
4 files changed, 19 insertions, 16 deletions
diff --git a/sql/field.cc b/sql/field.cc index a6bbd8c9c16..83fc694c3af 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -7558,7 +7558,8 @@ int Field_string::cmp(const uchar *a_ptr, const uchar *b_ptr) const return field_charset()->coll->strnncollsp_nchars(field_charset(), a_ptr, field_length, b_ptr, field_length, - Field_string::char_length()); + Field_string::char_length(), + MY_STRNNCOLLSP_NCHARS_EMULATE_TRIMMED_TRAILING_SPACES); } @@ -7925,10 +7926,11 @@ int Field_varstring::cmp(const uchar *a_ptr, const uchar *b_ptr) const int Field_varstring::cmp_prefix(const uchar *a_ptr, const uchar *b_ptr, - size_t prefix_len) const + size_t prefix_char_len) const { - /* avoid expensive well_formed_char_length if possible */ - if (prefix_len == table->field[field_index]->field_length) + /* avoid more expensive strnncollsp_nchars() if possible */ + if (prefix_char_len * field_charset()->mbmaxlen == + table->field[field_index]->field_length) return Field_varstring::cmp(a_ptr, b_ptr); size_t a_length, b_length; @@ -7948,8 +7950,8 @@ int Field_varstring::cmp_prefix(const uchar *a_ptr, const uchar *b_ptr, a_length, b_ptr + length_bytes, b_length, - prefix_len / - field_charset()->mbmaxlen); + prefix_char_len, + 0); } @@ -8736,7 +8738,7 @@ int Field_blob::cmp(const uchar *a_ptr, const uchar *b_ptr) const int Field_blob::cmp_prefix(const uchar *a_ptr, const uchar *b_ptr, - size_t prefix_len) const + size_t prefix_char_len) const { uchar *blob1,*blob2; memcpy(&blob1, a_ptr+packlength, sizeof(char*)); @@ -8745,8 +8747,8 @@ int Field_blob::cmp_prefix(const uchar *a_ptr, const uchar *b_ptr, return field_charset()->coll->strnncollsp_nchars(field_charset(), blob1, a_len, blob2, b_len, - prefix_len / - field_charset()->mbmaxlen); + prefix_char_len, + 0); } @@ -9942,7 +9944,7 @@ my_decimal *Field_bit::val_decimal(my_decimal *deciaml_value) (not the table->record[0] necessarily) */ int Field_bit::cmp_prefix(const uchar *a, const uchar *b, - size_t prefix_len) const + size_t prefix_char_len) const { my_ptrdiff_t a_diff= a - ptr; my_ptrdiff_t b_diff= b - ptr; diff --git a/sql/field.h b/sql/field.h index ffba863073f..99e73fcc282 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1294,7 +1294,7 @@ public: Currently it's only used in partitioning. */ virtual int cmp_prefix(const uchar *a, const uchar *b, - size_t prefix_len) const + size_t prefix_char_len) const { return cmp(a, b); } virtual int cmp(const uchar *,const uchar *) const=0; virtual int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0U) const @@ -4176,7 +4176,7 @@ public: my_decimal *val_decimal(my_decimal *) override; bool send(Protocol *protocol) override; int cmp(const uchar *a,const uchar *b) const override; - int cmp_prefix(const uchar *a, const uchar *b, size_t prefix_len) const + int cmp_prefix(const uchar *a, const uchar *b, size_t prefix_char_len) const override; void sort_string(uchar *buff,uint length) override; uint get_key_image(uchar *buff, uint length, @@ -4469,7 +4469,7 @@ public: String *val_str(String *, String *) override; my_decimal *val_decimal(my_decimal *) override; int cmp(const uchar *a, const uchar *b) const override; - int cmp_prefix(const uchar *a, const uchar *b, size_t prefix_len) const + int cmp_prefix(const uchar *a, const uchar *b, size_t prefix_char_len) const override; int cmp(const uchar *a, uint32 a_length, const uchar *b, uint32 b_length) const; @@ -4954,7 +4954,7 @@ public: int cmp_binary_offset(uint row_offset) override { return cmp_offset(row_offset); } int cmp_prefix(const uchar *a, const uchar *b, - size_t max_length) const override; + size_t prefix_char_length) const override; int key_cmp(const uchar *a, const uchar *b) const override { return cmp_binary((uchar *) a, (uchar *) b); } int key_cmp(const uchar *str, uint length) const override; diff --git a/sql/key.cc b/sql/key.cc index 79f1c55b61c..d801bcc982b 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -611,7 +611,8 @@ int key_rec_cmp(void *key_p, uchar *first_rec, uchar *second_rec) that take the max length into account. */ if ((result= field->cmp_prefix(field->ptr+first_diff, field->ptr+sec_diff, - key_part->length))) + key_part->length / + field->charset()->mbmaxlen))) DBUG_RETURN(result); next_loop: key_part++; diff --git a/sql/table.cc b/sql/table.cc index 1c13a244afd..0bd2148bdd5 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -9013,7 +9013,7 @@ bool TABLE::check_period_overlaps(const KEY &key, return false; uint kp_len= key.key_part[part_nr].length; if (f->cmp_prefix(f->ptr_in_record(lhs), f->ptr_in_record(rhs), - kp_len) != 0) + kp_len / f->charset()->mbmaxlen) != 0) return false; } |