diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2022-02-03 17:01:31 +0100 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2022-02-03 17:01:31 +0100 |
commit | f5c5f8e41ecd4d407022d3772ac43075c16824a5 (patch) | |
tree | 8a46fbd9dfd51352800ea606ae52a53ceb239501 /sql/field.cc | |
parent | 8d742fe4acb91652fcbeb36506d20ead4ff19e83 (diff) | |
parent | cf63eecef44f189ce2d221612dee9dfc1885ba4e (diff) | |
download | mariadb-git-f5c5f8e41ecd4d407022d3772ac43075c16824a5.tar.gz |
Merge branch '10.5' into 10.6
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 97 |
1 files changed, 54 insertions, 43 deletions
diff --git a/sql/field.cc b/sql/field.cc index 63d39c77d95..91ac3f50d3c 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -7289,6 +7289,19 @@ bool Field_longstr::send(Protocol *protocol) } +const Type_handler *Field_string::type_handler() const +{ + if (is_var_string()) + return &type_handler_var_string; + /* + This is a temporary solution and will be fixed soon (in 10.9?). + Type_handler_string_json will provide its own Field_string_json. + */ + if (Type_handler_json_common::has_json_valid_constraint(this)) + return &type_handler_string_json; + return &type_handler_string; +} + /* Copy a string and fill with space */ int Field_string::store(const char *from, size_t length,CHARSET_INFO *cs) @@ -7554,22 +7567,10 @@ Field_string::compatible_field_size(uint field_metadata, int Field_string::cmp(const uchar *a_ptr, const uchar *b_ptr) const { - size_t a_len, b_len; - - if (mbmaxlen() != 1) - { - size_t char_len= Field_string::char_length(); - a_len= field_charset()->charpos(a_ptr, a_ptr + field_length, char_len); - b_len= field_charset()->charpos(b_ptr, b_ptr + field_length, char_len); - } - else - a_len= b_len= field_length; - /* - We have to remove end space to be able to compare multi-byte-characters - like in latin_de 'ae' and 0xe4 - */ - return field_charset()->strnncollsp(a_ptr, a_len, - b_ptr, b_len); + return field_charset()->coll->strnncollsp_nchars(field_charset(), + a_ptr, field_length, + b_ptr, field_length, + Field_string::char_length()); } @@ -7788,6 +7789,20 @@ en_fieldtype Field_string::tmp_engine_column_type(bool use_packed_rows) const const uint Field_varstring::MAX_SIZE= UINT_MAX16; + +const Type_handler *Field_varstring::type_handler() const +{ + /* + This is a temporary solution and will be fixed soon (in 10.9?). + Type_handler_varchar_json will provide its own Field_varstring_json + and Field_varstring_compressed_json + */ + if (Type_handler_json_common::has_json_valid_constraint(this)) + return &type_handler_varchar_json; + return &type_handler_varchar; +} + + /** Save the field metadata for varstring fields. @@ -7934,19 +7949,6 @@ int Field_varstring::cmp(const uchar *a_ptr, const uchar *b_ptr) const } -static int cmp_str_prefix(const uchar *ua, size_t alen, const uchar *ub, - size_t blen, size_t prefix, CHARSET_INFO *cs) -{ - const char *a= (char*)ua, *b= (char*)ub; - MY_STRCOPY_STATUS status; - prefix/= cs->mbmaxlen; - alen= cs->cset->well_formed_char_length(cs, a, a + alen, prefix, &status); - blen= cs->cset->well_formed_char_length(cs, b, b + blen, prefix, &status); - return cs->coll->strnncollsp(cs, ua, alen, ub, blen); -} - - - int Field_varstring::cmp_prefix(const uchar *a_ptr, const uchar *b_ptr, size_t prefix_len) const { @@ -7966,8 +7968,13 @@ int Field_varstring::cmp_prefix(const uchar *a_ptr, const uchar *b_ptr, a_length= uint2korr(a_ptr); b_length= uint2korr(b_ptr); } - return cmp_str_prefix(a_ptr+length_bytes, a_length, b_ptr+length_bytes, - b_length, prefix_len, field_charset()); + return field_charset()->coll->strnncollsp_nchars(field_charset(), + a_ptr + length_bytes, + a_length, + b_ptr + length_bytes, + b_length, + prefix_len / + field_charset()->mbmaxlen); } @@ -8754,8 +8761,11 @@ int Field_blob::cmp_prefix(const uchar *a_ptr, const uchar *b_ptr, memcpy(&blob1, a_ptr+packlength, sizeof(char*)); memcpy(&blob2, b_ptr+packlength, sizeof(char*)); size_t a_len= get_length(a_ptr), b_len= get_length(b_ptr); - return cmp_str_prefix(blob1, a_len, blob2, b_len, prefix_len, - field_charset()); + return field_charset()->coll->strnncollsp_nchars(field_charset(), + blob1, a_len, + blob2, b_len, + prefix_len / + field_charset()->mbmaxlen); } @@ -8922,6 +8932,15 @@ void Field_blob::sort_string(uchar *to,uint length) */ const Type_handler *Field_blob::type_handler() const { + /* + This is a temporary solution and will be fixed soon (in 10.9?). + Type_handler_*blob_json will provide its own Field_blob_json + and Field_blob_compressed_json. + */ + if (Type_handler_json_common::has_json_valid_constraint(this)) + return Type_handler_json_common:: + json_blob_type_handler_by_length_bytes(packlength); + switch (packlength) { case 1: return &type_handler_tiny_blob; case 2: return &type_handler_blob; @@ -9634,16 +9653,8 @@ bool Field_num::is_equal(const Column_definition &new_field) const } -bool Field_enum::can_optimize_range(const Item_bool_func *cond, - const Item *item, - bool is_eq_func) const -{ - return item->cmp_type() != TIME_RESULT; -} - - -bool Field_enum::can_optimize_keypart_ref(const Item_bool_func *cond, - const Item *item) const +bool Field_enum::can_optimize_range_or_keypart_ref(const Item_bool_func *cond, + const Item *item) const { switch (item->cmp_type()) { |