diff options
118 files changed, 1416 insertions, 1025 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index 4b9abd17268..2c7f0a500b9 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2018, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB Corporation. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1092,8 +1092,8 @@ inline bool is_delimiter_command(char *name, ulong len) only name(first DELIMITER_NAME_LEN bytes) is checked. */ return (len >= DELIMITER_NAME_LEN && - !my_strnncoll(&my_charset_latin1, (uchar*) name, DELIMITER_NAME_LEN, - (uchar *) DELIMITER_NAME, DELIMITER_NAME_LEN)); + !my_charset_latin1.strnncoll(name, DELIMITER_NAME_LEN, + DELIMITER_NAME, DELIMITER_NAME_LEN)); } /** @@ -2254,8 +2254,8 @@ static COMMANDS *find_command(char *name) */ for (uint i= 0; commands[i].func; i++) { - if (!my_strnncoll(&my_charset_latin1, (uchar*) name, len, - (uchar*) commands[i].name, len) && + if (!my_charset_latin1.strnncoll((uchar*) name, len, + (uchar*) commands[i].name, len) && (commands[i].name[len] == '\0') && (!end || (commands[i].takes_params && get_arg(name, CHECK)))) { @@ -2306,7 +2306,7 @@ static bool add_line(String &buffer, char *line, size_t line_length, #ifdef USE_MB // Accept multi-byte characters as-is int length; - if (use_mb(charset_info) && + if (charset_info->use_mb() && (length= my_ismbchar(charset_info, pos, end_of_line))) { if (!*ml_comment || preserve_comments) @@ -3241,9 +3241,8 @@ com_go(String *buffer,char *line __attribute__((unused))) (void) com_print(buffer,0); if (skip_updates && - (buffer->length() < 4 || my_strnncoll(charset_info, - (const uchar*)buffer->ptr(),4, - (const uchar*)"SET ",4))) + (buffer->length() < 4 || charset_info->strnncoll((const uchar*)buffer->ptr(),4, + (const uchar*)"SET ",4))) { (void) put_info("Ignoring query to other database",INFO_INFO); return 0; @@ -3613,9 +3612,8 @@ print_table_data(MYSQL_RES *result) for (uint off=0; (field = mysql_fetch_field(result)) ; off++) { size_t name_length= (uint) strlen(field->name); - size_t numcells= charset_info->cset->numcells(charset_info, - field->name, - field->name + name_length); + size_t numcells= charset_info->numcells(field->name, + field->name + name_length); size_t display_length= field->max_length + name_length - numcells; tee_fprintf(PAGER, " %-*s |",(int) MY_MIN(display_length, MAX_COLUMN_LENGTH), @@ -3664,7 +3662,7 @@ print_table_data(MYSQL_RES *result) We need to find how much screen real-estate we will occupy to know how many extra padding-characters we should send with the printing function. */ - size_t visible_length= charset_info->cset->numcells(charset_info, buffer, buffer + data_length); + size_t visible_length= charset_info->numcells(buffer, buffer + data_length); extra_padding= (uint) (data_length - visible_length); if (opt_binhex && is_binary_field(field)) @@ -4011,7 +4009,7 @@ safe_put_field(const char *pos,ulong length) { #ifdef USE_MB int l; - if (use_mb(charset_info) && + if (charset_info->use_mb() && (l = my_ismbchar(charset_info, pos, end))) { while (l--) diff --git a/client/mysqldump.c b/client/mysqldump.c index 18284fe2490..f932420aef0 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2010, 2019, MariaDB Corporation. + Copyright (c) 2010, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1374,10 +1374,10 @@ static char *my_case_str(const char *str, { my_match_t match; - uint status= my_charset_latin1.coll->instr(&my_charset_latin1, - str, str_len, - token, token_len, - &match, 1); + uint status= my_ci_instr(&my_charset_latin1, + str, str_len, + token, token_len, + &match, 1); return status ? (char *) str + match.end : NULL; } diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 69bd0ec3309..148a492a648 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB + Copyright (c) 2009, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -6733,14 +6733,14 @@ int read_line() if (!skip_char) { *p++= c; - if (use_mb(charset_info)) + if (charset_info->use_mb()) { const char *mb_start= p - 1; /* Could be a multibyte character */ /* See a similar code in "sql_load.cc" */ for ( ; p < buf_end; ) { - int charlen= my_charlen(charset_info, mb_start, p); + int charlen= charset_info->charlen(mb_start, p); if (charlen > 0) break; /* Full character */ if (MY_CS_IS_TOOSMALL(charlen)) diff --git a/client/sql_string.cc.dontuse b/client/sql_string.cc.dontuse index 72736ef5511..0d9536abfa9 100644 --- a/client/sql_string.cc.dontuse +++ b/client/sql_string.cc.dontuse @@ -1,5 +1,6 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -96,7 +97,7 @@ bool String::set(longlong num, CHARSET_INFO *cs) if (alloc(l)) return TRUE; - str_length=(uint32) (cs->cset->longlong10_to_str)(cs,Ptr,l,-10,num); + str_length=(uint32) (cs->longlong10_to_str)(Ptr,l,-10,num); str_charset=cs; return FALSE; } @@ -107,7 +108,7 @@ bool String::set(ulonglong num, CHARSET_INFO *cs) if (alloc(l)) return TRUE; - str_length=(uint32) (cs->cset->longlong10_to_str)(cs,Ptr,l,10,num); + str_length=(uint32) (cs->longlong10_to_str)(Ptr,l,10,num); str_charset=cs; return FALSE; } @@ -480,14 +481,14 @@ bool String::append_with_prefill(const char *s,uint32 arg_length, uint32 String::numchars() { - return str_charset->cset->numchars(str_charset, Ptr, Ptr+str_length); + return str_charset->(Ptr, Ptr+str_length); } int String::charpos(longlong i,uint32 offset) { if (i <= 0) return (int)i; - return (int)str_charset->cset->charpos(str_charset,Ptr+offset,Ptr+str_length,(size_t)i); + return (int)str_charset->charpos(Ptr+offset,Ptr+str_length,(size_t)i); } int String::strstr(const String &s,uint32 offset) @@ -655,9 +656,8 @@ void String::qs_append(uint i) int sortcmp(const String *s,const String *t, CHARSET_INFO *cs) { - return cs->coll->strnncollsp(cs, - (unsigned char *) s->ptr(),s->length(), - (unsigned char *) t->ptr(),t->length(), 0); + return cs->strnncollsp(s->ptr(), s->length(), + t->ptr(), t->length()); } diff --git a/include/m_ctype.h b/include/m_ctype.h index 60976d437e5..ea475aa9c1b 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -537,7 +538,7 @@ struct my_charset_handler_st - MB3 native code is ((b0 <<16) + (b1 << 8) + b2) Note, CHARSET_INFO::min_sort_char and CHARSET_INFO::max_sort_char are defined in native notation and should be written using - cs->cset->native_to_mb() rather than cs->cset->wc_mb(). + my_ci_native_to_mb() rather than my_ci_wc_mb(). */ my_charset_conv_wc_mb native_to_mb; }; @@ -553,6 +554,7 @@ extern MY_CHARSET_HANDLER my_charset_utf8mb3_handler; */ #define CHARSET_INFO_DEFINED + /* See strings/CHARSET_INFO.txt about information on this structure */ struct charset_info_st { @@ -564,7 +566,7 @@ struct charset_info_st const char *name; const char *comment; const char *tailoring; - const uchar *ctype; + const uchar *m_ctype; const uchar *to_lower; const uchar *to_upper; const uchar *sort_order; @@ -587,8 +589,502 @@ struct charset_info_st MY_CHARSET_HANDLER *cset; MY_COLLATION_HANDLER *coll; - + +#ifdef __cplusplus + /* Character set routines */ + bool use_mb() const + { + return mbmaxlen > 1; + } + + size_t numchars(const char *b, const char *e) const + { + return (cset->numchars)(this, b, e); + } + + size_t charpos(const char *b, const char *e, size_t pos) const + { + return (cset->charpos)(this, b, e, pos); + } + size_t charpos(const uchar *b, const uchar *e, size_t pos) const + { + return (cset->charpos)(this, (const char *) b, (const char*) e, pos); + } + + size_t lengthsp(const char *str, size_t length) const + { + return (cset->lengthsp)(this, str, length); + } + + size_t numcells(const char *b, const char *e) const + { + return (cset->numcells)(this, b, e); + } + + size_t caseup(const char *src, size_t srclen, + char *dst, size_t dstlen) const + { + return (cset->caseup)(this, src, srclen, dst, dstlen); + } + + size_t casedn(const char *src, size_t srclen, + char *dst, size_t dstlen) const + { + return (cset->casedn)(this, src, srclen, dst, dstlen); + } + + size_t long10_to_str(char *dst, size_t dstlen, + int radix, long int val) const + { + return (cset->long10_to_str)(this, dst, dstlen, radix, val); + } + + size_t (longlong10_to_str)(char *dst, size_t dstlen, + int radix, longlong val) const + { + return (cset->longlong10_to_str)(this, dst, dstlen, radix, val); + } + + int mb_wc(my_wc_t *wc, const uchar *b, const uchar *e) const + { + return (cset->mb_wc)(this, wc, b, e); + } + + int wc_mb(my_wc_t wc, uchar *s, uchar *e) const + { + return (cset->wc_mb)(this, wc, s, e); + } + + int native_to_mb(my_wc_t wc, uchar *s, uchar *e) const + { + return (cset->native_to_mb)(this, wc, s, e); + } + + int ctype(int *to, const uchar *s, const uchar *e) const + { + return (cset->ctype)(this, to, s, e); + } + + void fill(char *to, size_t len, int ch) const + { + (cset->fill)(this, to, len, ch); + } + + long strntol(const char *str, size_t length, + int base, char **endptr, int *error) const + { + return (cset->strntol)(this, str, length, base, endptr, error); + } + + ulong strntoul(const char *str, size_t length, + int base, char **endptr, int *error) const + { + return (cset->strntoul)(this, str, length, base, endptr, error); + } + + longlong strntoll(const char *str, size_t length, + int base, char **endptr, int *error) const + { + return (cset->strntoll)(this, str, length, base, endptr, error); + } + + ulonglong strntoull(const char *str, size_t length, + int base, char **endptr, int *error) const + { + return (cset->strntoull)(this, str, length, base, endptr, error); + } + + double strntod(char *str, size_t length, + char **endptr, int *error) const + { + return (cset->strntod)(this, str, length, endptr, error); + } + + longlong strtoll10(const char *str, char **endptr, int *error) const + { + return (cset->strtoll10)(this, str, endptr, error); + } + + ulonglong strntoull10rnd(const char *str, size_t length, int unsigned_fl, + char **endptr, int *error) const + { + return (cset->strntoull10rnd)(this, str, length, unsigned_fl, endptr, error); + } + + size_t scan(const char *b, const char *e, int seq) const + { + return (cset->scan)(this, b, e, seq); + } + + int charlen(const uchar *str, const uchar *end) const + { + return (cset->charlen)(this, str, end); + } + int charlen(const char *str, const char *end) const + { + return (cset->charlen)(this, (const uchar *) str, (const uchar *) end); + } + + uint charlen_fix(const uchar *str, const uchar *end) const + { + int char_length= (cset->charlen)(this, str, end); + DBUG_ASSERT(str < end); + return char_length > 0 ? (uint) char_length : (uint) 1U; + } + uint charlen_fix(const char *str, const char *end) const + { + return charlen_fix((const uchar *) str, (const uchar *) end); + } + + size_t well_formed_char_length(const char *str, const char *end, + size_t nchars, + MY_STRCOPY_STATUS *status) const + { + return (cset->well_formed_char_length)(this, str, end, nchars, status); + } + + size_t copy_fix(char *dst, size_t dst_length, + const char *src, size_t src_length, + size_t nchars, MY_STRCOPY_STATUS *status) const + { + return (cset->copy_fix)(this, dst, dst_length, src, src_length, nchars, + status); + } + + /* Collation routines */ + int strnncoll(const uchar *a, size_t alen, + const uchar *b, size_t blen, my_bool b_is_prefix= FALSE) const + { + return (coll->strnncoll)(this, a, alen, b, blen, b_is_prefix); + } + int strnncoll(const char *a, size_t alen, + const char *b, size_t blen, my_bool b_is_prefix= FALSE) const + { + return (coll->strnncoll)(this, + (const uchar *) a, alen, + (const uchar *) b, blen, b_is_prefix); + } + + int strnncollsp(const uchar *a, size_t alen, + const uchar *b, size_t blen) const + { + return (coll->strnncollsp)(this, a, alen, b, blen); + } + int strnncollsp(const char *a, size_t alen, + const char *b, size_t blen) const + { + return (coll->strnncollsp)(this, (uchar *) a, alen, (uchar *) b, blen); + } + + size_t strnxfrm(char *dst, size_t dstlen, uint nweights, + const char *src, size_t srclen, uint flags) const + { + return (coll->strnxfrm)(this, + (uchar *) dst, dstlen, nweights, + (const uchar *) src, srclen, flags); + } + size_t strnxfrm(uchar *dst, size_t dstlen, uint nweights, + const uchar *src, size_t srclen, uint flags) const + { + return (coll->strnxfrm)(this, + dst, dstlen, nweights, + src, srclen, flags); + } + size_t strnxfrm(uchar *dst, size_t dstlen, + const uchar *src, size_t srclen) const + { + return (coll->strnxfrm)(this, + dst, dstlen, dstlen, + src, srclen, MY_STRXFRM_PAD_WITH_SPACE); + } + + size_t strnxfrmlen(size_t length) const + { + return (coll->strnxfrmlen)(this, length); + } + + my_bool like_range(const char *s, size_t s_length, + pchar w_prefix, pchar w_one, pchar w_many, + size_t res_length, + char *min_str, char *max_str, + size_t *min_len, size_t *max_len) const + { + return (coll->like_range)(this, s, s_length, + w_prefix, w_one, w_many, + res_length, min_str, max_str, + min_len, max_len); + } + + int wildcmp(const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape,int w_one, int w_many) const + { + return (coll->wildcmp)(this, str, str_end, wildstr, wildend, escape, w_one, w_many); + } + + uint instr(const char *b, size_t b_length, + const char *s, size_t s_length, + my_match_t *match, uint nmatch) const + { + return (coll->instr)(this, b, b_length, s, s_length, match, nmatch); + } + + void hash_sort(const uchar *key, size_t len, ulong *nr1, ulong *nr2) const + { + (coll->hash_sort)(this, key, len, nr1, nr2); + } + + my_bool propagate(const uchar *str, size_t len) const + { + return (coll->propagate)(this, str, len); + } + +#endif /* __cplusplus */ }; + + +/* Character set routines */ + +static inline my_bool +my_ci_init_charset(struct charset_info_st *ci, MY_CHARSET_LOADER *loader) +{ + if (!ci->cset->init) + return FALSE; + return (ci->cset->init)(ci, loader); +} + + +static inline my_bool +my_ci_use_mb(CHARSET_INFO *ci) +{ + return ci->mbmaxlen > 1 ? TRUE : FALSE; +} + +static inline size_t +my_ci_numchars(CHARSET_INFO *cs, const char *b, const char *e) +{ + return (cs->cset->numchars)(cs, b, e); +} + +static inline size_t +my_ci_charpos(CHARSET_INFO *cs, const char *b, const char *e, size_t pos) +{ + return (cs->cset->charpos)(cs, b, e, pos); +} + +static inline size_t +my_ci_lengthsp(CHARSET_INFO *cs, const char *str, size_t length) +{ + return (cs->cset->lengthsp)(cs, str, length); +} + +static inline size_t +my_ci_numcells(CHARSET_INFO *cs, const char *b, const char *e) +{ + return (cs->cset->numcells)(cs, b, e); +} + +static inline size_t +my_ci_caseup(CHARSET_INFO *ci, + const char *src, size_t srclen, + char *dst, size_t dstlen) +{ + return (ci->cset->caseup)(ci, src, srclen, dst, dstlen); +} + +static inline size_t +my_ci_casedn(CHARSET_INFO *ci, + const char *src, size_t srclen, + char *dst, size_t dstlen) +{ + return (ci->cset->casedn)(ci, src, srclen, dst, dstlen); +} + +static inline size_t +my_ci_long10_to_str(CHARSET_INFO *cs, char *dst, size_t dstlen, + int radix, long int val) +{ + return (cs->cset->long10_to_str)(cs, dst, dstlen, radix, val); +} + +static inline size_t +my_ci_longlong10_to_str(CHARSET_INFO *cs, char *dst, size_t dstlen, + int radix, longlong val) +{ + return (cs->cset->longlong10_to_str)(cs, dst, dstlen, radix, val); +} + +#define my_ci_mb_wc(s, pwc, b, e) ((s)->cset->mb_wc)(s, pwc, b, e) +#define my_ci_wc_mb(s, wc, b, e) ((s)->cset->wc_mb)(s, wc, b, e) +#define my_ci_native_to_mb(s, wc, b, e) ((s)->cset->native_to_mb)(s, wc, b, e) +#define my_ci_ctype(s, pctype, b, e) ((s)->cset->ctype)(s, pctype, b, e) + +static inline void +my_ci_fill(CHARSET_INFO *cs, char *to, size_t len, int ch) +{ + (cs->cset->fill)(cs, to, len, ch); +} + +static inline long +my_ci_strntol(CHARSET_INFO *cs, const char *str, size_t length, + int base, char **endptr, int *error) +{ + return (cs->cset->strntol)(cs, str, length, base, endptr, error); +} + +static inline ulong +my_ci_strntoul(CHARSET_INFO *cs, const char *str, size_t length, + int base, char **endptr, int *error) +{ + return (cs->cset->strntoul)(cs, str, length, base, endptr, error); +} + +static inline longlong +my_ci_strntoll(CHARSET_INFO *cs, const char *str, size_t length, + int base, char **endptr, int *error) +{ + return (cs->cset->strntoll)(cs, str, length, base, endptr, error); +} + +static inline ulonglong +my_ci_strntoull(CHARSET_INFO *cs, const char *str, size_t length, + int base, char **endptr, int *error) +{ + return (cs->cset->strntoull)(cs, str, length, base, endptr, error); +} + +static inline double +my_ci_strntod(CHARSET_INFO *cs, char *str, size_t length, + char **endptr, int *error) +{ + return (cs->cset->strntod)(cs, str, length, endptr, error); +} + +static inline longlong +my_ci_strtoll10(CHARSET_INFO *cs, const char *str, char **endptr, int *error) +{ + return (cs->cset->strtoll10)(cs, str, endptr, error); +} + +static inline ulonglong +my_ci_strntoull10rnd(CHARSET_INFO *cs, + const char *str, size_t length, int unsigned_fl, + char **endptr, int *error) +{ + return (cs->cset->strntoull10rnd)(cs, str, length, unsigned_fl, endptr, error); +} + + +static inline size_t +my_ci_scan(CHARSET_INFO *cs, const char *b, const char *e, int seq) +{ + return (cs->cset->scan)(cs, b, e, seq); +} + + +/** + Return length of the leftmost character in a string. + @param cs - character set + @param str - the beginning of the string + @param end - the string end (the next byte after the string) + @return <=0 on errors (EOL, wrong byte sequence) + @return 1 on a single byte character + @return >1 on a multi-byte character + + Note, inlike my_ismbchar(), 1 is returned for a single byte character. +*/ + +static inline int +my_ci_charlen(CHARSET_INFO *cs, const uchar *str, const uchar *end) +{ + return (cs->cset->charlen)(cs, str, end); +} + + +static inline size_t +my_ci_well_formed_char_length(CHARSET_INFO *cs, + const char *str, const char *end, + size_t nchars, + MY_STRCOPY_STATUS *status) +{ + return (cs->cset->well_formed_char_length)(cs, str, end, nchars, status); +} + + +static inline size_t +my_ci_copy_fix(CHARSET_INFO *cs, + char *dst, size_t dst_length, + const char *src, size_t src_length, + size_t nchars, MY_STRCOPY_STATUS *status) +{ + return (cs->cset->copy_fix)(cs, dst, dst_length, src, src_length, nchars, + status); +} + + +/* Collation routines */ + +static inline my_bool +my_ci_init_collation(struct charset_info_st *ci, MY_CHARSET_LOADER *loader) +{ + if (!ci->coll->init) + return FALSE; + return (ci->coll->init)(ci, loader); +} + + +static inline int +my_ci_strnncoll(CHARSET_INFO *ci, + const uchar *a, size_t alen, + const uchar *b, size_t blen, + my_bool b_is_prefix) +{ + return (ci->coll->strnncoll)(ci, a, alen, b, blen, b_is_prefix); +} + +static inline int +my_ci_strnncollsp(CHARSET_INFO *ci, + const uchar *a, size_t alen, + const uchar *b, size_t blen) +{ + return (ci->coll->strnncollsp)(ci, a, alen, b, blen); +} + + +static inline my_bool +my_ci_like_range(CHARSET_INFO *ci, + const char *s, size_t s_length, + pchar w_prefix, pchar w_one, pchar w_many, + size_t res_length, + char *min_str, char *max_str, + size_t *min_len, size_t *max_len) +{ + return (ci->coll->like_range)(ci, s, s_length, + w_prefix, w_one, w_many, + res_length, min_str, max_str, + min_len, max_len); +} + + +static inline uint +my_ci_instr(CHARSET_INFO *ci, + const char *b, size_t b_length, + const char *s, size_t s_length, + my_match_t *match, uint nmatch) +{ + return (ci->coll->instr)(ci, b, b_length, s, s_length, match, nmatch); +} + + +static inline void +my_ci_hash_sort(CHARSET_INFO *ci, + const uchar *key, size_t len, + ulong *nr1, ulong *nr2) +{ + (ci->coll->hash_sort)(ci, key, len, nr1, nr2); +} + + #define ILLEGAL_CHARSET_INFO_NUMBER (~0U) extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_bin; @@ -1013,17 +1509,17 @@ size_t my_convert_fix(CHARSET_INFO *dstcs, char *dst, size_t dst_length, #define my_toprint(c) ((c) | 64) #define my_toupper(s,c) (char) ((s)->to_upper[(uchar) (c)]) #define my_tolower(s,c) (char) ((s)->to_lower[(uchar) (c)]) -#define my_isalpha(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L)) -#define my_isupper(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_U) -#define my_islower(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_L) -#define my_isdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_NMR) -#define my_isxdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_X) -#define my_isalnum(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L | _MY_NMR)) -#define my_isspace(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_SPC) -#define my_ispunct(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_PNT) -#define my_isprint(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B)) -#define my_isgraph(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR)) -#define my_iscntrl(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_CTR) +#define my_isalpha(s, c) (((s)->m_ctype+1)[(uchar) (c)] & (_MY_U | _MY_L)) +#define my_isupper(s, c) (((s)->m_ctype+1)[(uchar) (c)] & _MY_U) +#define my_islower(s, c) (((s)->m_ctype+1)[(uchar) (c)] & _MY_L) +#define my_isdigit(s, c) (((s)->m_ctype+1)[(uchar) (c)] & _MY_NMR) +#define my_isxdigit(s, c) (((s)->m_ctype+1)[(uchar) (c)] & _MY_X) +#define my_isalnum(s, c) (((s)->m_ctype+1)[(uchar) (c)] & (_MY_U | _MY_L | _MY_NMR)) +#define my_isspace(s, c) (((s)->m_ctype+1)[(uchar) (c)] & _MY_SPC) +#define my_ispunct(s, c) (((s)->m_ctype+1)[(uchar) (c)] & _MY_PNT) +#define my_isprint(s, c) (((s)->m_ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B)) +#define my_isgraph(s, c) (((s)->m_ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR)) +#define my_iscntrl(s, c) (((s)->m_ctype+1)[(uchar) (c)] & _MY_CTR) /* Some macros that should be cleaned up a little */ #define my_isvar(s,c) (my_isalnum(s,c) || (c) == '_') @@ -1031,16 +1527,9 @@ size_t my_convert_fix(CHARSET_INFO *dstcs, char *dst, size_t dst_length, #define my_binary_compare(s) ((s)->state & MY_CS_BINSORT) #define use_strnxfrm(s) ((s)->state & MY_CS_STRNXFRM) -#define my_strnxfrm(cs, d, dl, s, sl) \ - ((cs)->coll->strnxfrm((cs), (d), (dl), (dl), (s), (sl), MY_STRXFRM_PAD_WITH_SPACE)) #define my_strnncoll(s, a, b, c, d) ((s)->coll->strnncoll((s), (a), (b), (c), (d), 0)) -#define my_like_range(s, a, b, c, d, e, f, g, h, i, j) \ - ((s)->coll->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h), (i), (j))) -#define my_wildcmp(cs,s,se,w,we,e,o,m) ((cs)->coll->wildcmp((cs),(s),(se),(w),(we),(e),(o),(m))) #define my_strcasecmp(s, a, b) ((s)->coll->strcasecmp((s), (a), (b))) -#define my_charpos(cs, b, e, num) (cs)->cset->charpos((cs), (const char*) (b), (const char *)(e), (num)) -#define use_mb(s) ((s)->mbmaxlen > 1) /** Detect if the leftmost character in a string is a valid multi-byte character and return its length, or return 0 otherwise. @@ -1060,31 +1549,12 @@ uint my_ismbchar(CHARSET_INFO *cs, const char *str, const char *end) /** - Return length of the leftmost character in a string. - @param cs - character set - @param str - the beginning of the string - @param end - the string end (the next byte after the string) - @return <=0 on errors (EOL, wrong byte sequence) - @return 1 on a single byte character - @return >1 on a multi-byte character - - Note, inlike my_ismbchar(), 1 is returned for a single byte character. -*/ -static inline -int my_charlen(CHARSET_INFO *cs, const char *str, const char *end) -{ - return (cs->cset->charlen)(cs, (const uchar *) str, - (const uchar *) end); -} - - -/** Convert broken and incomplete byte sequences to 1 byte. */ static inline -uint my_charlen_fix(CHARSET_INFO *cs, const char *str, const char *end) +uint my_ci_charlen_fix(CHARSET_INFO *cs, const uchar *str, const uchar *end) { - int char_length= my_charlen(cs, str, end); + int char_length= my_ci_charlen(cs, str, end); DBUG_ASSERT(str < end); return char_length > 0 ? (uint) char_length : (uint) 1U; } @@ -1100,7 +1570,7 @@ my_well_formed_length(CHARSET_INFO *cs, const char *b, const char *e, size_t nchars, int *error) { MY_STRCOPY_STATUS status; - (void) cs->cset->well_formed_char_length(cs, b, e, nchars, &status); + (void) my_ci_well_formed_char_length(cs, b, e, nchars, &status); *error= status.m_well_formed_error_pos == NULL ? 0 : 1; return (size_t) (status.m_source_end_pos - b); } @@ -1108,12 +1578,6 @@ my_well_formed_length(CHARSET_INFO *cs, const char *b, const char *e, #define my_caseup_str(s, a) ((s)->cset->caseup_str((s), (a))) #define my_casedn_str(s, a) ((s)->cset->casedn_str((s), (a))) -#define my_strntol(s, a, b, c, d, e) ((s)->cset->strntol((s),(a),(b),(c),(d),(e))) -#define my_strntoul(s, a, b, c, d, e) ((s)->cset->strntoul((s),(a),(b),(c),(d),(e))) -#define my_strntoll(s, a, b, c, d, e) ((s)->cset->strntoll((s),(a),(b),(c),(d),(e))) -#define my_strntoull(s, a, b, c,d, e) ((s)->cset->strntoull((s),(a),(b),(c),(d),(e))) -#define my_strntod(s, a, b, c, d) ((s)->cset->strntod((s),(a),(b),(c),(d))) - /* XXX: still need to take care of this one */ #ifdef MY_CHARSET_TIS620 diff --git a/libmysqld/libmysql.c b/libmysqld/libmysql.c index d931b251bfd..2be94882303 100644 --- a/libmysqld/libmysql.c +++ b/libmysqld/libmysql.c @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2014, Oracle and/or its affiliates - Copyright (c) 2009, 2017, MariaDB Corporation + Copyright (c) 2009, 2020, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1206,7 +1206,7 @@ myodbc_remove_escape(MYSQL *mysql,char *name) { char *to; #ifdef USE_MB - my_bool use_mb_flag=use_mb(mysql->charset); + my_bool use_mb_flag= my_ci_use_mb(mysql->charset); char *UNINIT_VAR(end); if (use_mb_flag) for (end=name; *end ; end++) ; @@ -3198,7 +3198,7 @@ static void fetch_string_with_conversion(MYSQL_BIND *param, char *value, size_t } case MYSQL_TYPE_FLOAT: { - double data= my_strntod(&my_charset_latin1, value, length, &endptr, &err); + double data= my_ci_strntod(&my_charset_latin1, value, length, &endptr, &err); float fdata= (float) data; *param->error= (fdata != data) | MY_TEST(err); floatstore(buffer, fdata); @@ -3206,7 +3206,7 @@ static void fetch_string_with_conversion(MYSQL_BIND *param, char *value, size_t } case MYSQL_TYPE_DOUBLE: { - double data= my_strntod(&my_charset_latin1, value, length, &endptr, &err); + double data= my_ci_strntod(&my_charset_latin1, value, length, &endptr, &err); *param->error= MY_TEST(err); doublestore(buffer, data); break; diff --git a/mysql-test/include/ctype_heap.inc b/mysql-test/include/ctype_heap.inc index eafd37e104a..061ed439483 100644 --- a/mysql-test/include/ctype_heap.inc +++ b/mysql-test/include/ctype_heap.inc @@ -1,5 +1,5 @@ --echo # ---echo # Test that cs->coll->hash_sort() ignores trailing spaces +--echo # Test that hash_sort() ignores trailing spaces --echo # SELECT @@collation_connection; CREATE TABLE t1 ENGINE=HEAP AS SELECT REPEAT (' ', 10) AS a LIMIT 0; diff --git a/mysql-test/include/ctype_strtoll10.inc b/mysql-test/include/ctype_strtoll10.inc index 8bb2d29f86a..725180d6a24 100644 --- a/mysql-test/include/ctype_strtoll10.inc +++ b/mysql-test/include/ctype_strtoll10.inc @@ -1,5 +1,5 @@ --echo # ---echo # Testing cs->cset->strtoll10() +--echo # Testing strtoll10() --echo # SELECT @@character_set_connection; diff --git a/mysql-test/main/ctype_uca.test b/mysql-test/main/ctype_uca.test index 82be0305f07..67ef7d7aa96 100644 --- a/mysql-test/main/ctype_uca.test +++ b/mysql-test/main/ctype_uca.test @@ -483,7 +483,7 @@ set names utf8; --echo # Start of 5.5 tests --echo # # -# Test my_like_range and contractions +# Test like_range and contractions # SET collation_connection=utf8_czech_ci; --source include/ctype_czech.inc diff --git a/mysql-test/main/ctype_utf16.result b/mysql-test/main/ctype_utf16.result index 24d97d80dbb..c3af1eaf549 100644 --- a/mysql-test/main/ctype_utf16.result +++ b/mysql-test/main/ctype_utf16.result @@ -1086,7 +1086,7 @@ select left('aaa','1'); left('aaa','1') a # -# Testing cs->cset->strtoll10() +# Testing strtoll10() # SELECT @@character_set_connection; @@character_set_connection diff --git a/mysql-test/main/ctype_utf16.test b/mysql-test/main/ctype_utf16.test index 4422f9a6bc7..b22d2c69541 100644 --- a/mysql-test/main/ctype_utf16.test +++ b/mysql-test/main/ctype_utf16.test @@ -511,12 +511,12 @@ drop table t1; set names latin1; set collation_connection=utf16_general_ci; # -# Testing cs->coll->instr() +# Testing instr() # select position('bb' in 'abba'); # -# Testing cs->coll->hash_sort() +# Testing hash_sort() # create table t1 (a varchar(10) character set utf16) engine=heap; insert into t1 values ('a'),('A'),('b'),('B'); @@ -525,21 +525,21 @@ select hex(min(binary a)),count(*) from t1 group by a; drop table t1; # -# Testing cs->cset->numchars() +# Testing numchars() # select char_length('abcd'), octet_length('abcd'); select char_length(_utf16 0xD800DC00), octet_length(_utf16 0xD800DC00); select char_length(_utf16 0xD87FDFFF), octet_length(_utf16 0xD87FDFFF); # -# Testing cs->cset->charpos() +# Testing charpos() # select left('abcd',2); select hex(left(_utf16 0xD800DC00D87FDFFF, 1)); select hex(right(_utf16 0xD800DC00D87FDFFF, 1)); # -# Testing cs->cset->well_formed_length() +# Testing well_formed_length() # create table t1 (a varchar(10) character set utf16); # Bad sequences @@ -564,7 +564,7 @@ drop table t1; # # Bug#32393 Character sets: illegal characters in utf16 columns # -# Tests that cs->cset->wc_mb() doesn't accept surrogate parts +# Tests that my_ci_wc_mb() doesn't accept surrogate parts # # via alter # @@ -586,7 +586,7 @@ drop table t1; # -# Testing cs->cset->lengthsp() +# Testing lengthsp() # create table t1 (a char(10)) character set utf16; insert into t1 values ('a '); @@ -594,13 +594,13 @@ select hex(a) from t1; drop table t1; # -# Testing cs->cset->caseup() and cs->cset->casedn() +# Testing caseup() and casedn() # select upper('abcd'), lower('ABCD'); # # TODO: str_to_datetime() is broken and doesn't work with ucs2 and utf16 -# Testing cs->cset->snprintf() +# Testing snprintf() # #create table t1 (a date); #insert into t1 values ('2007-09-16'); @@ -608,11 +608,11 @@ select upper('abcd'), lower('ABCD'); #drop table t1; # -# Testing cs->cset->l10tostr +# Testing l10tostr # !!! Not used in the code # -# Testing cs->cset->ll10tostr +# Testing ll10tostr # create table t1 (a varchar(10) character set utf16); insert into t1 values (123456); @@ -620,16 +620,16 @@ select a, hex(a) from t1; drop table t1; -# Testing cs->cset->fill +# Testing fill # SOUNDEX fills strings with DIGIT ZERO up to four characters select hex(soundex('a')); # -# Testing cs->cset->strntol +# Testing strntol # !!! Not used in the code # -# Testing cs->cset->strntoul +# Testing strntoul # create table t1 (a enum ('a','b','c')) character set utf16; insert into t1 values ('1'); @@ -637,14 +637,14 @@ select * from t1; drop table t1; # -# Testing cs->cset->strntoll and cs->cset->strntoull +# Testing strntoll and strntoull # set names latin1; select hex(conv(convert('123' using utf16), -10, 16)); select hex(conv(convert('123' using utf16), 10, 16)); # -# Testing cs->cset->strntod +# Testing strntod # set names latin1; set character_set_connection=utf16; @@ -652,12 +652,12 @@ select 1.1 + '1.2'; select 1.1 + '1.2xxx'; # Testing strntoll10_utf16 -# Testing cs->cset->strtoll10 +# Testing strtoll10 select left('aaa','1'); --source include/ctype_strtoll10.inc # -# Testing cs->cset->strntoull10rnd +# Testing strntoull10rnd # create table t1 (a int); insert into t1 values ('-1234.1e2'); @@ -667,7 +667,7 @@ select * from t1; drop table t1; # -# Testing cs->cset->scan +# Testing scan # create table t1 (a int); insert into t1 values ('1 '); diff --git a/mysql-test/main/ctype_utf16_uca.test b/mysql-test/main/ctype_utf16_uca.test index 46d572fbe81..3b54e0deead 100644 --- a/mysql-test/main/ctype_utf16_uca.test +++ b/mysql-test/main/ctype_utf16_uca.test @@ -143,7 +143,7 @@ set collation_connection=utf16_unicode_ci; --source include/ctype_regex.inc # -# Test my_like_range and contractions +# Test like_range and contractions # SET collation_connection=utf16_czech_ci; --source include/ctype_czech.inc diff --git a/mysql-test/main/ctype_utf16le.result b/mysql-test/main/ctype_utf16le.result index ae389ed7390..dbb743c7ec3 100644 --- a/mysql-test/main/ctype_utf16le.result +++ b/mysql-test/main/ctype_utf16le.result @@ -1027,17 +1027,17 @@ text 65535 32767 DROP TABLE t1; SET NAMES utf8, collation_connection=utf16le_general_ci; # -# Testing cs->coll->instr() +# Testing instr() # SELECT POSITION('bb' IN 'abba'); POSITION('bb' IN 'abba') 2 # -# Testing cs->coll->hash_sort() +# Testing hash_sort() # SET NAMES utf8, collation_connection=utf16le_bin; # -# Test that cs->coll->hash_sort() ignores trailing spaces +# Test that hash_sort() ignores trailing spaces # SELECT @@collation_connection; @@collation_connection @@ -1056,7 +1056,7 @@ a 61002000 DROP TABLE t1; SET NAMES utf8, collation_connection=utf16le_general_ci; # -# Test that cs->coll->hash_sort() ignores trailing spaces +# Test that hash_sort() ignores trailing spaces # SELECT @@collation_connection; @@collation_connection @@ -1074,7 +1074,7 @@ a HEX(a) a 61002000 DROP TABLE t1; # -# Testing cs->cset->numchars() +# Testing numchars() # SELECT CHAR_LENGTH('abcd'), OCTET_LENGTH('abcd'); CHAR_LENGTH('abcd') OCTET_LENGTH('abcd') @@ -1086,7 +1086,7 @@ SELECT CHAR_LENGTH(_utf16le 0x7DD8FFDF), OCTET_LENGTH(_utf16le 0x7FD8DDDF); CHAR_LENGTH(_utf16le 0x7DD8FFDF) OCTET_LENGTH(_utf16le 0x7FD8DDDF) 1 4 # -# Testing cs->cset->charpos() +# Testing charpos() # SELECT LEFT('abcd',2); LEFT('abcd',2) @@ -1098,7 +1098,7 @@ SELECT HEX(RIGHT(_utf16le 0x00D800DC7FD8FFDF, 1)); HEX(RIGHT(_utf16le 0x00D800DC7FD8FFDF, 1)) 7FD8FFDF # -# Testing cs->cset->well_formed_length() +# Testing well_formed_length() # CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le); # Bad sequences @@ -1127,7 +1127,7 @@ DROP TABLE t1; # # Bug#32393 Character sets: illegal characters in utf16le columns # -# Tests that cs->cset->wc_mb() doesn't accept surrogate parts +# Tests that my_ci_wc_mb() doesn't accept surrogate parts # # via ALTER # @@ -1154,7 +1154,7 @@ HEX(s2) 3F00 DROP TABLE t1; # -# Testing cs->cset->lengthsp() +# Testing lengthsp() # CREATE TABLE t1 (a CHAR(10)) CHARACTER SET utf16le; INSERT INTO t1 VALUES ('a '); @@ -1163,7 +1163,7 @@ HEX(a) 6100 DROP TABLE t1; # -# Testing cs->cset->caseup() and cs->cset->casedn() +# Testing caseup() and casedn() # SELECT UPPER('abcd'), LOWER('ABCD'); UPPER('abcd') LOWER('ABCD') @@ -1181,7 +1181,7 @@ a 2007-09-16 DROP TABLE t1; # -# Testing cs->cset->ll10tostr +# Testing ll10tostr # CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le); INSERT INTO t1 VALUES (123456); @@ -1190,14 +1190,14 @@ a HEX(a) 123456 310032003300340035003600 DROP TABLE t1; # -# Testing cs->cset->fill +# Testing fill # SOUNDEX fills strings with DIGIT ZERO up to four characters # SELECT SOUNDEX('a'), HEX(SOUNDEX('a')); SOUNDEX('a') HEX(SOUNDEX('a')) A000 4100300030003000 # -# Testing cs->cset->strntoul +# Testing strntoul # CREATE TABLE t1 (a enum ('a','b','c')) CHARACTER SET utf16le; INSERT INTO t1 VALUES ('1'); @@ -1206,7 +1206,7 @@ a a DROP TABLE t1; # -# Testing cs->cset->strntoll and cs->cset->strntoull +# Testing strntoll and strntoull # SET NAMES latin1; SELECT HEX(CONV(CONVERT('123' USING utf16le), -10, 16)); @@ -1217,7 +1217,7 @@ HEX(CONV(CONVERT('123' USING utf16le), 10, 16)) 3742 SET NAMES utf8, collation_connection=utf16le_general_ci; # -# Testing cs->cset->strntod +# Testing strntod # SET NAMES utf8, collation_connection=utf16le_general_ci; SELECT 1.1 + '1.2'; @@ -1229,7 +1229,7 @@ SELECT 1.1 + '1.2xxx'; Warnings: Warning 1292 Truncated incorrect DOUBLE value: '1.2xxx' # -# Testing cs->cset->strtoll10 +# Testing strtoll10 # SELECT LEFT('aaa','1'); LEFT('aaa','1') @@ -1303,7 +1303,7 @@ Warning 1292 Truncated incorrect INTEGER value: '-18446744073709551614' Warning 1292 Truncated incorrect INTEGER value: '-18446744073709551615' DROP TABLE t1; # -# Testing cs->cset->strtoll10() +# Testing strtoll10() # SELECT @@character_set_connection; @@character_set_connection @@ -1479,7 +1479,7 @@ CAST('123456789123456789123x' AS UNSIGNED) Warnings: Warning 1292 Truncated incorrect INTEGER value: '123456789123456789123x' # -# Testing cs->cset->strntoull10rnd +# Testing strntoull10rnd # CREATE TABLE t1 (a int); INSERT INTO t1 VALUES ('-1234.1e2'); @@ -1531,7 +1531,7 @@ a 18446744073709551615 DROP TABLE t1; # -# Testing cs->cset->scan +# Testing scan # CREATE TABLE t1 (a int); INSERT INTO t1 VALUES ('1 '); diff --git a/mysql-test/main/ctype_utf16le.test b/mysql-test/main/ctype_utf16le.test index b8728b52db2..643e8559d97 100644 --- a/mysql-test/main/ctype_utf16le.test +++ b/mysql-test/main/ctype_utf16le.test @@ -434,12 +434,12 @@ DROP TABLE t1; SET NAMES utf8, collation_connection=utf16le_general_ci; --echo # ---echo # Testing cs->coll->instr() +--echo # Testing instr() --echo # SELECT POSITION('bb' IN 'abba'); --echo # ---echo # Testing cs->coll->hash_sort() +--echo # Testing hash_sort() --echo # SET NAMES utf8, collation_connection=utf16le_bin; --source include/ctype_heap.inc @@ -447,21 +447,21 @@ SET NAMES utf8, collation_connection=utf16le_general_ci; --source include/ctype_heap.inc --echo # ---echo # Testing cs->cset->numchars() +--echo # Testing numchars() --echo # SELECT CHAR_LENGTH('abcd'), OCTET_LENGTH('abcd'); SELECT CHAR_LENGTH(_utf16le 0x00D800DC), OCTET_LENGTH(_utf16le 0x00D800DC); SELECT CHAR_LENGTH(_utf16le 0x7DD8FFDF), OCTET_LENGTH(_utf16le 0x7FD8DDDF); --echo # ---echo # Testing cs->cset->charpos() +--echo # Testing charpos() --echo # SELECT LEFT('abcd',2); SELECT HEX(LEFT(_utf16le 0x00D800DC7FD8FFDF, 1)); SELECT HEX(RIGHT(_utf16le 0x00D800DC7FD8FFDF, 1)); --echo # ---echo # Testing cs->cset->well_formed_length() +--echo # Testing well_formed_length() --echo # CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le); --echo # Bad sequences @@ -486,7 +486,7 @@ DROP TABLE t1; --echo # --echo # Bug#32393 Character sets: illegal characters in utf16le columns --echo # ---echo # Tests that cs->cset->wc_mb() doesn't accept surrogate parts +--echo # Tests that my_ci_wc_mb() doesn't accept surrogate parts --echo # --echo # via ALTER --echo # @@ -508,7 +508,7 @@ DROP TABLE t1; --echo # ---echo # Testing cs->cset->lengthsp() +--echo # Testing lengthsp() --echo # CREATE TABLE t1 (a CHAR(10)) CHARACTER SET utf16le; INSERT INTO t1 VALUES ('a '); @@ -517,7 +517,7 @@ DROP TABLE t1; --echo # ---echo # Testing cs->cset->caseup() and cs->cset->casedn() +--echo # Testing caseup() and casedn() --echo # SELECT UPPER('abcd'), LOWER('ABCD'); @@ -532,7 +532,7 @@ DROP TABLE t1; --echo # ---echo # Testing cs->cset->ll10tostr +--echo # Testing ll10tostr --echo # CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le); INSERT INTO t1 VALUES (123456); @@ -540,14 +540,14 @@ SELECT a, HEX(a) FROM t1; DROP TABLE t1; --echo # ---echo # Testing cs->cset->fill +--echo # Testing fill --echo # SOUNDEX fills strings with DIGIT ZERO up to four characters --echo # SELECT SOUNDEX('a'), HEX(SOUNDEX('a')); --echo # ---echo # Testing cs->cset->strntoul +--echo # Testing strntoul --echo # CREATE TABLE t1 (a enum ('a','b','c')) CHARACTER SET utf16le; INSERT INTO t1 VALUES ('1'); @@ -556,7 +556,7 @@ DROP TABLE t1; --echo # ---echo # Testing cs->cset->strntoll and cs->cset->strntoull +--echo # Testing strntoll and strntoull --echo # SET NAMES latin1; SELECT HEX(CONV(CONVERT('123' USING utf16le), -10, 16)); @@ -565,7 +565,7 @@ SET NAMES utf8, collation_connection=utf16le_general_ci; --echo # ---echo # Testing cs->cset->strntod +--echo # Testing strntod --echo # SET NAMES utf8, collation_connection=utf16le_general_ci; SELECT 1.1 + '1.2'; @@ -573,7 +573,7 @@ SELECT 1.1 + '1.2xxx'; --echo # ---echo # Testing cs->cset->strtoll10 +--echo # Testing strtoll10 --echo # SELECT LEFT('aaa','1'); CREATE TABLE t1 AS SELECT REPEAT('abcd', 128) AS a; @@ -600,7 +600,7 @@ DROP TABLE t1; --source include/ctype_strtoll10.inc --echo # ---echo # Testing cs->cset->strntoull10rnd +--echo # Testing strntoull10rnd --echo # CREATE TABLE t1 (a int); INSERT INTO t1 VALUES ('-1234.1e2'); @@ -626,7 +626,7 @@ DROP TABLE t1; --echo # ---echo # Testing cs->cset->scan +--echo # Testing scan --echo # CREATE TABLE t1 (a int); INSERT INTO t1 VALUES ('1 '); diff --git a/mysql-test/main/ctype_utf32.result b/mysql-test/main/ctype_utf32.result index 501732848b1..c4e1e8beeeb 100644 --- a/mysql-test/main/ctype_utf32.result +++ b/mysql-test/main/ctype_utf32.result @@ -1083,7 +1083,7 @@ select left('aaa','1'); left('aaa','1') a # -# Testing cs->cset->strtoll10() +# Testing strtoll10() # SELECT @@character_set_connection; @@character_set_connection diff --git a/mysql-test/main/ctype_utf32.test b/mysql-test/main/ctype_utf32.test index 2e739ebfdbc..902647ec522 100644 --- a/mysql-test/main/ctype_utf32.test +++ b/mysql-test/main/ctype_utf32.test @@ -554,12 +554,12 @@ drop table t1; set names latin1; set collation_connection=utf32_general_ci; # -# Testing cs->coll->instr() +# Testing instr() # select position('bb' in 'abba'); # -# Testing cs->coll->hash_sort() +# Testing hash_sort() # create table t1 (a varchar(10) character set utf32) engine=heap; insert into t1 values ('a'),('A'),('b'),('B'); @@ -568,17 +568,17 @@ select hex(min(binary a)),count(*) from t1 group by a; drop table t1; # -# Testing cs->cset->numchars() +# Testing numchars() # select char_length('abcd'), octet_length('abcd'); # -# Testing cs->cset->charpos() +# Testing charpos() # select left('abcd',2); # -# Testing cs->cset->well_formed_length() +# Testing well_formed_length() # create table t1 (a varchar(10) character set utf32); insert into t1 values (_utf32 0x0010FFFF); @@ -625,7 +625,7 @@ select hex(s1) from t1 where s1 = 0xfffd; drop table t1; # -# Testing cs->cset->lengthsp() +# Testing lengthsp() # create table t1 (a char(10)) character set utf32; insert into t1 values ('a '); @@ -633,13 +633,13 @@ select hex(a) from t1; drop table t1; # -# Testing cs->cset->caseup() and cs->cset->casedn() +# Testing caseup() and casedn() # select upper('abcd'), lower('ABCD'); # # TODO: str_to_datetime() is broken and doesn't work with ucs2 and utf32 -# Testing cs->cset->snprintf() +# Testing snprintf() # #create table t1 (a date); #insert into t1 values ('2007-09-16'); @@ -647,11 +647,11 @@ select upper('abcd'), lower('ABCD'); #drop table t1; # -# Testing cs->cset->l10tostr +# Testing l10tostr # !!! Not used in the code # -# Testing cs->cset->ll10tostr +# Testing ll10tostr # create table t1 (a varchar(10) character set utf32); insert into t1 values (123456); @@ -659,16 +659,16 @@ select a, hex(a) from t1; drop table t1; # -# Testing cs->cset->fill +# Testing fill # SOUNDEX fills strings with DIGIT ZERO up to four characters select hex(soundex('a')); # -# Testing cs->cset->strntol +# Testing strntol # !!! Not used in the code # -# Testing cs->cset->strntoul +# Testing strntoul # create table t1 (a enum ('a','b','c')) character set utf32; insert into t1 values ('1'); @@ -676,14 +676,14 @@ select * from t1; drop table t1; # -# Testing cs->cset->strntoll and cs->cset->strntoull +# Testing strntoll and strntoull # set names latin1; select hex(conv(convert('123' using utf32), -10, 16)); select hex(conv(convert('123' using utf32), 10, 16)); # -# Testing cs->cset->strntod +# Testing strntod # set names latin1; set character_set_connection=utf32; @@ -691,12 +691,12 @@ select 1.1 + '1.2'; select 1.1 + '1.2xxx'; # Testing strntoll10_utf32 -# Testing cs->cset->strtoll10 +# Testing strtoll10 select left('aaa','1'); --source include/ctype_strtoll10.inc # -# Testing cs->cset->strntoull10rnd +# Testing strntoull10rnd # create table t1 (a int); insert into t1 values ('-1234.1e2'); @@ -706,7 +706,7 @@ select * from t1; drop table t1; # -# Testing cs->cset->scan +# Testing scan # create table t1 (a int); insert into t1 values ('1 '); diff --git a/mysql-test/main/ctype_utf32_uca.test b/mysql-test/main/ctype_utf32_uca.test index 334d8fd1d48..7849ddbca6f 100644 --- a/mysql-test/main/ctype_utf32_uca.test +++ b/mysql-test/main/ctype_utf32_uca.test @@ -144,7 +144,7 @@ set collation_connection=utf32_unicode_ci; # -# Test my_like_range and contractions +# Test like_range and contractions # SET collation_connection=utf32_czech_ci; --source include/ctype_czech.inc diff --git a/mysql-test/main/ctype_utf8mb4_uca.test b/mysql-test/main/ctype_utf8mb4_uca.test index 160cb48bad6..7a95da8468c 100644 --- a/mysql-test/main/ctype_utf8mb4_uca.test +++ b/mysql-test/main/ctype_utf8mb4_uca.test @@ -45,7 +45,7 @@ DROP TABLE t1; --echo # # # Bug#57737 Character sets: search fails with like, contraction, index -# Test my_like_range and contractions +# Test like_range and contractions # SET collation_connection=utf8mb4_czech_ci; --source include/ctype_czech.inc diff --git a/mysys/charset.c b/mysys/charset.c index 7771f5800ef..9c61fa85481 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -1,5 +1,6 @@ /* Copyright (c) 2000, 2011, Oracle and/or its affiliates + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -61,7 +62,7 @@ get_collation_number_internal(const char *name) static my_bool is_multi_byte_ident(CHARSET_INFO *cs, uchar ch) { - int chlen= my_charlen(cs, (const char *) &ch, (const char *) &ch + 1); + int chlen= my_ci_charlen(cs, &ch, &ch + 1); return MY_CS_IS_TOOSMALL(chlen) ? TRUE : FALSE; } @@ -164,11 +165,11 @@ static int cs_copy_data(struct charset_info_st *to, CHARSET_INFO *from) if (!(to->comment= my_once_strdup(from->comment,MYF(MY_WME)))) goto err; - if (from->ctype) + if (from->m_ctype) { - if (!(to->ctype= (uchar*) my_once_memdup((char*) from->ctype, - MY_CS_CTYPE_TABLE_SIZE, - MYF(MY_WME)))) + if (!(to->m_ctype= (uchar*) my_once_memdup((char*) from->m_ctype, + MY_CS_CTYPE_TABLE_SIZE, + MYF(MY_WME)))) goto err; if (init_state_maps(to)) goto err; @@ -212,7 +213,7 @@ err: static my_bool simple_8bit_charset_data_is_full(CHARSET_INFO *cs) { - return cs->ctype && cs->to_upper && cs->to_lower && cs->tab_to_uni; + return cs->m_ctype && cs->to_upper && cs->to_lower && cs->tab_to_uni; } @@ -228,8 +229,8 @@ inherit_charset_data(struct charset_info_st *cs, CHARSET_INFO *refcs) cs->to_upper= refcs->to_upper; if (!cs->to_lower) cs->to_lower= refcs->to_lower; - if (!cs->ctype) - cs->ctype= refcs->ctype; + if (!cs->m_ctype) + cs->m_ctype= refcs->m_ctype; if (!cs->tab_to_uni) cs->tab_to_uni= refcs->tab_to_uni; } @@ -355,7 +356,7 @@ static int add_collation(struct charset_info_st *cs) &my_charset_utf8mb3_unicode_nopad_ci : &my_charset_utf8mb3_unicode_ci, cs); - newcs->ctype= my_charset_utf8mb3_unicode_ci.ctype; + newcs->m_ctype= my_charset_utf8mb3_unicode_ci.m_ctype; if (init_state_maps(newcs)) return MY_XML_ERROR; #endif @@ -367,7 +368,7 @@ static int add_collation(struct charset_info_st *cs) &my_charset_utf8mb4_unicode_nopad_ci : &my_charset_utf8mb4_unicode_ci, cs); - newcs->ctype= my_charset_utf8mb4_unicode_ci.ctype; + newcs->m_ctype= my_charset_utf8mb4_unicode_ci.m_ctype; newcs->state|= MY_CS_AVAILABLE | MY_CS_LOADED; #endif } @@ -630,7 +631,7 @@ static void init_available_charsets(void) if (*cs) { DBUG_ASSERT(cs[0]->mbmaxlen <= MY_CS_MBMAXLEN); - if (cs[0]->ctype) + if (cs[0]->m_ctype) if (init_state_maps(*cs)) *cs= NULL; } @@ -807,8 +808,8 @@ get_internal_charset(MY_CHARSET_LOADER *loader, uint cs_number, myf flags) inherit_collation_data(cs, refcl); } - if ((cs->cset->init && cs->cset->init(cs, loader)) || - (cs->coll->init && cs->coll->init(cs, loader))) + if (my_ci_init_charset(cs, loader) || + my_ci_init_collation(cs, loader)) { cs= NULL; } @@ -1036,8 +1037,7 @@ size_t escape_string_for_mysql(CHARSET_INFO *charset_info, { char escape= 0; #ifdef USE_MB - int tmp_length= use_mb(charset_info) ? my_charlen(charset_info, from, end) : - 1; + int tmp_length= my_ci_charlen(charset_info, (const uchar *) from, (const uchar *) end); if (tmp_length > 1) { if (to + tmp_length > to_end) @@ -1174,7 +1174,7 @@ size_t escape_quotes_for_mysql(CHARSET_INFO *charset_info, const char *end, *to_end=to_start + (to_length ? to_length-1 : 2*length); my_bool overflow= FALSE; #ifdef USE_MB - my_bool use_mb_flag= use_mb(charset_info); + my_bool use_mb_flag= my_ci_use_mb(charset_info); #endif for (end= from + length; from < end; from++) { diff --git a/mysys/hash.c b/mysys/hash.c index bf2c176f9df..2d3077013d8 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. - Copyright (c) 2011, 2013, Monty Program Ab. + Copyright (c) 2011, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -45,7 +45,7 @@ my_hash_value_type my_hash_sort(CHARSET_INFO *cs, const uchar *key, size_t length) { ulong nr1= 1, nr2= 4; - cs->coll->hash_sort(cs, (uchar*) key, length, &nr1, &nr2); + my_ci_hash_sort(cs, (uchar*) key, length, &nr1, &nr2); return (my_hash_value_type) nr1; } diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c index 5dbbc17141f..73b9f874598 100644 --- a/mysys/lf_hash.c +++ b/mysys/lf_hash.c @@ -1,5 +1,5 @@ /* Copyright (c) 2006, 2018, Oracle and/or its affiliates. - Copyright (c) 2009, 2018, MariaDB + Copyright (c) 2009, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -313,7 +313,7 @@ static inline my_hash_value_type calc_hash(CHARSET_INFO *cs, size_t keylen) { ulong nr1= 1, nr2= 4; - cs->coll->hash_sort(cs, (uchar*) key, keylen, &nr1, &nr2); + my_ci_hash_sort(cs, (uchar*) key, keylen, &nr1, &nr2); return nr1; } diff --git a/mysys/mf_dirname.c b/mysys/mf_dirname.c index 700a68e4f3a..12fd15f82b9 100644 --- a/mysys/mf_dirname.c +++ b/mysys/mf_dirname.c @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,7 +35,7 @@ size_t dirname_length(const char *name) { #ifdef BASKSLASH_MBTAIL uint l; - if (use_mb(fs) && (l= my_ismbchar(fs, pos, pos + 3))) + if (my_ci_use_mb(fs) && (l= my_ismbchar(fs, pos, pos + 3))) { pos+= l - 1; continue; @@ -123,7 +124,7 @@ char *convert_dirname(char *to, const char *from, const char *from_end) { #ifdef BACKSLASH_MBTAIL uint l; - if (use_mb(fs) && (l= my_ismbchar(fs, from, from + 3))) + if (my_ci_use_mb(fs) && (l= my_ismbchar(fs, from, from + 3))) { memmove(to, from, l); to+= l; diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c index d79aa18dab2..b8722a2fdde 100644 --- a/mysys/mf_pack.c +++ b/mysys/mf_pack.c @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2012, 2013, Monty Program Ab. + Copyright (c) 2012, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -152,7 +152,7 @@ size_t cleanup_dirname(register char *to, const char *from) { #ifdef BACKSLASH_MBTAIL uint l; - if (use_mb(fs) && (l= my_ismbchar(fs, from_ptr - 1, from_ptr + 2))) + if (my_ci_use_mb(fs) && (l= my_ismbchar(fs, from_ptr - 1, from_ptr + 2))) { for (l-- ; l ; *++pos= *from_ptr++, l--); start= pos + 1; /* Don't look inside multi-byte char */ diff --git a/mysys/my_compare.c b/mysys/my_compare.c index 358cb77008e..d4ecfd7b4aa 100644 --- a/mysys/my_compare.c +++ b/mysys/my_compare.c @@ -1,5 +1,5 @@ /* Copyright (c) 2011, Oracle and/or its affiliates. - Copyright (C) 2009-2011 Monty Program Ab + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,9 +24,9 @@ int ha_compare_text(CHARSET_INFO *charset_info, const uchar *a, size_t a_length, const uchar *b, size_t b_length, my_bool part_key) { if (!part_key) - return charset_info->coll->strnncollsp(charset_info, a, a_length, - b, b_length); - return charset_info->coll->strnncoll(charset_info, a, a_length, + return my_ci_strnncollsp(charset_info, a, a_length, + b, b_length); + return my_ci_strnncoll(charset_info, a, a_length, b, b_length, part_key); } diff --git a/sql/create_options.cc b/sql/create_options.cc index a8d997efaf4..817c4ba46e0 100644 --- a/sql/create_options.cc +++ b/sql/create_options.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2010, 2019, MariaDB Corporation. +/* Copyright (C) 2010, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,9 +44,8 @@ void engine_option_value::link(engine_option_value **start, /* check duplicates to avoid writing them to frm*/ for(opt= *start; opt && ((opt->parsed && !opt->value.str) || - my_strnncoll(system_charset_info, - (uchar *)name.str, name.length, - (uchar*)opt->name.str, opt->name.length)); + system_charset_info->strnncoll(name.str, name.length, + opt->name.str, opt->name.length)); opt= opt->next) /* no-op */; if (opt) { @@ -187,9 +186,8 @@ static bool set_one_value(ha_create_table_option *opt, for (end=start; *end && *end != ','; end++) /* no-op */; - if (!my_strnncoll(system_charset_info, - (uchar*)start, end-start, - (uchar*)value->str, value->length)) + if (!system_charset_info->strnncoll(start, end-start, + value->str, value->length)) { *val= num; DBUG_RETURN(0); @@ -211,29 +209,17 @@ static bool set_one_value(ha_create_table_option *opt, if (!value->str) DBUG_RETURN(0); - if (!my_strnncoll(system_charset_info, - (const uchar*)"NO", 2, - (uchar *)value->str, value->length) || - !my_strnncoll(system_charset_info, - (const uchar*)"OFF", 3, - (uchar *)value->str, value->length) || - !my_strnncoll(system_charset_info, - (const uchar*)"0", 1, - (uchar *)value->str, value->length)) + if (!system_charset_info->strnncoll("NO", 2, value->str, value->length) || + !system_charset_info->strnncoll("OFF", 3, value->str, value->length) || + !system_charset_info->strnncoll("0", 1, value->str, value->length)) { *val= FALSE; DBUG_RETURN(FALSE); } - if (!my_strnncoll(system_charset_info, - (const uchar*)"YES", 3, - (uchar *)value->str, value->length) || - !my_strnncoll(system_charset_info, - (const uchar*)"ON", 2, - (uchar *)value->str, value->length) || - !my_strnncoll(system_charset_info, - (const uchar*)"1", 1, - (uchar *)value->str, value->length)) + if (!system_charset_info->strnncoll("YES", 3, value->str, value->length) || + !system_charset_info->strnncoll("ON", 2, value->str, value->length) || + !system_charset_info->strnncoll("1", 1, value->str, value->length)) { *val= TRUE; DBUG_RETURN(FALSE); @@ -295,9 +281,8 @@ bool parse_option_list(THD* thd, handlerton *hton, void *option_struct_arg, for (val= *option_list; val; val= val->next) { last= val; - if (my_strnncoll(system_charset_info, - (uchar*)opt->name, opt->name_length, - (uchar*)val->name.str, val->name.length)) + if (system_charset_info->strnncoll(opt->name, opt->name_length, + val->name.str, val->name.length)) continue; /* skip duplicates (see engine_option_value constructor above) */ @@ -809,9 +794,8 @@ bool is_engine_option_known(engine_option_value *opt, for (; rules->name; rules++) { - if (!my_strnncoll(system_charset_info, - (uchar*)rules->name, rules->name_length, - (uchar*)opt->name.str, opt->name.length)) + if (!system_charset_info->strnncoll(rules->name, rules->name_length, + opt->name.str, opt->name.length)) return true; } return false; diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc index 19ea40106df..af541b1bb32 100644 --- a/sql/debug_sync.cc +++ b/sql/debug_sync.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2009, 2013, Oracle and/or its affiliates. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -855,8 +856,7 @@ static char *debug_sync_token(char **token_p, uint *token_length_p, DBUG_ASSERT(ptr); /* Skip leading space */ - ptr+= system_charset_info->cset->scan(system_charset_info, - ptr, ptrend, MY_SEQ_SPACES); + ptr+= system_charset_info->scan(ptr, ptrend, MY_SEQ_SPACES); if (!*ptr) { ptr= NULL; @@ -867,8 +867,7 @@ static char *debug_sync_token(char **token_p, uint *token_length_p, *token_p= ptr; /* Find token end. */ - ptr+= system_charset_info->cset->scan(system_charset_info, - ptr, ptrend, MY_SEQ_NONSPACES); + ptr+= system_charset_info->scan(ptr, ptrend, MY_SEQ_NONSPACES); /* Get token length. */ *token_length_p= (uint)(ptr - *token_p); @@ -878,7 +877,7 @@ static char *debug_sync_token(char **token_p, uint *token_length_p, { DBUG_ASSERT(ptr < ptrend); /* Get terminator character length. */ - uint mbspacelen= my_charlen_fix(system_charset_info, ptr, ptrend); + uint mbspacelen= system_charset_info->charlen_fix(ptr, ptrend); /* Terminate token. */ *ptr= '\0'; @@ -887,8 +886,7 @@ static char *debug_sync_token(char **token_p, uint *token_length_p, ptr+= mbspacelen; /* Skip trailing space */ - ptr+= system_charset_info->cset->scan(system_charset_info, - ptr, ptrend, MY_SEQ_SPACES); + ptr+= system_charset_info->scan(ptr, ptrend, MY_SEQ_SPACES); } end: diff --git a/sql/discover.cc b/sql/discover.cc index 3df777c19ba..3e41388ed51 100644 --- a/sql/discover.cc +++ b/sql/discover.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -206,12 +207,12 @@ int extension_based_table_discovery(MY_DIR *dirp, const char *ext_meta, size_t len= (octothorp ? octothorp : ext) - cur->name; if (from != cur && (strlen(from->name) <= len || - my_strnncoll(cs, (uchar*)from->name, len, (uchar*)cur->name, len) || + cs->strnncoll(from->name, len, cur->name, len) || (from->name[len] != FN_EXTCHAR && from->name[len] != '#'))) advance(from, to, cur, skip); - if (my_strnncoll(cs, (uchar*)ext, strlen(ext), - (uchar*)ext_meta, ext_meta_len) == 0) + if (cs->strnncoll(ext, strlen(ext), + ext_meta, ext_meta_len) == 0) { *ext = 0; if (result->add_file(cur->name)) @@ -255,8 +256,8 @@ int ext_table_discovery_simple(MY_DIR *dirp, if (ext) { - if (my_strnncoll(cs, (uchar*)ext, strlen(ext), - (uchar*)reg_ext, reg_ext_length) == 0) + if (cs->strnncoll(ext, strlen(ext), + reg_ext, reg_ext_length) == 0) { *ext = 0; if (result->add_file(cur->name)) diff --git a/sql/events.cc b/sql/events.cc index 242689f8370..38a9bbf3e9e 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2005, 2013, Oracle and/or its affiliates. - Copyright (c) 2017, MariaDB Corporation. + Copyright (c) 2017, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -103,8 +103,8 @@ ulong Events::inited; int sortcmp_lex_string(const LEX_CSTRING *s, const LEX_CSTRING *t, const CHARSET_INFO *cs) { - return cs->coll->strnncollsp(cs, (uchar *) s->str, s->length, - (uchar *) t->str, t->length); + return cs->strnncollsp(s->str, s->length, + t->str, t->length); } diff --git a/sql/field.cc b/sql/field.cc index db8d234f006..1ce49b0bdfa 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2008, 2019, MariaDB + Copyright (c) 2008, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -984,7 +984,7 @@ static bool test_if_important_data(CHARSET_INFO *cs, const char *str, const char *strend) { if (cs != &my_charset_bin) - str+= cs->cset->scan(cs, str, strend, MY_SEQ_SPACES); + str+= cs->scan(str, strend, MY_SEQ_SPACES); return (str < strend); } @@ -1120,15 +1120,15 @@ double Field::pos_in_interval_val_str(Field *min, Field *max, uint data_offset) uchar minp_prefix[sizeof(ulonglong)]; uchar maxp_prefix[sizeof(ulonglong)]; ulonglong mp, minp, maxp; - my_strnxfrm(charset(), mp_prefix, sizeof(mp), - ptr + data_offset, - data_length()); - my_strnxfrm(charset(), minp_prefix, sizeof(minp), - min->ptr + data_offset, - min->data_length()); - my_strnxfrm(charset(), maxp_prefix, sizeof(maxp), - max->ptr + data_offset, - max->data_length()); + charset()->strnxfrm(mp_prefix, sizeof(mp), + ptr + data_offset, + data_length()); + charset()->strnxfrm(minp_prefix, sizeof(minp), + min->ptr + data_offset, + min->data_length()); + charset()->strnxfrm(maxp_prefix, sizeof(maxp), + max->ptr + data_offset, + max->data_length()); mp= char_prefix_to_ulonglong(mp_prefix); minp= char_prefix_to_ulonglong(minp_prefix); maxp= char_prefix_to_ulonglong(maxp_prefix); @@ -1582,7 +1582,7 @@ Value_source::Converter_string_to_number::check_edom_and_truncation(THD *thd, @note This is called after one has called one of the following functions: - strntoull10rnd() - - my_strntod() + - strntod() - str2my_decimal() @retval @@ -1662,9 +1662,9 @@ bool Field_num::get_int(CHARSET_INFO *cs, const char *from, size_t len, char *end; int error; - *rnd= (longlong) cs->cset->strntoull10rnd(cs, from, len, - unsigned_flag, &end, - &error); + *rnd= (longlong) cs->strntoull10rnd(from, len, + unsigned_flag, &end, + &error); if (unsigned_flag) { @@ -1703,7 +1703,7 @@ double Field_real::get_double(const char *str, size_t length, CHARSET_INFO *cs, int *error) { char *end; - double nr= my_strntod(cs,(char*) str, length, &end, error); + double nr= cs->strntod((char*) str, length, &end, error); if (unlikely(*error)) { set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); @@ -1760,10 +1760,10 @@ String *Field::val_int_as_str(String *val_buffer, bool unsigned_val) if (val_buffer->alloc(MY_INT64_NUM_DECIMAL_DIGITS)) return 0; - length= (uint) (*cs->cset->longlong10_to_str)(cs, (char*) val_buffer->ptr(), - MY_INT64_NUM_DECIMAL_DIGITS, - unsigned_val ? 10 : -10, - value); + length= (uint) (cs->longlong10_to_str)((char*) val_buffer->ptr(), + MY_INT64_NUM_DECIMAL_DIGITS, + unsigned_val ? 10 : -10, + value); val_buffer->length(length); return val_buffer; } @@ -1801,8 +1801,7 @@ void Field::hash(ulong *nr, ulong *nr2) else { uint len= pack_length(); - CHARSET_INFO *cs= sort_charset(); - cs->coll->hash_sort(cs, ptr, len, nr, nr2); + sort_charset()->hash_sort(ptr, len, nr, nr2); } } @@ -2207,7 +2206,7 @@ bool Field_str::test_if_equality_guarantees_uniqueness(const Item *item) const SELECT * FROM t1 WHERE varchar_column=DATE'2001-01-01' return non-unuque values, e.g. '2001-01-01' and '2001-01-01x'. */ - if (!field_charset()->coll->propagate(field_charset(), 0, 0) || + if (!field_charset()->propagate(0, 0) || item->cmp_type() != STRING_RESULT) return false; /* @@ -3035,8 +3034,7 @@ double Field_decimal::val_real(void) DBUG_ASSERT(marked_for_read()); int not_used; char *end_not_used; - return my_strntod(&my_charset_bin, (char*) ptr, field_length, &end_not_used, - ¬_used); + return my_charset_bin.strntod((char*) ptr, field_length, &end_not_used, ¬_used); } longlong Field_decimal::val_int(void) @@ -3044,10 +3042,8 @@ longlong Field_decimal::val_int(void) DBUG_ASSERT(marked_for_read()); int not_used; if (unsigned_flag) - return my_strntoull(&my_charset_bin, (char*) ptr, field_length, 10, NULL, - ¬_used); - return my_strntoll(&my_charset_bin, (char*) ptr, field_length, 10, NULL, - ¬_used); + return my_charset_bin.strntoull((char*) ptr, field_length, 10, NULL, ¬_used); + return my_charset_bin.strntoll((char*) ptr, field_length, 10, NULL, ¬_used); } @@ -4115,7 +4111,7 @@ String *Field_int::val_str_from_long(String *val_buffer, uint mlength= MY_MAX(field_length + 1, max_char_length * cs->mbmaxlen); val_buffer->alloc(mlength); char *to=(char*) val_buffer->ptr(); - length= (uint) cs->cset->long10_to_str(cs, to, mlength, radix, nr); + length= (uint) cs->long10_to_str(to, mlength, radix, nr); val_buffer->length(length); if (zerofill) prepend_zeros(val_buffer); /* purecov: inspected */ @@ -4334,7 +4330,7 @@ int Field_longlong::store(const char *from,size_t len,CHARSET_INFO *cs) char *end; ulonglong tmp; - tmp= cs->cset->strntoull10rnd(cs,from,len,unsigned_flag,&end,&error); + tmp= cs->strntoull10rnd(from, len, unsigned_flag, &end, &error); if (unlikely(error == MY_ERRNO_ERANGE)) { set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1); @@ -4422,8 +4418,8 @@ String *Field_longlong::val_str(String *val_buffer, longlong j; j=sint8korr(ptr); - length=(uint) (cs->cset->longlong10_to_str)(cs,to,mlength, - unsigned_flag ? 10 : -10, j); + length=(uint) (cs->longlong10_to_str)(to, mlength, + unsigned_flag ? 10 : -10, j); val_buffer->length(length); if (zerofill) prepend_zeros(val_buffer); @@ -6240,7 +6236,7 @@ int Field_year::store(const char *from, size_t len,CHARSET_INFO *cs) DBUG_ASSERT(marked_for_write_or_computed()); char *end; int error; - longlong nr= cs->cset->strntoull10rnd(cs, from, len, 0, &end, &error); + longlong nr= cs->strntoull10rnd(from, len, 0, &end, &error); if (nr < 0 || (nr >= 100 && nr <= 1900) || nr > 2155 || error == MY_ERRNO_ERANGE) @@ -7052,10 +7048,9 @@ int Field_string::store(const char *from, size_t length,CHARSET_INFO *cs) /* Append spaces if the string was shorter than the field. */ if (copy_length < field_length) - field_charset()->cset->fill(field_charset(), - (char*) ptr + copy_length, - field_length - copy_length, - field_charset()->pad_char); + field_charset()->fill((char*) ptr + copy_length, + field_length - copy_length, + field_charset()->pad_char); return rc; } @@ -7065,12 +7060,9 @@ int Field_str::store(longlong nr, bool unsigned_val) { char buff[64]; uint length; - length= (uint) (field_charset()->cset->longlong10_to_str)(field_charset(), - buff, - sizeof(buff), - (unsigned_val ? 10: - -10), - nr); + length= (uint) (field_charset()->longlong10_to_str)(buff, sizeof(buff), + (unsigned_val ? 10: -10), + nr); return store(buff, length, field_charset()); } @@ -7244,12 +7236,10 @@ String *Field_string::val_str(String *val_buffer __attribute__((unused)), size_t length; if (get_thd()->variables.sql_mode & MODE_PAD_CHAR_TO_FULL_LENGTH) - length= my_charpos(field_charset(), ptr, ptr + field_length, - Field_string::char_length()); + length= field_charset()->charpos(ptr, ptr + field_length, + Field_string::char_length()); else - length= field_charset()->cset->lengthsp(field_charset(), - (const char*) ptr, - field_length); + length= field_charset()->lengthsp((const char*) ptr, field_length); val_ptr->set((const char*) ptr, length, field_charset()); return val_ptr; } @@ -7310,8 +7300,8 @@ int Field_string::cmp(const uchar *a_ptr, const uchar *b_ptr) const if (mbmaxlen() != 1) { size_t char_len= Field_string::char_length(); - a_len= my_charpos(field_charset(), a_ptr, a_ptr + field_length, char_len); - b_len= my_charpos(field_charset(), b_ptr, b_ptr + field_length, char_len); + 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; @@ -7319,9 +7309,8 @@ int Field_string::cmp(const uchar *a_ptr, const uchar *b_ptr) const 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(), - a_ptr, a_len, - b_ptr, b_len); + return field_charset()->strnncollsp(a_ptr, a_len, + b_ptr, b_len); } @@ -7330,13 +7319,11 @@ void Field_string::sort_string(uchar *to,uint length) #ifdef DBUG_ASSERT_EXISTS size_t tmp= #endif - field_charset()->coll->strnxfrm(field_charset(), - to, length, - char_length() * - field_charset()->strxfrm_multiply, - ptr, field_length, - MY_STRXFRM_PAD_WITH_SPACE | - MY_STRXFRM_PAD_TO_MAXLEN); + field_charset()->strnxfrm(to, length, + char_length() * field_charset()->strxfrm_multiply, + ptr, field_length, + MY_STRXFRM_PAD_WITH_SPACE | + MY_STRXFRM_PAD_TO_MAXLEN); DBUG_ASSERT(tmp == length); } @@ -7484,15 +7471,14 @@ uint Field_string::max_packed_col_length(uint max_length) uint Field_string::get_key_image(uchar *buff, uint length, imagetype type_arg) { - size_t bytes= my_charpos(field_charset(), (char*) ptr, - (char*) ptr + field_length, - length / mbmaxlen()); + size_t bytes= field_charset()->charpos((char*) ptr, + (char*) ptr + field_length, + length / mbmaxlen()); memcpy(buff, ptr, bytes); if (bytes < length) - field_charset()->cset->fill(field_charset(), - (char*) buff + bytes, - length - bytes, - field_charset()->pad_char); + field_charset()->fill((char*) buff + bytes, + length - bytes, + field_charset()->pad_char); return (uint)bytes; } @@ -7650,9 +7636,8 @@ int Field_varstring::cmp_max(const uchar *a_ptr, const uchar *b_ptr, } set_if_smaller(a_length, max_len); set_if_smaller(b_length, max_len); - diff= field_charset()->coll->strnncollsp(field_charset(), - a_ptr + length_bytes, a_length, - b_ptr + length_bytes, b_length); + diff= field_charset()->strnncollsp(a_ptr + length_bytes, a_length, + b_ptr + length_bytes, b_length); return diff; } @@ -7667,14 +7652,14 @@ int Field_varstring::key_cmp(const uchar *key_ptr, uint max_key_length) const size_t length= length_bytes == 1 ? (uint) *ptr : uint2korr(ptr); size_t local_char_length= max_key_length / mbmaxlen(); - local_char_length= my_charpos(field_charset(), ptr + length_bytes, - ptr + length_bytes + length, local_char_length); + local_char_length= field_charset()->charpos(ptr + length_bytes, + ptr + length_bytes + length, + local_char_length); set_if_smaller(length, local_char_length); - return field_charset()->coll->strnncollsp(field_charset(), - ptr + length_bytes, - length, - key_ptr + HA_KEY_BLOB_LENGTH, - uint2korr(key_ptr)); + return field_charset()->strnncollsp(ptr + length_bytes, + length, + key_ptr + HA_KEY_BLOB_LENGTH, + uint2korr(key_ptr)); } @@ -7688,11 +7673,8 @@ int Field_varstring::key_cmp(const uchar *key_ptr, uint max_key_length) const int Field_varstring::key_cmp(const uchar *a,const uchar *b) const { - return field_charset()->coll->strnncollsp(field_charset(), - a + HA_KEY_BLOB_LENGTH, - uint2korr(a), - b + HA_KEY_BLOB_LENGTH, - uint2korr(b)); + return field_charset()->strnncollsp(a + HA_KEY_BLOB_LENGTH, uint2korr(a), + b + HA_KEY_BLOB_LENGTH, uint2korr(b)); } @@ -7715,13 +7697,11 @@ void Field_varstring::sort_string(uchar *to,uint length) #ifdef DBUG_ASSERT_EXISTS size_t rc= #endif - field_charset()->coll->strnxfrm(field_charset(), - to, length, - char_length() * - field_charset()->strxfrm_multiply, - (const uchar*) buf.ptr(), buf.length(), - MY_STRXFRM_PAD_WITH_SPACE | - MY_STRXFRM_PAD_TO_MAXLEN); + field_charset()->strnxfrm(to, length, + char_length() * field_charset()->strxfrm_multiply, + (const uchar *) buf.ptr(), buf.length(), + MY_STRXFRM_PAD_WITH_SPACE | + MY_STRXFRM_PAD_TO_MAXLEN); DBUG_ASSERT(rc == length); } @@ -7979,8 +7959,7 @@ void Field_varstring::hash(ulong *nr, ulong *nr2) else { uint len= length_bytes == 1 ? (uint) *ptr : uint2korr(ptr); - CHARSET_INFO *cs= charset(); - cs->coll->hash_sort(cs, ptr + length_bytes, len, nr, nr2); + charset()->hash_sort(ptr + length_bytes, len, nr, nr2); } } @@ -8421,8 +8400,7 @@ my_decimal *Field_blob::val_decimal(my_decimal *decimal_value) int Field_blob::cmp(const uchar *a,uint32 a_length, const uchar *b, uint32 b_length) const { - return field_charset()->coll->strnncollsp(field_charset(), - a, a_length, b, b_length); + return field_charset()->strnncollsp(a, a_length, b, b_length); } @@ -8465,8 +8443,8 @@ uint Field_blob::get_key_image_itRAW(uchar *buff, uint length) size_t blob_length= get_length(ptr); uchar *blob= get_ptr(); size_t local_char_length= length / mbmaxlen(); - local_char_length= my_charpos(field_charset(), blob, blob + blob_length, - local_char_length); + local_char_length= field_charset()->charpos(blob, blob + blob_length, + local_char_length); set_if_smaller(blob_length, local_char_length); if (length > blob_length) @@ -8499,8 +8477,8 @@ int Field_blob::key_cmp(const uchar *key_ptr, uint max_key_length) const memcpy(&blob1, ptr+packlength, sizeof(char*)); CHARSET_INFO *cs= charset(); size_t local_char_length= max_key_length / cs->mbmaxlen; - local_char_length= my_charpos(cs, blob1, blob1+blob_length, - local_char_length); + local_char_length= cs->charpos(blob1, blob1+blob_length, + local_char_length); set_if_smaller(blob_length, local_char_length); return Field_blob::cmp(blob1, (uint32)blob_length, key_ptr+HA_KEY_BLOB_LENGTH, @@ -8574,10 +8552,10 @@ void Field_blob::sort_string(uchar *to,uint length) #ifdef DBUG_ASSERT_EXISTS size_t rc= #endif - field_charset()->coll->strnxfrm(field_charset(), to, length, length, - (const uchar*) buf.ptr(), buf.length(), - MY_STRXFRM_PAD_WITH_SPACE | - MY_STRXFRM_PAD_TO_MAXLEN); + field_charset()->strnxfrm(to, length, length, + (const uchar *) buf.ptr(), buf.length(), + MY_STRXFRM_PAD_WITH_SPACE | + MY_STRXFRM_PAD_TO_MAXLEN); DBUG_ASSERT(rc == length); } } @@ -8855,7 +8833,7 @@ int Field_enum::store(const char *from,size_t length,CHARSET_INFO *cs) } /* Remove end space */ - length= (uint)field_charset()->cset->lengthsp(field_charset(), from, length); + length= (uint) field_charset()->lengthsp(from, length); uint tmp=find_type2(typelib, from, length, field_charset()); if (!tmp) { @@ -8863,7 +8841,7 @@ int Field_enum::store(const char *from,size_t length,CHARSET_INFO *cs) { /* This is for reading numbers with LOAD DATA INFILE */ char *end; - tmp=(uint) my_strntoul(cs,from,length,10,&end,&err); + tmp=(uint) cs->strntoul(from,length,10,&end,&err); if (err || end != from+length || tmp > typelib->count) { tmp=0; @@ -9045,7 +9023,7 @@ int Field_set::store(const char *from,size_t length,CHARSET_INFO *cs) { /* This is for reading numbers with LOAD DATA INFILE */ char *end; - tmp=my_strntoull(cs,from,length,10,&end,&err); + tmp= cs->strntoull(from,length,10,&end,&err); if (err || end != from+length || tmp > (ulonglong) (((longlong) 1 << typelib->count) - (longlong) 1)) { @@ -9176,11 +9154,8 @@ static bool compare_type_names(CHARSET_INFO *charset, const TYPELIB *t1, const TYPELIB *t2) { for (uint i= 0; i < t1->count; i++) - if (my_strnncoll(charset, - (const uchar*) t1->type_names[i], - t1->type_lengths[i], - (const uchar*) t2->type_names[i], - t2->type_lengths[i])) + if (charset->strnncoll(t1->type_names[i], t1->type_lengths[i], + t2->type_names[i], t2->type_lengths[i])) return FALSE; return TRUE; } @@ -9420,7 +9395,7 @@ void Field_bit::hash(ulong *nr, ulong *nr2) longlong value= Field_bit::val_int(); uchar tmp[8]; mi_int8store(tmp,value); - cs->coll->hash_sort(cs, tmp, 8, nr, nr2); + cs->hash_sort(tmp, 8, nr, nr2); } } @@ -9940,10 +9915,9 @@ bool Column_definition::create_interval_from_interval_list(MEM_ROOT *mem_root, StringBuffer<64> conv; char comma_buf[5]; /* 5 bytes for 'filename' charset */ DBUG_ASSERT(sizeof(comma_buf) >= charset->mbmaxlen); - int comma_length= charset->cset->wc_mb(charset, ',', - (uchar*) comma_buf, - (uchar*) comma_buf + - sizeof(comma_buf)); + int comma_length= charset->wc_mb(',', + (uchar*) comma_buf, + (uchar*) comma_buf + sizeof(comma_buf)); DBUG_ASSERT(comma_length >= 0 && comma_length <= (int) sizeof(comma_buf)); if (!multi_alloc_root(mem_root, @@ -9982,13 +9956,13 @@ bool Column_definition::create_interval_from_interval_list(MEM_ROOT *mem_root, goto err; // EOM // Strip trailing spaces. - value.length= charset->cset->lengthsp(charset, value.str, value.length); + value.length= charset->lengthsp(value.str, value.length); ((char*) value.str)[value.length]= '\0'; if (real_field_type() == MYSQL_TYPE_SET) { - if (charset->coll->instr(charset, value.str, value.length, - comma_buf, comma_length, NULL, 0)) + if (charset->instr(value.str, value.length, + comma_buf, comma_length, NULL, 0)) { ErrConvString err(tmp); my_error(ER_ILLEGAL_VALUE_FOR_TYPE, MYF(0), "set", err.ptr()); @@ -10989,7 +10963,7 @@ void Field_string::print_key_value(String *out, uint32 length) { if (charset() == &my_charset_bin) { - size_t len= field_charset()->cset->lengthsp(field_charset(), (const char*) ptr, length); + size_t len= field_charset()->lengthsp((const char*) ptr, length); print_key_value_binary(out, ptr, static_cast<uint32>(len)); } else diff --git a/sql/field.h b/sql/field.h index df0f97776fb..4a8eec35b05 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1,7 +1,7 @@ #ifndef FIELD_INCLUDED #define FIELD_INCLUDED /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2008, 2019, MariaDB Corporation. + Copyright (c) 2008, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -204,7 +204,7 @@ protected: public: Converter_strntod(CHARSET_INFO *cs, const char *str, size_t length) { - m_result= my_strntod(cs, (char *) str, length, &m_end_of_num, &m_error); + m_result= cs->strntod((char *) str, length, &m_end_of_num, &m_error); // strntod() does not set an error if the input string was empty m_edom= m_error !=0 || str == m_end_of_num; } @@ -224,7 +224,7 @@ protected: public: Converter_strntoll(CHARSET_INFO *cs, const char *str, size_t length) { - m_result= my_strntoll(cs, str, length, 10, &m_end_of_num, &m_error); + m_result= cs->strntoll(str, length, 10, &m_end_of_num, &m_error); /* All non-zero errors means EDOM error. strntoll() does not set an error if the input string was empty. @@ -241,7 +241,7 @@ protected: Converter_strtoll10(CHARSET_INFO *cs, const char *str, size_t length) { m_end_of_num= (char *) str + length; - m_result= (*(cs->cset->strtoll10))(cs, str, &m_end_of_num, &m_error); + m_result= cs->strtoll10(str, &m_end_of_num, &m_error); /* Negative error means "good negative number". Only a positive m_error value means a real error. @@ -3924,8 +3924,7 @@ public: Copy_func *get_copy_func(const Field *from) const override; int reset() override { - charset()->cset->fill(charset(),(char*) ptr, field_length, - (has_charset() ? ' ' : 0)); + charset()->fill((char*) ptr, field_length, (has_charset() ? ' ' : 0)); return 0; } int store(const char *to,size_t length,CHARSET_INFO *charset) override; @@ -5016,7 +5015,7 @@ class Column_definition: public Sql_alloc, for (pos= interval->type_names, len= interval->type_lengths; *pos ; pos++, len++) { - size_t length= charset->cset->numchars(charset, *pos, *pos + *len); + size_t length= charset->numchars(*pos, *pos + *len); DBUG_ASSERT(length < UINT_MAX32); *tot_length+= (uint) length; set_if_bigger(*max_length, (uint32)length); diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 80a2ee1b06e..65f0e4f535e 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2010, 2018, MariaDB Corporation + Copyright (c) 2010, 2020, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -465,10 +465,9 @@ static void do_cut_string(Copy_field *copy) memcpy(copy->to_ptr,copy->from_ptr,copy->to_length); /* Check if we loosed any important characters */ - if (cs->cset->scan(cs, - (char*) copy->from_ptr + copy->to_length, - (char*) copy->from_ptr + copy->from_length, - MY_SEQ_SPACES) < copy->from_length - copy->to_length) + if (cs->scan((char*) copy->from_ptr + copy->to_length, + (char*) copy->from_ptr + copy->from_length, + MY_SEQ_SPACES) < copy->from_length - copy->to_length) { copy->to_field->set_warning(Sql_condition::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); @@ -496,9 +495,9 @@ static void do_cut_string_complex(Copy_field *copy) /* Check if we lost any important characters */ if (unlikely(prefix.well_formed_error_pos() || - cs->cset->scan(cs, (char*) copy->from_ptr + copy_length, - (char*) from_end, - MY_SEQ_SPACES) < + cs->scan((char*) copy->from_ptr + copy_length, + (char*) from_end, + MY_SEQ_SPACES) < (copy->from_length - copy_length))) { copy->to_field->set_warning(Sql_condition::WARN_LEVEL_WARN, @@ -506,8 +505,8 @@ static void do_cut_string_complex(Copy_field *copy) } if (copy_length < copy->to_length) - cs->cset->fill(cs, (char*) copy->to_ptr + copy_length, - copy->to_length - copy_length, ' '); + cs->fill((char*) copy->to_ptr + copy_length, + copy->to_length - copy_length, ' '); } @@ -517,8 +516,8 @@ static void do_expand_binary(Copy_field *copy) { CHARSET_INFO *cs= copy->from_field->charset(); memcpy(copy->to_ptr,copy->from_ptr,copy->from_length); - cs->cset->fill(cs, (char*) copy->to_ptr+copy->from_length, - copy->to_length-copy->from_length, '\0'); + cs->fill((char*) copy->to_ptr+copy->from_length, + copy->to_length-copy->from_length, '\0'); } @@ -527,8 +526,8 @@ static void do_expand_string(Copy_field *copy) { CHARSET_INFO *cs= copy->from_field->charset(); memcpy(copy->to_ptr,copy->from_ptr,copy->from_length); - cs->cset->fill(cs, (char*) copy->to_ptr+copy->from_length, - copy->to_length-copy->from_length, ' '); + cs->fill((char*) copy->to_ptr+copy->from_length, + copy->to_length-copy->from_length, ' '); } diff --git a/sql/filesort.cc b/sql/filesort.cc index 7da2fef232c..763f9f59246 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2009, 2015, MariaDB + Copyright (c) 2009, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1072,12 +1072,11 @@ Type_handler_string_result::make_sort_key(uchar *to, Item *item, #ifdef DBUG_ASSERT_EXISTS size_t tmp_length= #endif - cs->coll->strnxfrm(cs, to, sort_field->length, - item->max_char_length() * - cs->strxfrm_multiply, - (uchar*) res->ptr(), res->length(), - MY_STRXFRM_PAD_WITH_SPACE | - MY_STRXFRM_PAD_TO_MAXLEN); + cs->strnxfrm(to, sort_field->length, + item->max_char_length() * cs->strxfrm_multiply, + (uchar*) res->ptr(), res->length(), + MY_STRXFRM_PAD_WITH_SPACE | + MY_STRXFRM_PAD_TO_MAXLEN); DBUG_ASSERT(tmp_length == sort_field->length); } else @@ -1098,9 +1097,9 @@ Type_handler_string_result::make_sort_key(uchar *to, Item *item, store_length(to + sort_field_length, length, sort_field->suffix_length); } /* apply cs->sort_order for case-insensitive comparison if needed */ - my_strnxfrm(cs,(uchar*)to,length,(const uchar*)res->ptr(),length); + cs->strnxfrm((uchar*)to, length, (const uchar*) res->ptr(), length); char fill_char= ((cs->state & MY_CS_BINSORT) ? (char) 0 : ' '); - cs->cset->fill(cs, (char *)to+length,diff,fill_char); + cs->fill((char *) to + length, diff, fill_char); } } @@ -2017,7 +2016,7 @@ Type_handler_string_result::sortlength(THD *thd, set_if_smaller(sortorder->length, thd->variables.max_sort_length); if (use_strnxfrm((cs= item->collation.collation))) { - sortorder->length= (uint)cs->coll->strnxfrmlen(cs, sortorder->length); + sortorder->length= (uint) cs->strnxfrmlen(sortorder->length); } else if (cs == &my_charset_bin) { @@ -2109,7 +2108,7 @@ sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length, if (use_strnxfrm((cs=sortorder->field->sort_charset()))) { *multi_byte_charset= true; - sortorder->length= (uint)cs->coll->strnxfrmlen(cs, sortorder->length); + sortorder->length= (uint) cs->strnxfrmlen(sortorder->length); } if (sortorder->field->maybe_null()) length++; // Place for NULL marker diff --git a/sql/gstream.cc b/sql/gstream.cc index 4678e85019e..b743140ba59 100644 --- a/sql/gstream.cc +++ b/sql/gstream.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -107,8 +108,7 @@ bool Gis_read_stream::get_next_number(double *d) return 1; } - *d = my_strntod(m_charset, (char *)m_cur, - (uint) (m_limit-m_cur), &endptr, &err); + *d = m_charset->strntod((char *)m_cur, (uint) (m_limit-m_cur), &endptr, &err); if (err) return 1; if (endptr) diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 182621e6de4..929cb87fbda 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2005, 2019, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB + Copyright (c) 2009, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -9697,8 +9697,7 @@ uint32 ha_partition::calculate_key_hash_value(Field **field_array) } /* Force this to my_hash_sort_bin, which was used in 5.1! */ uint len= field->pack_length(); - my_charset_bin.coll->hash_sort(&my_charset_bin, field->ptr, len, - &nr1, &nr2); + my_charset_bin.hash_sort(field->ptr, len, &nr1, &nr2); /* Done with this field, continue with next one. */ continue; } @@ -9721,8 +9720,7 @@ uint32 ha_partition::calculate_key_hash_value(Field **field_array) } /* Force this to my_hash_sort_bin, which was used in 5.1! */ uint len= field->pack_length(); - my_charset_latin1.coll->hash_sort(&my_charset_latin1, field->ptr, - len, &nr1, &nr2); + my_charset_latin1.hash_sort(field->ptr, len, &nr1, &nr2); continue; } /* New types in mysql-5.6. */ diff --git a/sql/handler.cc b/sql/handler.cc index 0132f2dd027..ac6b4f3f453 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB Corporation. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -182,8 +182,7 @@ plugin_ref ha_resolve_by_name(THD *thd, const LEX_CSTRING *name, plugin_ref plugin; redo: - /* my_strnncoll is a macro and gcc doesn't do early expansion of macro */ - if (thd && !my_charset_latin1.coll->strnncoll(&my_charset_latin1, + if (thd && !my_charset_latin1.strnncoll( (const uchar *)name->str, name->length, (const uchar *)STRING_WITH_LEN("DEFAULT"), 0)) return tmp_table ? ha_default_tmp_plugin(thd) : ha_default_plugin(thd); @@ -205,7 +204,7 @@ redo: */ for (table_alias= sys_table_aliases; table_alias->str; table_alias+= 2) { - if (!my_strnncoll(&my_charset_latin1, + if (!my_charset_latin1.strnncoll( (const uchar *)name->str, name->length, (const uchar *)table_alias->str, table_alias->length)) { @@ -5587,13 +5586,13 @@ static int cmp_file_names(const void *a, const void *b) CHARSET_INFO *cs= character_set_filesystem; char *aa= ((FILEINFO *)a)->name; char *bb= ((FILEINFO *)b)->name; - return my_strnncoll(cs, (uchar*)aa, strlen(aa), (uchar*)bb, strlen(bb)); + return cs->strnncoll(aa, strlen(aa), bb, strlen(bb)); } static int cmp_table_names(LEX_CSTRING * const *a, LEX_CSTRING * const *b) { - return my_strnncoll(&my_charset_bin, (uchar*)((*a)->str), (*a)->length, - (uchar*)((*b)->str), (*b)->length); + return my_charset_bin.strnncoll((*a)->str, (*a)->length, + (*b)->str, (*b)->length); } #ifndef DBUG_OFF @@ -5627,8 +5626,8 @@ bool Discovered_table_list::add_table(const char *tname, size_t tlen) custom discover_table_names() method, that calls add_table() directly). Note: avoid comparing the same name twice (here and in add_file). */ - if (wild && my_wildcmp(table_alias_charset, tname, tname + tlen, wild, wend, - wild_prefix, wild_one, wild_many)) + if (wild && table_alias_charset->wildcmp(tname, tname + tlen, wild, wend, + wild_prefix, wild_one, wild_many)) return 0; LEX_CSTRING *name= thd->make_clex_string(tname, tlen); diff --git a/sql/item.cc b/sql/item.cc index 5dd10c292f9..d837e8b5719 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2018, Oracle and/or its affiliates. - Copyright (c) 2010, 2019, MariaDB Corporation + Copyright (c) 2010, 2020, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1100,9 +1100,9 @@ void Item::set_name(THD *thd, const char *str, size_t length, CHARSET_INFO *cs) } const char *str_start= str; - if (!cs->ctype || cs->mbminlen > 1) + if (!cs->m_ctype || cs->mbminlen > 1) { - str+= cs->cset->scan(cs, str, str + length, MY_SEQ_SPACES); + str+= cs->scan(str, str + length, MY_SEQ_SPACES); length-= (uint)(str - str_start); } else @@ -4826,16 +4826,16 @@ double Item_copy_string::val_real() int err_not_used; char *end_not_used; return (null_value ? 0.0 : - my_strntod(str_value.charset(), (char*) str_value.ptr(), - str_value.length(), &end_not_used, &err_not_used)); + str_value.charset()->strntod((char*) str_value.ptr(), str_value.length(), + &end_not_used, &err_not_used)); } longlong Item_copy_string::val_int() { int err; - return null_value ? 0 : my_strntoll(str_value.charset(),str_value.ptr(), - str_value.length(), 10, (char**) 0, - &err); + return null_value ? 0 : str_value.charset()->strntoll(str_value.ptr(), + str_value.length(), 10, (char**) 0, + &err); } @@ -6285,7 +6285,7 @@ String_copier_for_item::copy_with_warn(CHARSET_INFO *dstcs, String *dst, if (unlikely(pos= cannot_convert_error_pos())) { char buf[16]; - int mblen= my_charlen(srccs, pos, src + src_length); + int mblen= srccs->charlen(pos, src + src_length); DBUG_ASSERT(mblen > 0 && mblen * 2 + 1 <= (int) sizeof(buf)); octet2hex(buf, pos, mblen); push_warning_printf(m_thd, Sql_condition::WARN_LEVEL_WARN, @@ -6810,8 +6810,7 @@ Item_float::Item_float(THD *thd, const char *str_arg, size_t length): { int error; char *end_not_used; - value= my_strntod(&my_charset_bin, (char*) str_arg, length, &end_not_used, - &error); + value= my_charset_bin.strntod((char*) str_arg, length, &end_not_used, &error); if (unlikely(error)) { char tmp[NAME_LEN + 1]; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index b54a78aca97..6df2b5dbd3a 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB + Copyright (c) 2009, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -5603,7 +5603,7 @@ longlong Item_func_like::val_int() null_value=0; if (canDoTurboBM) return turboBM_matches(res->ptr(), res->length()) ? !negated : negated; - return my_wildcmp(cmp_collation.collation, + return cmp_collation.collation->wildcmp( res->ptr(),res->ptr()+res->length(), res2->ptr(),res2->ptr()+res2->length(), escape,wild_one,wild_many) ? negated : !negated; @@ -5696,14 +5696,14 @@ bool fix_escape_item(THD *thd, Item *escape_item, String *tmp_str, return TRUE; } - if (use_mb(cmp_cs)) + if (cmp_cs->use_mb()) { CHARSET_INFO *cs= escape_str->charset(); my_wc_t wc; - int rc= cs->cset->mb_wc(cs, &wc, - (const uchar*) escape_str_ptr, - (const uchar*) escape_str_ptr + - escape_str->length()); + int rc= cs->mb_wc(&wc, + (const uchar*) escape_str_ptr, + (const uchar*) escape_str_ptr + + escape_str->length()); *escape= (int) (rc > 0 ? wc : '\\'); } else @@ -5771,7 +5771,7 @@ bool Item_func_like::fix_fields(THD *thd, Item **ref) { const char* tmp = first + 1; for (; *tmp != wild_many && *tmp != wild_one && *tmp != escape; tmp++) ; - canDoTurboBM = (tmp == last) && !use_mb(args[0]->collation.collation); + canDoTurboBM = (tmp == last) && !args[0]->collation.collation->use_mb(); } if (canDoTurboBM) { @@ -6018,10 +6018,9 @@ bool Regexp_processor_pcre::exec(String *str, int offset, /* Convert byte offset into character offset. */ - m_SubStrVec[i]= (int) str->charset()->cset->numchars(str->charset(), - str->ptr(), - str->ptr() + - m_SubStrVec[i]); + m_SubStrVec[i]= (int) str->charset()->numchars(str->ptr(), + str->ptr() + + m_SubStrVec[i]); } } return false; diff --git a/sql/item_func.cc b/sql/item_func.cc index 21ed478f24a..0419d55cc58 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB + Copyright (c) 2009, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1753,9 +1753,9 @@ static void calc_hash_for_unique(ulong &nr1, ulong &nr2, String *str) uchar l[4]; int4store(l, str->length()); cs= str->charset(); - cs->coll->hash_sort(cs, l, sizeof(l), &nr1, &nr2); + cs->hash_sort(l, sizeof(l), &nr1, &nr2); cs= str->charset(); - cs->coll->hash_sort(cs, (uchar *)str->ptr(), str->length(), &nr1, &nr2); + cs->hash_sort((uchar *)str->ptr(), str->length(), &nr1, &nr2); } longlong Item_func_hash::val_int() @@ -2962,11 +2962,10 @@ longlong Item_func_locate::val_int() if (!b->length()) // Found empty string at start return start + 1; - if (!cmp_collation.collation->coll->instr(cmp_collation.collation, - a->ptr()+start, - (uint) (a->length()-start), - b->ptr(), b->length(), - &match, 1)) + if (!cmp_collation.collation->instr(a->ptr() + start, + (uint) (a->length() - start), + b->ptr(), b->length(), + &match, 1)) return 0; return (longlong) match.mb_len + start0 + 1; } @@ -3079,7 +3078,7 @@ longlong Item_func_ord::val_int() null_value=0; if (!res->length()) return 0; #ifdef USE_MB - if (use_mb(res->charset())) + if (res->use_mb()) { const char *str=res->ptr(); uint32 n=0, l=my_ismbchar(res->charset(),str,str+res->length()); @@ -3165,14 +3164,14 @@ longlong Item_func_find_in_set::val_int() const char *str_begin= buffer->ptr(); const char *str_end= buffer->ptr(); const char *real_end= str_end+buffer->length(); - const uchar *find_str= (const uchar *) find->ptr(); + const char *find_str= find->ptr(); uint find_str_len= find->length(); int position= 0; while (1) { int symbol_len; - if ((symbol_len= cs->cset->mb_wc(cs, &wc, (uchar*) str_end, - (uchar*) real_end)) > 0) + if ((symbol_len= cs->mb_wc(&wc, (uchar*) str_end, + (uchar*) real_end)) > 0) { const char *substr_end= str_end + symbol_len; bool is_last_item= (substr_end == real_end); @@ -3182,9 +3181,8 @@ longlong Item_func_find_in_set::val_int() position++; if (is_last_item && !is_separator) str_end= substr_end; - if (!my_strnncoll(cs, (const uchar *) str_begin, - (uint) (str_end - str_begin), - find_str, find_str_len)) + if (!cs->strnncoll(str_begin, (uint) (str_end - str_begin), + find_str, find_str_len)) return (longlong) position; else str_begin= substr_end; @@ -5645,9 +5643,8 @@ bool Item_func_get_system_var::fix_length_and_dec() (char*) var->value_ptr(current_thd, var_type, &component) : *(char**) var->value_ptr(current_thd, var_type, &component); if (cptr) - max_length= (uint32)system_charset_info->cset->numchars(system_charset_info, - cptr, - cptr + strlen(cptr)); + max_length= (uint32) system_charset_info->numchars(cptr, + cptr + strlen(cptr)); mysql_mutex_unlock(&LOCK_global_system_variables); collation.set(system_charset_info, DERIVATION_SYSCONST); max_length*= system_charset_info->mbmaxlen; @@ -5657,9 +5654,8 @@ bool Item_func_get_system_var::fix_length_and_dec() { mysql_mutex_lock(&LOCK_global_system_variables); LEX_STRING *ls= ((LEX_STRING*)var->value_ptr(current_thd, var_type, &component)); - max_length= (uint32)system_charset_info->cset->numchars(system_charset_info, - ls->str, - ls->str + ls->length); + max_length= (uint32) system_charset_info->numchars(ls->str, + ls->str + ls->length); mysql_mutex_unlock(&LOCK_global_system_variables); collation.set(system_charset_info, DERIVATION_SYSCONST); max_length*= system_charset_info->mbmaxlen; diff --git a/sql/item_func.h b/sql/item_func.h index ecdbd4c30ed..dced158bb86 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1,7 +1,7 @@ #ifndef ITEM_FUNC_INCLUDED #define ITEM_FUNC_INCLUDED /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2009, 2016, MariaDB + Copyright (c) 2009, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2574,15 +2574,15 @@ public: char *end_not_used; String *res; res= val_str(&str_value); - return res ? my_strntod(res->charset(),(char*) res->ptr(), - res->length(), &end_not_used, &err_not_used) : 0.0; + return res ? res->charset()->strntod((char*) res->ptr(), res->length(), + &end_not_used, &err_not_used) : 0.0; } longlong val_int() { int err_not_used; String *res; res=val_str(&str_value); - return res ? my_strntoll(res->charset(),res->ptr(),res->length(),10, - (char**) 0, &err_not_used) : (longlong) 0; + return res ? res->charset()->strntoll(res->ptr(),res->length(),10, + (char**) 0, &err_not_used) : (longlong) 0; } my_decimal *val_decimal(my_decimal *dec_buf) { diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index aa3993e57df..a3b5d3b7fac 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2016, Monty Program Ab. +/* Copyright (c) 2016, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -36,7 +36,7 @@ static bool eq_ascii_string(const CHARSET_INFO *cs, my_wc_t wc; int wc_len; - wc_len= cs->cset->mb_wc(cs, &wc, (uchar *) s, (uchar *) s_end); + wc_len= cs->mb_wc(&wc, (uchar *) s, (uchar *) s_end); if (wc_len <= 0 || (wc | 0x20) != (my_wc_t) *ascii) return 0; @@ -905,7 +905,7 @@ longlong Item_func_json_extract::val_int() { char *end; int err; - i= my_strntoll(collation.collation, value, value_len, 10, &end, &err); + i= collation.collation->strntoll(value, value_len, 10, &end, &err); break; } case JSON_VALUE_TRUE: @@ -936,7 +936,7 @@ double Item_func_json_extract::val_real() { char *end; int err; - d= my_strntod(collation.collation, value, value_len, &end, &err); + d= collation.collation->strntod(value, value_len, &end, &err); break; } case JSON_VALUE_TRUE: @@ -1092,10 +1092,8 @@ static int check_contains(json_engine_t *js, json_engine_t *value) char *end; int err; - d_j= my_strntod(js->s.cs, (char *) js->value, js->value_len, - &end, &err);; - d_v= my_strntod(value->s.cs, (char *) value->value, value->value_len, - &end, &err);; + d_j= js->s.cs->strntod((char *) js->value, js->value_len, &end, &err);; + d_v= value->s.cs->strntod((char *) value->value, value->value_len, &end, &err);; return (fabs(d_j - d_v) < 1e-12); } @@ -3316,7 +3314,7 @@ int Item_func_json_search::compare_json_value_wild(json_engine_t *je, const String *cmp_str) { if (je->value_type != JSON_VALUE_STRING || !je->value_escaped) - return my_wildcmp(collation.collation, + return collation.collation->wildcmp( (const char *) je->value, (const char *) (je->value + je->value_len), cmp_str->ptr(), cmp_str->end(), escape, wild_one, wild_many) ? 0 : 1; @@ -3333,7 +3331,7 @@ int Item_func_json_search::compare_json_value_wild(json_engine_t *je, if (esc_len <= 0) return 0; - return my_wildcmp(collation.collation, + return collation.collation->wildcmp( esc_value.ptr(), esc_value.ptr() + esc_len, cmp_str->ptr(), cmp_str->end(), escape, wild_one, wild_many) ? 0 : 1; } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 5fb7ee0ea61..e689a71e431 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB Corporation + Copyright (c) 2009, 2020, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1099,7 +1099,7 @@ String *Item_func_reverse::val_str(String *str) end= res->end(); tmp= (char *) str->end(); #ifdef USE_MB - if (use_mb(res->charset())) + if (res->use_mb()) { uint32 l; while (ptr < end) @@ -1172,7 +1172,7 @@ String *Item_func_replace::val_str_internal(String *str, res->set_charset(collation.collation); #ifdef USE_MB - binary_cmp = ((res->charset()->state & MY_CS_BINSORT) || !use_mb(res->charset())); + binary_cmp = ((res->charset()->state & MY_CS_BINSORT) || !res->use_mb()); #endif if (res2->length() == 0) @@ -1331,8 +1331,8 @@ bool Item_func_regexp_replace::append_replacement(String *str, my_wc_t wc; int cnv, n; - if ((cnv= cs->cset->mb_wc(cs, &wc, (const uchar *) beg, - (const uchar *) end)) < 1) + if ((cnv= cs->mb_wc(&wc, (const uchar *) beg, + (const uchar *) end)) < 1) break; /* End of line */ beg+= cnv; @@ -1343,8 +1343,8 @@ bool Item_func_regexp_replace::append_replacement(String *str, continue; } - if ((cnv= cs->cset->mb_wc(cs, &wc, (const uchar *) beg, - (const uchar *) end)) < 1) + if ((cnv= cs->mb_wc(&wc, (const uchar *) beg, + (const uchar *) end)) < 1) break; /* End of line */ beg+= cnv; @@ -1801,7 +1801,7 @@ String *Item_func_substr_index::val_str(String *str) res->set_charset(collation.collation); #ifdef USE_MB - if (use_mb(res->charset())) + if (res->use_mb()) { const char *ptr= res->ptr(); const char *strend= ptr+res->length(); @@ -2006,7 +2006,7 @@ String *Item_func_rtrim::val_str(String *str) { char chr=(*remove_str)[0]; #ifdef USE_MB - if (use_mb(collation.collation)) + if (collation.collation->use_mb()) { while (ptr < end) { @@ -2023,7 +2023,7 @@ String *Item_func_rtrim::val_str(String *str) { const char *r_ptr=remove_str->ptr(); #ifdef USE_MB - if (use_mb(collation.collation)) + if (collation.collation->use_mb()) { loop: while (ptr + remove_length < end) @@ -2082,7 +2082,7 @@ String *Item_func_trim::val_str(String *str) while (ptr+remove_length <= end && !memcmp(ptr,r_ptr,remove_length)) ptr+=remove_length; #ifdef USE_MB - if (use_mb(collation.collation)) + if (collation.collation->use_mb()) { char *p=ptr; uint32 l; @@ -2553,10 +2553,10 @@ String *Item_func_soundex::val_str(String *str) for ( ; ; ) /* Skip pre-space */ { - if ((rc= cs->cset->mb_wc(cs, &wc, (uchar*) from, (uchar*) end)) <= 0) + if ((rc= cs->mb_wc(&wc, (uchar*) from, (uchar*) end)) <= 0) return make_empty_result(); /* EOL or invalid byte sequence */ - if (rc == 1 && cs->ctype) + if (rc == 1 && cs->m_ctype) { /* Single byte letter found */ if (my_isalpha(cs, *from)) @@ -2575,7 +2575,7 @@ String *Item_func_soundex::val_str(String *str) /* Multibyte letter found */ wc= soundex_toupper(wc); last_ch= get_scode(wc); // Code of the first letter - if ((rc= cs->cset->wc_mb(cs, wc, (uchar*) to, (uchar*) to_end)) <= 0) + if ((rc= cs->wc_mb(wc, (uchar*) to, (uchar*) to_end)) <= 0) { /* Extra safety - should not really happen */ DBUG_ASSERT(false); @@ -2593,10 +2593,10 @@ String *Item_func_soundex::val_str(String *str) */ for (nchars= 1 ; ; ) { - if ((rc= cs->cset->mb_wc(cs, &wc, (uchar*) from, (uchar*) end)) <= 0) + if ((rc= cs->mb_wc(&wc, (uchar*) from, (uchar*) end)) <= 0) break; /* EOL or invalid byte sequence */ - if (rc == 1 && cs->ctype) + if (rc == 1 && cs->m_ctype) { if (!my_isalpha(cs, *from++)) continue; @@ -2612,8 +2612,7 @@ String *Item_func_soundex::val_str(String *str) if ((ch != '0') && (ch != last_ch)) // if not skipped or double { // letter, copy to output - if ((rc= cs->cset->wc_mb(cs, (my_wc_t) ch, - (uchar*) to, (uchar*) to_end)) <= 0) + if ((rc= cs->wc_mb((my_wc_t) ch, (uchar*) to, (uchar*) to_end)) <= 0) { // Extra safety - should not really happen DBUG_ASSERT(false); @@ -2629,7 +2628,7 @@ String *Item_func_soundex::val_str(String *str) if (nchars < 4) { uint nbytes= (4 - nchars) * cs->mbminlen; - cs->cset->fill(cs, to, nbytes, '0'); + cs->fill(to, nbytes, '0'); to+= nbytes; } @@ -3127,7 +3126,7 @@ String *Item_func_space::val_str(String *str) goto err; str->length(tot_length); str->set_charset(cs); - cs->cset->fill(cs, (char*) str->ptr(), tot_length, ' '); + cs->fill((char*) str->ptr(), tot_length, ' '); return str; err: @@ -3461,11 +3460,11 @@ String *Item_func_conv::val_str(String *str) else { if (from_base < 0) - dec= my_strntoll(res->charset(), res->ptr(), res->length(), - -from_base, &endptr, &err); + dec= res->charset()->strntoll(res->ptr(), res->length(), + -from_base, &endptr, &err); else - dec= (longlong) my_strntoull(res->charset(), res->ptr(), res->length(), - from_base, &endptr, &err); + dec= (longlong) res->charset()->strntoull(res->ptr(), res->length(), + from_base, &endptr, &err); } if (!(ptr= longlong2str(dec, ans, to_base)) || @@ -3587,7 +3586,7 @@ bool Item_func_weight_string::fix_length_and_dec() size_t char_length; char_length= ((cs->state & MY_CS_STRNXFRM_BAD_NWEIGHTS) || !nweights) ? args[0]->max_char_length() : nweights * cs->levels_for_order; - max_length= (uint32)cs->coll->strnxfrmlen(cs, char_length * cs->mbmaxlen); + max_length= (uint32) cs->strnxfrmlen(char_length * cs->mbmaxlen); } maybe_null= 1; return FALSE; @@ -3638,7 +3637,7 @@ String *Item_func_weight_string::val_str(String *str) char_length= (flags & MY_STRXFRM_PAD_WITH_SPACE) ? res->numchars() : (res->length() / cs->mbminlen); } - tmp_length= cs->coll->strnxfrmlen(cs, char_length * cs->mbmaxlen); + tmp_length= cs->strnxfrmlen(char_length * cs->mbmaxlen); } { @@ -3657,11 +3656,10 @@ String *Item_func_weight_string::val_str(String *str) if (str->alloc(tmp_length)) goto nl; - frm_length= cs->coll->strnxfrm(cs, - (uchar *) str->ptr(), tmp_length, - nweights ? nweights : (uint)tmp_length, - (const uchar *) res->ptr(), res->length(), - flags); + frm_length= cs->strnxfrm((char*) str->ptr(), tmp_length, + nweights ? nweights : (uint) tmp_length, + res->ptr(), res->length(), + flags); DBUG_ASSERT(frm_length <= tmp_length); str->length(frm_length); @@ -3781,10 +3779,10 @@ String *Item_func_like_range::val_str(String *str) goto err; null_value=0; - if (cs->coll->like_range(cs, res->ptr(), res->length(), - '\\', '_', '%', (size_t)nbytes, - (char*) min_str.ptr(), (char*) max_str.ptr(), - &min_len, &max_len)) + if (cs->like_range(res->ptr(), res->length(), + '\\', '_', '%', (size_t)nbytes, + (char*) min_str.ptr(), (char*) max_str.ptr(), + &min_len, &max_len)) goto err; min_str.set_charset(collation.collation); @@ -4053,7 +4051,7 @@ String *Item_func_quote::val_str(String *str) to_end= (uchar*) to + new_length; /* Put leading quote */ - if ((mblen= cs->cset->wc_mb(cs, '\'', (uchar *) to, to_end)) <= 0) + if ((mblen= cs->wc_mb('\'', (uchar *) to, to_end)) <= 0) goto toolong; to+= mblen; @@ -4061,7 +4059,7 @@ String *Item_func_quote::val_str(String *str) { my_wc_t wc; bool escape; - if ((mblen= cs->cset->mb_wc(cs, &wc, (uchar*) start, (uchar*) end)) <= 0) + if ((mblen= cs->mb_wc(&wc, (uchar*) start, (uchar*) end)) <= 0) goto null; start+= mblen; switch (wc) { @@ -4073,17 +4071,17 @@ String *Item_func_quote::val_str(String *str) } if (escape) { - if ((mblen= cs->cset->wc_mb(cs, '\\', (uchar*) to, to_end)) <= 0) + if ((mblen= cs->wc_mb('\\', (uchar*) to, to_end)) <= 0) goto toolong; to+= mblen; } - if ((mblen= cs->cset->wc_mb(cs, wc, (uchar*) to, to_end)) <= 0) + if ((mblen= cs->wc_mb(wc, (uchar*) to, to_end)) <= 0) goto toolong; to+= mblen; } /* Put trailing quote */ - if ((mblen= cs->cset->wc_mb(cs, '\'', (uchar *) to, to_end)) <= 0) + if ((mblen= cs->wc_mb('\'', (uchar *) to, to_end)) <= 0) goto toolong; to+= mblen; new_length= (uint)(to - str->ptr()); @@ -4991,8 +4989,8 @@ double Item_dyncol_get::val_real() { int error; char *end; - double res= my_strntod(val.x.string.charset, (char*) val.x.string.value.str, - val.x.string.value.length, &end, &error); + double res= val.x.string.charset->strntod((char*) val.x.string.value.str, + val.x.string.value.length, &end, &error); if (end != (char*) val.x.string.value.str + val.x.string.value.length || error) diff --git a/sql/item_sum.h b/sql/item_sum.h index 7fccc4e24aa..bd97e661775 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -1,7 +1,7 @@ #ifndef ITEM_SUM_INCLUDED #define ITEM_SUM_INCLUDED /* Copyright (c) 2000, 2013 Oracle and/or its affiliates. - Copyright (c) 2008, 2013 Monty Program Ab. + Copyright (c) 2008, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1703,8 +1703,8 @@ public: char *end_not_used; String *res; res=val_str(&str_value); - return res ? my_strntod(res->charset(),(char*) res->ptr(),res->length(), - &end_not_used, &err_not_used) : 0.0; + return res ? res->charset()->strntod((char*) res->ptr(),res->length(), + &end_not_used, &err_not_used) : 0.0; } longlong val_int() { @@ -1717,7 +1717,7 @@ public: return 0; /* Null value */ cs= res->charset(); end= (char*) res->ptr()+res->length(); - return cs->cset->strtoll10(cs, res->ptr(), &end, &err_not_used); + return cs->strtoll10(res->ptr(), &end, &err_not_used); } my_decimal *val_decimal(my_decimal *dec); const Type_handler *type_handler() const { return string_type_handler(); } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index b999035705c..a1377af08e6 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2012, Oracle and/or its affiliates. - Copyright (c) 2009, 2016, MariaDB + Copyright (c) 2009, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -157,7 +157,7 @@ static bool extract_date_time(THD *thd, DATE_TIME_FORMAT *format, for (; ptr != end && val != val_end; ptr++) { /* Skip pre-space between each argument */ - if ((val+= cs->cset->scan(cs, val, val_end, MY_SEQ_SPACES)) >= val_end) + if ((val+= cs->scan(val, val_end, MY_SEQ_SPACES)) >= val_end) break; if (*ptr == '%' && ptr+1 != end) @@ -259,13 +259,9 @@ static bool extract_date_time(THD *thd, DATE_TIME_FORMAT *format, case 'p': if (val_len < 2 || ! usa_time) goto err; - if (!my_strnncoll(&my_charset_latin1, - (const uchar *) val, 2, - (const uchar *) "PM", 2)) + if (!my_charset_latin1.strnncoll(val, 2, "PM", 2)) daypart= 12; - else if (my_strnncoll(&my_charset_latin1, - (const uchar *) val, 2, - (const uchar *) "AM", 2)) + else if (my_charset_latin1.strnncoll(val, 2, "AM", 2)) goto err; val+= 2; break; @@ -2917,9 +2913,8 @@ String *Item_func_get_format::val_str_ascii(String *str) uint format_name_len; format_name_len= (uint) strlen(format_name); if (val_len == format_name_len && - !my_strnncoll(&my_charset_latin1, - (const uchar *) val->ptr(), val_len, - (const uchar *) format_name, val_len)) + !my_charset_latin1.strnncoll(val->ptr(), val_len, + format_name, val_len)) { const char *format_str= get_date_time_format_str(format, type); str->set(format_str, (uint) strlen(format_str), &my_charset_numeric); diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index c8224157e0f..b5eda985eb2 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2005, 2019, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB + Copyright (c) 2009, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -507,8 +507,8 @@ public: { char *end; int err; - double add= my_strntod(collation.collation, (char*) node->beg, - node->end - node->beg, &end, &err); + double add= collation.collation->strntod((char*) node->beg, + node->end - node->beg, &end, &err); if (!err) sum+= add; } @@ -1442,16 +1442,16 @@ my_xpath_lex_scan(MY_XPATH *xpath, } // Check ident, or a function call, or a keyword - if ((length= xpath->cs->cset->ctype(xpath->cs, &ctype, - (const uchar*) beg, - (const uchar*) end)) > 0 && + if ((length= xpath->cs->ctype(&ctype, + (const uchar*) beg, + (const uchar*) end)) > 0 && ((ctype & (_MY_L | _MY_U)) || *beg == '_')) { // scan untill the end of the idenfitier for (beg+= length; - (length= xpath->cs->cset->ctype(xpath->cs, &ctype, - (const uchar*) beg, - (const uchar*) end)) > 0 && + (length= xpath->cs->ctype(&ctype, + (const uchar*) beg, + (const uchar*) end)) > 0 && ((ctype & (_MY_L | _MY_U | _MY_NMR)) || *beg == '_' || *beg == '-' || *beg == '.') ; beg+= length) /* no op */; diff --git a/sql/key.cc b/sql/key.cc index bf50094a9e4..9dbb7a15726 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. - Copyright (c) 2018, MariaDB + Copyright (c) 2018, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -159,7 +159,7 @@ void key_copy(uchar *to_key, const uchar *from_record, KEY *key_info, CHARSET_INFO *cs= field->charset(); uint bytes= field->get_key_image(to_key, length, Field::itRAW); if (bytes < length) - cs->cset->fill(cs, (char*) to_key + bytes, length - bytes, ' '); + cs->fill((char*) to_key + bytes, length - bytes, ' '); } } } @@ -324,12 +324,10 @@ bool key_cmp_if_same(TABLE *table,const uchar *key,uint idx,uint key_length) const uchar *pos= table->record[0] + key_part->offset; if (length > char_length) { - char_length= my_charpos(cs, pos, pos + length, char_length); + char_length= cs->charpos(pos, pos + length, char_length); set_if_smaller(char_length, length); } - if (cs->coll->strnncollsp(cs, - (const uchar*) key, length, - (const uchar*) pos, char_length)) + if (cs->strnncollsp(key, length, pos, char_length)) return 1; continue; } @@ -387,9 +385,9 @@ void field_unpack(String *to, Field *field, const uchar *rec, uint max_length, Align, returning not more than "char_length" characters. */ size_t charpos, char_length= max_length / cs->mbmaxlen; - if ((charpos= my_charpos(cs, tmp.ptr(), - tmp.ptr() + tmp.length(), - char_length)) < tmp.length()) + if ((charpos= cs->charpos(tmp.ptr(), + tmp.ptr() + tmp.length(), + char_length)) < tmp.length()) tmp.length(charpos); } if (max_length < field->pack_length()) @@ -757,12 +755,12 @@ ulong key_hashnr(KEY *key_info, uint used_key_parts, const uchar *key) { if (cs->mbmaxlen > 1) { - size_t char_length= my_charpos(cs, pos + pack_length, - pos + pack_length + length, - length / cs->mbmaxlen); + size_t char_length= cs->charpos(pos + pack_length, + pos + pack_length + length, + length / cs->mbmaxlen); set_if_smaller(length, char_length); } - cs->coll->hash_sort(cs, pos+pack_length, length, &nr, &nr2); + cs->hash_sort(pos+pack_length, length, &nr, &nr2); key+= pack_length; } else @@ -871,19 +869,18 @@ bool key_buf_cmp(KEY *key_info, uint used_key_parts, size_t byte_len1= length1, byte_len2= length2; if (cs->mbmaxlen > 1) { - size_t char_length1= my_charpos(cs, pos1 + pack_length, - pos1 + pack_length + length1, - length1 / cs->mbmaxlen); - size_t char_length2= my_charpos(cs, pos2 + pack_length, - pos2 + pack_length + length2, - length2 / cs->mbmaxlen); + size_t char_length1= cs->charpos(pos1 + pack_length, + pos1 + pack_length + length1, + length1 / cs->mbmaxlen); + size_t char_length2= cs->charpos(pos2 + pack_length, + pos2 + pack_length + length2, + length2 / cs->mbmaxlen); set_if_smaller(length1, char_length1); set_if_smaller(length2, char_length2); } if (length1 != length2 || - cs->coll->strnncollsp(cs, - pos1 + pack_length, byte_len1, - pos2 + pack_length, byte_len2)) + cs->strnncollsp(pos1 + pack_length, byte_len1, + pos2 + pack_length, byte_len2)) return TRUE; key1+= pack_length; key2+= pack_length; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 09d8b4b7d1c..7fe98c756cd 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2008, 2019, MariaDB Corporation. + Copyright (c) 2008, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -8850,11 +8850,10 @@ bool is_secure_file_path(char *path) } else { - if (files_charset_info->coll->strnncoll(files_charset_info, - (uchar *) buff2, strlen(buff2), - (uchar *) opt_secure_file_priv, - opt_secure_file_priv_len, - TRUE)) + if (files_charset_info->strnncoll(buff2, strlen(buff2), + opt_secure_file_priv, + opt_secure_file_priv_len, + TRUE)) return FALSE; } return TRUE; diff --git a/sql/mysqld.h b/sql/mysqld.h index c643f3786ef..80e1876a70c 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -1,5 +1,5 @@ /* Copyright (c) 2006, 2016, Oracle and/or its affiliates. - Copyright (c) 2010, 2019, MariaDB Corporation. + Copyright (c) 2010, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -788,8 +788,7 @@ extern "C" void unireg_clear(int exit_code); inline void table_case_convert(char * name, uint length) { if (lower_case_table_names) - files_charset_info->cset->casedn(files_charset_info, - name, length, name, length); + files_charset_info->casedn(name, length, name, length); } extern void set_server_version(char *buf, size_t size); diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 0aa06532d0f..1b95b4b4ab1 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2008, 2019, MariaDB + Copyright (c) 2008, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -8604,13 +8604,12 @@ Item_func_like::get_mm_leaf(RANGE_OPT_PARAM *param, size_t min_length, max_length; field_length-= maybe_null; - if (my_like_range(field->charset(), - res->ptr(), res->length(), - escape, wild_one, wild_many, - field_length, - (char*) min_str + offset, - (char*) max_str + offset, - &min_length, &max_length)) + if (field->charset()->like_range(res->ptr(), res->length(), + escape, wild_one, wild_many, + field_length, + (char*) min_str + offset, + (char*) max_str + offset, + &min_length, &max_length)) DBUG_RETURN(0); // Can't optimize with LIKE if (offset != maybe_null) // BLOB or VARCHAR diff --git a/sql/procedure.h b/sql/procedure.h index 8cb8ce9a677..769eac5f217 100644 --- a/sql/procedure.h +++ b/sql/procedure.h @@ -2,6 +2,7 @@ #define PROCEDURE_INCLUDED /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -88,7 +89,7 @@ public: { int err_not_used; char *end_not_used; - value= my_strntod(cs,(char*) str,length, &end_not_used, &err_not_used); + value= cs->strntod((char*) str,length, &end_not_used, &err_not_used); } double val_real() { return value; } longlong val_int() { return (longlong) value; } @@ -116,7 +117,7 @@ public: void set(double nr) { value=(longlong) nr; } void set(longlong nr) { value=nr; } void set(const char *str,uint length, CHARSET_INFO *cs) - { int err; value=my_strntoll(cs,str,length,10,NULL,&err); } + { int err; value= cs->strntoll(str,length,10,NULL,&err); } double val_real() { return (double) value; } longlong val_int() { return value; } String *val_str(String *s) { s->set(value, default_charset()); return s; } @@ -140,14 +141,14 @@ public: int err_not_used; char *end_not_used; CHARSET_INFO *cs= str_value.charset(); - return my_strntod(cs, (char*) str_value.ptr(), str_value.length(), - &end_not_used, &err_not_used); + return cs->strntod((char*) str_value.ptr(), str_value.length(), + &end_not_used, &err_not_used); } longlong val_int() { int err; CHARSET_INFO *cs=str_value.charset(); - return my_strntoll(cs,str_value.ptr(),str_value.length(),10,NULL,&err); + return cs->strntoll(str_value.ptr(),str_value.length(),10,NULL,&err); } String *val_str(String*) { diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc index 5d10cc661ca..e96f9640098 100644 --- a/sql/rpl_filter.cc +++ b/sql/rpl_filter.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -595,10 +596,10 @@ Rpl_filter::find_wild(DYNAMIC_ARRAY *a, const char* key, int len) { TABLE_RULE_ENT* e ; get_dynamic(a, (uchar*)&e, i); - if (!my_wildcmp(system_charset_info, key, key_end, - (const char*)e->db, - (const char*)(e->db + e->key_len), - '\\',wild_one,wild_many)) + if (!system_charset_info->wildcmp(key, key_end, + (const char*)e->db, + (const char*)(e->db + e->key_len), + '\\', wild_one, wild_many)) return e; } diff --git a/sql/slave.cc b/sql/slave.cc index 9b1f0b96bce..d0ea276c03c 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2009, 2017, MariaDB Corporation + Copyright (c) 2009, 2020, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -934,7 +934,7 @@ bool init_slave_skip_errors(const char* arg) use_slave_mask= 1; for (;my_isspace(system_charset_info,*arg);++arg) /* empty */; - if (!my_strnncoll(system_charset_info,(uchar*)arg,4,(const uchar*)"all",4)) + if (!system_charset_info->strnncoll((uchar*)arg,4,(const uchar*)"all",4)) { bitmap_set_all(&slave_error_mask); goto end; diff --git a/sql/sp.cc b/sql/sp.cc index 4e958aedc44..ae413fcf615 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2002, 2018, Oracle and/or its affiliates. - Copyright (c) 2009, 2018, MariaDB + Copyright (c) 2009, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1283,9 +1283,8 @@ Sp_handler::sp_create_routine(THD *thd, const sp_head *sp) const goto done; } - if (system_charset_info->cset->numchars(system_charset_info, - sp->m_name.str, - sp->m_name.str+sp->m_name.length) > + if (system_charset_info->numchars(sp->m_name.str, + sp->m_name.str + sp->m_name.length) > table->field[MYSQL_PROC_FIELD_NAME]->char_length()) { my_error(ER_TOO_LONG_IDENT, MYF(0), sp->m_name.str); @@ -1,5 +1,6 @@ /* -*- C++ -*- */ /* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -135,9 +136,8 @@ public: static bool eq_routine_name(const LEX_CSTRING &name1, const LEX_CSTRING &name2) { - return my_strnncoll(system_charset_info, - (const uchar *) name1.str, name1.length, - (const uchar *) name2.str, name2.length) == 0; + return system_charset_info->strnncoll(name1.str, name1.length, + name2.str, name2.length) == 0; } const char *type_str() const { return type_lex_cstring().str; } virtual const char *show_create_routine_col1_caption() const diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc index 433efda479b..01841bb57b7 100644 --- a/sql/sp_pcontext.cc +++ b/sql/sp_pcontext.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -208,9 +209,8 @@ sp_variable *sp_pcontext::find_variable(const LEX_CSTRING *name, { sp_variable *p= m_vars.at(i); - if (my_strnncoll(system_charset_info, - (const uchar *)name->str, name->length, - (const uchar *)p->name.str, p->name.length) == 0) + if (system_charset_info->strnncoll(name->str, name->length, + p->name.str, p->name.length) == 0) { return p; } @@ -624,9 +624,8 @@ const sp_pcursor *sp_pcontext::find_cursor(const LEX_CSTRING *name, { LEX_CSTRING n= m_cursors.at(i); - if (my_strnncoll(system_charset_info, - (const uchar *) name->str, name->length, - (const uchar *) n.str, n.length) == 0) + if (system_charset_info->strnncoll(name->str, name->length, + n.str, n.length) == 0) { *poff= m_cursor_offset + i; return &m_cursors.at(i); diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h index b1d77234f54..ffc9c0e19af 100644 --- a/sql/sp_pcontext.h +++ b/sql/sp_pcontext.h @@ -1,5 +1,6 @@ /* -*- C++ -*- */ /* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -260,9 +261,8 @@ public: } bool eq_name(const LEX_CSTRING *str) const { - return my_strnncoll(system_charset_info, - (const uchar *) name.str, name.length, - (const uchar *) str->str, str->length) == 0; + return system_charset_info->strnncoll(name.str, name.length, + str->str, str->length) == 0; } }; diff --git a/sql/spatial.cc b/sql/spatial.cc index ebec280a5eb..e3502dbac1a 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2002, 2013, Oracle and/or its affiliates. - Copyright (c) 2011, 2013, Monty Program Ab. + Copyright (c) 2011, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -149,9 +149,8 @@ Geometry::Class_info *Geometry::find_class(const char *name, size_t len) { if (*cur_rt && ((*cur_rt)->m_name.length == len) && - (my_strnncoll(&my_charset_latin1, - (const uchar*) (*cur_rt)->m_name.str, len, - (const uchar*) name, len) == 0)) + (my_charset_latin1.strnncoll((*cur_rt)->m_name.str, len, + name, len) == 0)) return *cur_rt; } return 0; @@ -455,8 +454,8 @@ Geometry *Geometry::create_from_json(Geometry_buffer *buffer, goto create_geom; } else if (je->value_len == feature_coll_type_len && - my_strnncoll(&my_charset_latin1, je->value, je->value_len, - feature_coll_type, feature_coll_type_len) == 0) + my_charset_latin1.strnncoll(je->value, je->value_len, + feature_coll_type, feature_coll_type_len) == 0) { /* 'FeatureCollection' type found. Handle the 'Featurecollection'/'features' @@ -467,8 +466,8 @@ Geometry *Geometry::create_from_json(Geometry_buffer *buffer, fcoll_type_found= 1; } else if (je->value_len == feature_type_len && - my_strnncoll(&my_charset_latin1, je->value, je->value_len, - feature_type, feature_type_len) == 0) + my_charset_latin1.strnncoll(je->value, je->value_len, + feature_type, feature_type_len) == 0) { if (geometry_start) goto handle_geometry_key; @@ -860,8 +859,7 @@ static int read_point_from_json(json_engine_t *je, bool er_on_3D, goto bad_coordinates; d= (n_coord == 0) ? x : ((n_coord == 1) ? y : &tmp); - *d= my_strntod(je->s.cs, (char *) je->value, - je->value_len, &endptr, &err); + *d= je->s.cs->strntod((char *) je->value, je->value_len, &endptr, &err); if (err) goto bad_coordinates; n_coord++; @@ -2989,9 +2987,7 @@ bool Gis_geometry_collection::init_from_wkt(Gis_read_stream *trs, String *wkb) return 1; if (next_word.length != 5 || - (my_strnncoll(&my_charset_latin1, - (const uchar*) "empty", 5, - (const uchar*) next_word.str, 5) != 0)) + (my_charset_latin1.strnncoll("empty", 5, next_word.str, 5) != 0)) { for (;;) { diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 4c8eaee3145..26fc365b74a 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2018, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB Corporation. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -4170,7 +4170,7 @@ bool hostname_requires_resolving(const char *hostname) if (hostname == my_localhost || (hostname_len == localhost_len && - !my_strnncoll(system_charset_info, + !system_charset_info->strnncoll( (const uchar *) hostname, hostname_len, (const uchar *) my_localhost, strlen(my_localhost)))) { @@ -12765,7 +12765,7 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio) */ ulong nr1=1, nr2=4; CHARSET_INFO *cs= &my_charset_latin1; - cs->coll->hash_sort(cs, (uchar*) sctx->user, strlen(sctx->user), &nr1, &nr2); + cs->hash_sort((uchar*) sctx->user, strlen(sctx->user), &nr1, &nr2); mysql_mutex_lock(&acl_cache->lock); if (!acl_users.elements) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 4577f1007be..1fdf4f17447 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2008, 2019, MariaDB Corporation. + Copyright (c) 2008, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -3395,7 +3395,7 @@ int select_export::send_data(List<Item> &items) pos++) { #ifdef USE_MB - if (use_mb(res_charset)) + if (res_charset->use_mb()) { int l; if ((l=my_ismbchar(res_charset, pos, end))) diff --git a/sql/sql_class.h b/sql/sql_class.h index 8fc33523896..5bbe2e386d0 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB Corporation. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -3790,7 +3790,7 @@ public: const char *src, size_t src_length); /* If either "dstcs" or "srccs" is &my_charset_bin, - then performs native copying using cs->cset->copy_fix(). + then performs native copying using copy_fix(). Otherwise, performs Unicode conversion using convert_fix(). */ bool copy_fix(CHARSET_INFO *dstcs, LEX_STRING *dst, @@ -6999,12 +6999,10 @@ public: return m_db.length == other->m_db.length && m_name.length == other->m_name.length && - !my_strnncoll(cs, - (const uchar *) m_db.str, m_db.length, - (const uchar *) other->m_db.str, other->m_db.length) && - !my_strnncoll(cs, - (const uchar *) m_name.str, m_name.length, - (const uchar *) other->m_name.str, other->m_name.length); + !cs->strnncoll(m_db.str, m_db.length, + other->m_db.str, other->m_db.length) && + !cs->strnncoll(m_name.str, m_name.length, + other->m_name.str, other->m_name.length); } void copy(MEM_ROOT *mem_root, const LEX_CSTRING &db, const LEX_CSTRING &name); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index b9a65e17a3a..65fbd5a0ede 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB Corporation + Copyright (c) 2009, 2020, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1535,7 +1535,7 @@ my_unescape(CHARSET_INFO *cs, char *to, const char *str, const char *end, { #ifdef USE_MB int l; - if (use_mb(cs) && (l= my_ismbchar(cs, str, end))) + if (cs->use_mb() && (l= my_ismbchar(cs, str, end))) { while (l--) *to++ = *str++; @@ -1613,7 +1613,7 @@ bool Lex_input_stream::get_text(Lex_string_with_metadata_st *dst, uint sep, #ifdef USE_MB { int l; - if (use_mb(cs) && + if (cs->use_mb() && (l = my_ismbchar(cs, get_ptr() -1, get_end_of_query()))) { @@ -2644,12 +2644,12 @@ int Lex_input_stream::scan_ident_start(THD *thd, Lex_ident_cli_st *str) const uchar *const ident_map= cs->ident_map; DBUG_ASSERT(m_tok_start <= m_ptr); - if (use_mb(cs)) + if (cs->use_mb()) { is_8bit= true; while (ident_map[c= yyGet()]) { - int char_length= my_charlen(cs, get_ptr() - 1, get_end_of_query()); + int char_length= cs->charlen(get_ptr() - 1, get_end_of_query()); if (char_length <= 0) break; skip_binary(char_length - 1); @@ -2687,10 +2687,10 @@ int Lex_input_stream::scan_ident_middle(THD *thd, Lex_ident_cli_st *str, bool resolve_introducer= true; DBUG_ASSERT(m_ptr == m_tok_start + 1); // m_ptr points to the second byte - if (use_mb(cs)) + if (cs->use_mb()) { is_8bit= true; - int char_length= my_charlen(cs, get_ptr() - 1, get_end_of_query()); + int char_length= cs->charlen(get_ptr() - 1, get_end_of_query()); if (char_length <= 0) { *st= MY_LEX_CHAR; @@ -2700,7 +2700,7 @@ int Lex_input_stream::scan_ident_middle(THD *thd, Lex_ident_cli_st *str, while (ident_map[c= yyGet()]) { - char_length= my_charlen(cs, get_ptr() - 1, get_end_of_query()); + char_length= cs->charlen(get_ptr() - 1, get_end_of_query()); if (char_length <= 0) break; if (char_length > 1 || (c & 0x80)) @@ -2789,7 +2789,7 @@ int Lex_input_stream::scan_ident_delimited(THD *thd, while ((c= yyGet())) { - int var_length= my_charlen(cs, get_ptr() - 1, get_end_of_query()); + int var_length= cs->charlen(get_ptr() - 1, get_end_of_query()); if (var_length == 1) { if (c == quote_char) @@ -7940,11 +7940,11 @@ Item *LEX::create_item_ident(THD *thd, if ((thd->variables.sql_mode & MODE_ORACLE) && b.length == 7) { - if (!my_strnncoll(system_charset_info, + if (!system_charset_info->strnncoll( (const uchar *) b.str, 7, (const uchar *) "NEXTVAL", 7)) return create_item_func_nextval(thd, &null_clex_str, &a); - else if (!my_strnncoll(system_charset_info, + else if (!system_charset_info->strnncoll( (const uchar *) b.str, 7, (const uchar *) "CURRVAL", 7)) return create_item_func_lastval(thd, &null_clex_str, &a); @@ -7963,11 +7963,11 @@ Item *LEX::create_item_ident(THD *thd, Lex_ident_sys() : *a; if ((thd->variables.sql_mode & MODE_ORACLE) && c->length == 7) { - if (!my_strnncoll(system_charset_info, + if (!system_charset_info->strnncoll( (const uchar *) c->str, 7, (const uchar *) "NEXTVAL", 7)) return create_item_func_nextval(thd, a, b); - else if (!my_strnncoll(system_charset_info, + else if (!system_charset_info->strnncoll( (const uchar *) c->str, 7, (const uchar *) "CURRVAL", 7)) return create_item_func_lastval(thd, a, b); diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 89cc3f8da64..6d3f9e540a7 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2010, 2018, MariaDB Corporation. + Copyright (c) 2010, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -190,7 +190,7 @@ class READ_INFO: public Load_data_param bool read_mbtail(String *str) { int chlen; - if ((chlen= my_charlen(charset(), str->end() - 1, str->end())) == 1) + if ((chlen= charset()->charlen(str->end() - 1, str->end())) == 1) return false; // Single byte character found for (uint32 length0= str->length() - 1 ; MY_CS_IS_TOOSMALL(chlen); ) { @@ -201,7 +201,7 @@ class READ_INFO: public Load_data_param return true; // EOF } str->append(chr); - chlen= my_charlen(charset(), str->ptr() + length0, str->end()); + chlen= charset()->charlen(str->ptr() + length0, str->end()); if (chlen == MY_CS_ILSEQ) { /** @@ -1587,7 +1587,7 @@ int READ_INFO::read_field() } } data.append(chr); - if (use_mb(charset()) && read_mbtail(&data)) + if (charset()->use_mb() && read_mbtail(&data)) goto found_eof; } /* @@ -1686,8 +1686,8 @@ int READ_INFO::next_line() if (getbyte(&buf[0])) return 1; // EOF - if (use_mb(charset()) && - (chlen= my_charlen(charset(), buf, buf + 1)) != 1) + if (charset()->use_mb() && + (chlen= charset()->charlen(buf, buf + 1)) != 1) { uint i; for (i= 1; MY_CS_IS_TOOSMALL(chlen); ) @@ -1696,7 +1696,7 @@ int READ_INFO::next_line() DBUG_ASSERT(chlen != 1); if (getbyte(&buf[i++])) return 1; // EOF - chlen= my_charlen(charset(), buf, buf + i); + chlen= charset()->charlen(buf, buf + i); } /* @@ -1867,7 +1867,7 @@ int READ_INFO::read_value(int delim, String *val) else { val->append(chr); - if (use_mb(charset()) && read_mbtail(val)) + if (charset()->use_mb() && read_mbtail(val)) return my_b_EOF; } } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f420aa01a92..dc81e8a2b91 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2008, 2019, MariaDB + Copyright (c) 2008, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -10133,10 +10133,10 @@ int path_starts_from_data_home_dir(const char *path) if (lower_case_file_system) { - if (!my_strnncoll(default_charset_info, (const uchar*) path, - mysql_unpacked_real_data_home_len, - (const uchar*) mysql_unpacked_real_data_home, - mysql_unpacked_real_data_home_len)) + if (!default_charset_info->strnncoll(path, + mysql_unpacked_real_data_home_len, + mysql_unpacked_real_data_home, + mysql_unpacked_real_data_home_len)) { DBUG_PRINT("error", ("Path is part of mysql_real_data_home")); DBUG_RETURN(1); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index ff5c1c6bc58..58ff9e05432 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2005, 2017, Oracle and/or its affiliates. - Copyright (c) 2009, 2018, MariaDB + Copyright (c) 2009, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1864,7 +1864,7 @@ bool field_is_partition_charset(Field *field) DESCRIPTION We will check in this routine that the fields of the partition functions do not contain unallowed parts. It can also be used to check if there - are fields that require special care by calling my_strnxfrm before + are fields that require special care by calling strnxfrm before calling the functions to calculate partition id. */ @@ -2951,8 +2951,8 @@ static void copy_to_part_field_buffers(Field **ptr, if (field->type() == MYSQL_TYPE_VARCHAR) { uint len_bytes= ((Field_varstring*)field)->length_bytes; - my_strnxfrm(cs, field_buf + len_bytes, max_len, - field->ptr + len_bytes, data_len); + cs->strnxfrm(field_buf + len_bytes, max_len, + field->ptr + len_bytes, data_len); if (len_bytes == 1) *field_buf= (uchar) data_len; else @@ -2960,8 +2960,8 @@ static void copy_to_part_field_buffers(Field **ptr, } else { - my_strnxfrm(cs, field_buf, max_len, - field->ptr, max_len); + cs->strnxfrm(field_buf, max_len, + field->ptr, max_len); } field->ptr= field_buf; } diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 19ea6e31042..bbfbdc3a22e 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2005, 2018, Oracle and/or its affiliates. - Copyright (c) 2010, 2018, MariaDB Corporation + Copyright (c) 2010, 2020, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -454,9 +454,8 @@ static struct st_plugin_dl *plugin_dl_find(const LEX_CSTRING *dl) { tmp= *dynamic_element(&plugin_dl_array, i, struct st_plugin_dl **); if (tmp->ref_count && - ! my_strnncoll(files_charset_info, - (const uchar *)dl->str, dl->length, - (const uchar *)tmp->dl.str, tmp->dl.length)) + ! files_charset_info->strnncoll(dl->str, dl->length, + tmp->dl.str, tmp->dl.length)) DBUG_RETURN(tmp); } DBUG_RETURN(0); @@ -1128,9 +1127,8 @@ static enum install_status plugin_add(MEM_ROOT *tmp_root, bool if_not_exists, tmp.plugin_dl->mariaversion == 0)) continue; // unsupported plugin type - if (name->str && my_strnncoll(system_charset_info, - (const uchar *)name->str, name->length, - (const uchar *)tmp.name.str, tmp.name.length)) + if (name->str && system_charset_info->strnncoll(name->str, name->length, + tmp.name.str, tmp.name.length)) continue; // plugin name doesn't match if (!name->str && @@ -1634,8 +1632,7 @@ int plugin_init(int *argc, char **argv, int flags) for (plugin= *builtins; plugin->info; plugin++) { if (opt_ignore_builtin_innodb && - !my_strnncoll(&my_charset_latin1, (const uchar*) plugin->name, - 6, (const uchar*) "InnoDB", 6)) + !my_charset_latin1.strnncoll(plugin->name, 6, "InnoDB", 6)) continue; bzero(&tmp, sizeof(tmp)); diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index bef9125faba..5bfa29b72c4 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2018, Oracle and/or its affiliates. - Copyright (c) 2008, 2019, MariaDB Corporation + Copyright (c) 2008, 2020, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -3506,7 +3506,7 @@ static bool get_string_parameter(char *to, const char *from, size_t length, if (from) // Empty paramaters allowed { size_t from_length= strlen(from); - size_t from_numchars= cs->cset->numchars(cs, from, from + from_length); + size_t from_numchars= cs->numchars(from, from + from_length); if (from_numchars > length / cs->mbmaxlen) { my_error(ER_WRONG_STRING_LENGTH, MYF(0), from, name, diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 311125419cf..a154d4771e9 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB Corporation. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19086,10 +19086,8 @@ bool Virtual_tmp_table::sp_find_field_by_name(uint *idx, for (uint i= 0; (f= field[i]); i++) { // Use the same comparison style with sp_context::find_variable() - if (!my_strnncoll(system_charset_info, - (const uchar *) f->field_name.str, - f->field_name.length, - (const uchar *) name.str, name.length)) + if (!system_charset_info->strnncoll(f->field_name.str, f->field_name.length, + name.str, name.length)) { *idx= i; return false; @@ -27163,7 +27161,7 @@ Index_hint::print(THD *thd, String *str) str->append (STRING_WITH_LEN(" (")); if (key_name.length) { - if (thd && !my_strnncoll(system_charset_info, + if (thd && !system_charset_info->strnncoll( (const uchar *)key_name.str, key_name.length, (const uchar *)primary_key_name, strlen(primary_key_name))) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 40ecb7b1fe5..eaa4b5a33bb 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB + Copyright (c) 2009, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -346,15 +346,14 @@ int fill_all_plugins(THD *thd, TABLE_LIST *tables, COND *cond) { if (lookup.wild_db_value) { - if (my_wildcmp(files_charset_info, dl.str, dlend, wstr, wend, - wild_prefix, wild_one, wild_many)) + if (files_charset_info->wildcmp(dl.str, dlend, wstr, wend, + wild_prefix, wild_one, wild_many)) continue; } else { - if (my_strnncoll(files_charset_info, - (uchar*)dl.str, dl.length, - (uchar*)lookup.db_value.str, lookup.db_value.length)) + if (files_charset_info->strnncoll(dl.str, dl.length, + lookup.db_value.str, lookup.db_value.length)) continue; } } @@ -1494,7 +1493,7 @@ static const char *require_quotes(const char *name, uint name_length) for (; name < end ; name++) { uchar chr= (uchar) *name; - int length= my_charlen(system_charset_info, name, end); + int length= system_charset_info->charlen(name, end); if (length == 1 && !system_charset_info->ident_map[chr]) return name; if (length == 1 && (chr < '0' || chr > '9')) @@ -1555,7 +1554,7 @@ append_identifier(THD *thd, String *packet, const char *name, size_t length) for (name_end= name+length ; name < name_end ; ) { uchar chr= (uchar) *name; - int char_length= my_charlen(system_charset_info, name, name_end); + int char_length= system_charset_info->charlen(name, name_end); /* charlen can return 0 and negative numbers on a wrong multibyte sequence. It is possible when upgrading from 4.0, @@ -3882,18 +3881,18 @@ bool get_lookup_value(THD *thd, Item_func *item_func, return 1; /* Lookup value is database name */ - if (!cs->coll->strnncollsp(cs, (uchar *) field_name1, strlen(field_name1), - (uchar *) item_field->field_name.str, - item_field->field_name.length)) + if (!cs->strnncollsp(field_name1, strlen(field_name1), + item_field->field_name.str, + item_field->field_name.length)) { thd->make_lex_string(&lookup_field_vals->db_value, tmp_str->ptr(), tmp_str->length()); } /* Lookup value is table name */ - else if (!cs->coll->strnncollsp(cs, (uchar *) field_name2, - strlen(field_name2), - (uchar *) item_field->field_name.str, - item_field->field_name.length)) + else if (!cs->strnncollsp(field_name2, + strlen(field_name2), + item_field->field_name.str, + item_field->field_name.length)) { thd->make_lex_string(&lookup_field_vals->table_value, tmp_str->ptr(), tmp_str->length()); @@ -3986,12 +3985,12 @@ bool uses_only_table_name_fields(Item *item, TABLE_LIST *table) const char *field_name2= schema_table->idx_field2 >= 0 ? field_info[schema_table->idx_field2].name().str : ""; if (table->table != item_field->field->table || - (cs->coll->strnncollsp(cs, (uchar *) field_name1, strlen(field_name1), - (uchar *) item_field->field_name.str, - item_field->field_name.length) && - cs->coll->strnncollsp(cs, (uchar *) field_name2, strlen(field_name2), - (uchar *) item_field->field_name.str, - item_field->field_name.length))) + (cs->strnncollsp(field_name1, strlen(field_name1), + item_field->field_name.str, + item_field->field_name.length) && + cs->strnncollsp(field_name2, strlen(field_name2), + item_field->field_name.str, + item_field->field_name.length))) return 0; } else if (item->type() == Item::EXPR_CACHE_ITEM) diff --git a/sql/sql_signal.cc b/sql/sql_signal.cc index 1b1d2fe0f31..115f5fa4347 100644 --- a/sql/sql_signal.cc +++ b/sql/sql_signal.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -104,7 +105,7 @@ static bool assign_fixed_string(MEM_ROOT *mem_root, src_cs= src->charset(); src_len= src->length(); src_end= src_str + src_len; - numchars= src_cs->cset->numchars(src_cs, src_str, src_end); + numchars= src_cs->numchars(src_str, src_end); if (numchars <= max_char) { @@ -114,7 +115,7 @@ static bool assign_fixed_string(MEM_ROOT *mem_root, else { numchars= max_char; - to_copy= dst_cs->cset->charpos(dst_cs, src_str, src_end, numchars); + to_copy= dst_cs->charpos(src_str, src_end, numchars); truncated= true; } diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 71425e0caf6..4ddc467794f 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2016, MariaDB + Copyright (c) 2016, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -125,7 +125,7 @@ bool String::set_int(longlong num, bool unsigned_flag, CHARSET_INFO *cs) if (alloc(l)) return TRUE; - str_length=(uint32) (cs->cset->longlong10_to_str)(cs,Ptr,l,base,num); + str_length=(uint32) (cs->longlong10_to_str)(Ptr,l,base,num); set_charset(cs); return FALSE; } @@ -821,9 +821,8 @@ bool Binary_string::copy_printable_hhhh(CHARSET_INFO *to_cs, int sortcmp(const String *s,const String *t, CHARSET_INFO *cs) { - return cs->coll->strnncollsp(cs, - (uchar *) s->ptr(),s->length(), - (uchar *) t->ptr(),t->length()); + return cs->strnncollsp(s->ptr(), s->length(), + t->ptr(), t->length()); } @@ -1099,8 +1098,8 @@ String_copier::well_formed_copy(CHARSET_INFO *to_cs, my_charset_same(from_cs, to_cs)) { m_cannot_convert_error_pos= NULL; - return (uint) to_cs->cset->copy_fix(to_cs, to, to_length, from, from_length, - nchars, this); + return (uint) to_cs->copy_fix(to, to_length, from, from_length, + nchars, this); } return (uint) my_convert_fix(to_cs, to, to_length, from_cs, from, from_length, nchars, this, this); diff --git a/sql/sql_string.h b/sql/sql_string.h index 617fcda5fee..eb69d21eaeb 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -3,7 +3,7 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2008, 2019, MariaDB Corporation. + Copyright (c) 2008, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -60,7 +60,7 @@ class Well_formed_prefix_status: public String_copy_status public: Well_formed_prefix_status(CHARSET_INFO *cs, const char *str, const char *end, size_t nchars) - { cs->cset->well_formed_char_length(cs, str, end, nchars, this); } + { cs->well_formed_char_length(str, end, nchars, this); } }; @@ -137,6 +137,7 @@ public: Charset(CHARSET_INFO *cs) :m_charset(cs) { } CHARSET_INFO *charset() const { return m_charset; } + bool use_mb() const { return m_charset->use_mb(); } uint mbminlen() const { return m_charset->mbminlen; } uint mbmaxlen() const { return m_charset->mbmaxlen; } bool is_good_for_ft() const @@ -147,15 +148,15 @@ public: size_t numchars(const char *str, const char *end) const { - return m_charset->cset->numchars(m_charset, str, end); + return m_charset->numchars(str, end); } size_t lengthsp(const char *str, size_t length) const { - return m_charset->cset->lengthsp(m_charset, str, length); + return m_charset->lengthsp(str, length); } size_t charpos(const char *str, const char *end, size_t pos) const { - return m_charset->cset->charpos(m_charset, str, end, pos); + return m_charset->charpos(str, end, pos); } void set_charset(CHARSET_INFO *charset_arg) { @@ -1067,7 +1068,7 @@ static inline bool check_if_only_end_space(CHARSET_INFO *cs, const char *str, const char *end) { - return str+ cs->cset->scan(cs, str, end, MY_SEQ_SPACES) == end; + return str + cs->scan(str, end, MY_SEQ_SPACES) == end; } int append_query_string(CHARSET_INFO *csinfo, String *to, diff --git a/sql/sql_table.cc b/sql/sql_table.cc index bc955fb17ba..e4a33dd99cd 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2019, Oracle and/or its affiliates. - Copyright (c) 2010, 2019, MariaDB + Copyright (c) 2010, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -132,7 +132,7 @@ static char* add_identifier(THD* thd, char *to_p, const char * end_p, *(to_p++)= (char) quote; while (*conv_name && (end_p - to_p - 1) > 0) { - int length= my_charlen(system_charset_info, conv_name, conv_name_end); + int length= system_charset_info->charlen(conv_name, conv_name_end); if (length <= 0) length= 1; if (length == 1 && *conv_name == (char) quote) @@ -3228,8 +3228,7 @@ bool Column_definition::prepare_stage1_check_typelib_default() } else /* MYSQL_TYPE_ENUM */ { - def->length(charset->cset->lengthsp(charset, - def->ptr(), def->length())); + def->length(charset->lengthsp(def->ptr(), def->length())); not_found= !find_type2(interval, def->ptr(), def->length(), charset); } } @@ -3478,11 +3477,10 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, LEX_CSTRING* connect_string = &create_info->connect_string; if (connect_string->length != 0 && connect_string->length > CONNECT_STRING_MAXLEN && - (system_charset_info->cset->charpos(system_charset_info, - connect_string->str, - (connect_string->str + - connect_string->length), - CONNECT_STRING_MAXLEN) + (system_charset_info->charpos(connect_string->str, + (connect_string->str + + connect_string->length), + CONNECT_STRING_MAXLEN) < connect_string->length)) { my_error(ER_WRONG_STRING_LENGTH, MYF(0), @@ -4402,8 +4400,9 @@ bool validate_comment_length(THD *thd, LEX_CSTRING *comment, size_t max_len, uint err_code, const char *name) { DBUG_ENTER("validate_comment_length"); - size_t tmp_len= my_charpos(system_charset_info, comment->str, - comment->str + comment->length, max_len); + size_t tmp_len= system_charset_info->charpos(comment->str, + comment->str + comment->length, + max_len); if (tmp_len < comment->length) { if (thd->is_strict_mode()) diff --git a/sql/sql_time.cc b/sql/sql_time.cc index b128a7f7291..8a9311ae577 100644 --- a/sql/sql_time.cc +++ b/sql/sql_time.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. - Copyright (c) 2009, 2013 Monty Program Ab. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -338,9 +338,9 @@ to_ascii(CHARSET_INFO *cs, const char *srcend= src + src_length; char *dst0= dst, *dstend= dst + dst_length - 1; while (dst < dstend && - (cnvres= (cs->cset->mb_wc)(cs, &wc, - (const uchar*) src, - (const uchar*) srcend)) > 0 && + (cnvres= cs->mb_wc(&wc, + (const uchar*) src, + (const uchar*) srcend)) > 0 && wc < 128) { src+= cnvres; @@ -734,9 +734,7 @@ bool parse_date_time_format(timestamp_type format_type, this. If separators are used, they must be between each part */ if (format_length == 6 && !need_p && - !my_strnncoll(&my_charset_bin, - (const uchar *) format, 6, - (const uchar *) format_str, 6)) + !my_charset_bin.strnncoll(format, 6, format_str, 6)) return 0; if (separator_map == (1 | 2)) { @@ -757,9 +755,9 @@ bool parse_date_time_format(timestamp_type format_type, Between DATE and TIME we also allow space as separator */ if ((format_length == 12 && !need_p && - !my_strnncoll(&my_charset_bin, - (const uchar *) format, 12, - (const uchar*) known_date_time_formats[INTERNAL_FORMAT].datetime_format, + !my_charset_bin.strnncoll( + format, 12, + known_date_time_formats[INTERNAL_FORMAT].datetime_format, 12)) || (separators == 5 && separator_map == (1 | 2 | 8 | 16))) return 0; diff --git a/sql/sql_type.cc b/sql/sql_type.cc index 9e8375afd10..cbf620e85d1 100644 --- a/sql/sql_type.cc +++ b/sql/sql_type.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2015,2019 MariaDB + Copyright (c) 2015,2020 MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -5597,9 +5597,8 @@ cmp_item *Type_handler_timestamp_common::make_cmp_item(THD *thd, static int srtcmp_in(CHARSET_INFO *cs, const String *x,const String *y) { - return cs->coll->strnncollsp(cs, - (uchar *) x->ptr(),x->length(), - (uchar *) y->ptr(),y->length()); + return cs->strnncollsp(x->ptr(), x->length(), + y->ptr(), y->length()); } in_vector *Type_handler_string_result::make_in_vector(THD *thd, diff --git a/sql/sql_type.h b/sql/sql_type.h index 54e06b1ec6b..ce87c8e9d93 100644 --- a/sql/sql_type.h +++ b/sql/sql_type.h @@ -2,6 +2,7 @@ #define SQL_TYPE_H_INCLUDED /* Copyright (c) 2015 MariaDB Foundation. + Copyright (c) 2015, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2773,11 +2774,10 @@ public: default: return "UNKNOWN"; } } - int sortcmp(const String *s, const String *t) const + int sortcmp(const Binary_string *s, const Binary_string *t) const { - return collation->coll->strnncollsp(collation, - (uchar *) s->ptr(), s->length(), - (uchar *) t->ptr(), t->length()); + return collation->strnncollsp(s->ptr(), s->length(), + t->ptr(), t->length()); } }; @@ -3130,9 +3130,8 @@ public: const LEX_CSTRING &lex_cstring() const { return *this; } bool eq(const LEX_CSTRING &other) const { - return !my_strnncoll(system_charset_info, - (const uchar *) LEX_CSTRING::str, LEX_CSTRING::length, - (const uchar *) other.str, other.length); + return !system_charset_info->strnncoll(LEX_CSTRING::str, LEX_CSTRING::length, + other.str, other.length); } }; diff --git a/sql/sql_type_string.cc b/sql/sql_type_string.cc index 36acad36718..df46ef744f0 100644 --- a/sql/sql_type_string.cc +++ b/sql/sql_type_string.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2019 MariaDB + Copyright (c) 2019, 2020 MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,8 +28,8 @@ StringPack::pack(uchar *to, const uchar *from, uint max_length) const DBUG_PRINT("debug", ("length: %zu ", length)); if (length > local_char_length) - local_char_length= my_charpos(charset(), from, from + length, - local_char_length); + local_char_length= charset()->charpos(from, from + length, + local_char_length); set_if_smaller(length, local_char_length); /* @@ -44,7 +44,7 @@ StringPack::pack(uchar *to, const uchar *from, uint max_length) const length --; } else - length= charset()->cset->lengthsp(charset(), (const char*) from, length); + length= charset()->lengthsp((const char*) from, length); // Length always stored little-endian *to++= (uchar) length; @@ -97,9 +97,8 @@ StringPack::unpack(uchar *to, const uchar *from, const uchar *from_end, memcpy(to, from, length); // Pad the string with the pad character of the fields charset - charset()->cset->fill(charset(), - (char*) to + length, - m_octet_length - length, - charset()->pad_char); + charset()->fill((char*) to + length, + m_octet_length - length, + charset()->pad_char); return from+length; } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index c115d9352aa..c00ba42846a 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2010, 2019, MariaDB Corporation. + Copyright (c) 2010, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16762,7 +16762,7 @@ grant_role: { CHARSET_INFO *cs= system_charset_info; /* trim end spaces (as they'll be lost in mysql.user anyway) */ - $1.length= cs->cset->lengthsp(cs, $1.str, $1.length); + $1.length= cs->lengthsp($1.str, $1.length); ((char*) $1.str)[$1.length] = '\0'; if (unlikely($1.length == 0)) my_yyabort_error((ER_INVALID_ROLE, MYF(0), "")); diff --git a/sql/strfunc.cc b/sql/strfunc.cc index 61f6078c875..c488ab1afbb 100644 --- a/sql/strfunc.cc +++ b/sql/strfunc.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -50,7 +51,7 @@ ulonglong find_set(const TYPELIB *lib, char **err_pos, uint *err_len, bool *set_warning) { CHARSET_INFO *strip= cs ? cs : &my_charset_latin1; - const char *end= str + strip->cset->lengthsp(strip, str, length); + const char *end= str + strip->lengthsp(str, length); ulonglong found= 0; *err_pos= 0; // No error yet *err_len= 0; @@ -68,8 +69,8 @@ ulonglong find_set(const TYPELIB *lib, for ( ; pos < end; pos+= mblen) { my_wc_t wc; - if ((mblen= cs->cset->mb_wc(cs, &wc, (const uchar *) pos, - (const uchar *) end)) < 1) + if ((mblen= cs->mb_wc(&wc, (const uchar *) pos, + (const uchar *) end)) < 1) mblen= 1; // Not to hang on a wrong multibyte sequence if (wc == (my_wc_t) field_separator) break; @@ -170,8 +171,8 @@ uint find_type2(const TYPELIB *typelib, const char *x, size_t length, for (pos=0 ; (j=typelib->type_names[pos]) ; pos++) { - if (!my_strnncoll(cs, (const uchar*) x, length, - (const uchar*) j, typelib->type_lengths[pos])) + if (!cs->strnncoll(x, length, + j, typelib->type_lengths[pos])) DBUG_RETURN(pos+1); } DBUG_PRINT("exit",("Couldn't find type")); @@ -338,8 +339,8 @@ int find_string_in_array(LEX_CSTRING * const haystack, LEX_CSTRING * const needl { const LEX_CSTRING *pos; for (pos= haystack; pos->str; pos++) - if (!cs->coll->strnncollsp(cs, (uchar *) pos->str, pos->length, - (uchar *) needle->str, needle->length)) + if (!cs->strnncollsp(pos->str, pos->length, + needle->str, needle->length)) { return (int)(pos - haystack); } diff --git a/sql/table.cc b/sql/table.cc index d56981ce114..be2b8781399 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2008, 2019, MariaDB + Copyright (c) 2008, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -346,8 +346,7 @@ TABLE_SHARE *alloc_table_share(const char *db, const char *table_name, if (share->table_category == TABLE_CATEGORY_LOG) share->no_replicate= 1; if (key_length > 6 && - my_strnncoll(table_alias_charset, (const uchar*) key, 6, - (const uchar*) "mysql", 6) == 0) + table_alias_charset->strnncoll(key, 6, "mysql", 6) == 0) share->not_usable_by_query_cache= 1; init_sql_alloc(&share->stats_cb.mem_root, "share_stats", @@ -1834,7 +1833,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, { const CHARSET_INFO *cs= thd->variables.collation_database; /* unknown charset in frm_image[38] or pre-3.23 frm */ - if (use_mb(cs)) + if (cs->use_mb()) { /* Warn that we may be changing the size of character columns */ sql_print_warning("'%s' had no or invalid character set, " @@ -4743,7 +4742,7 @@ bool check_table_name(const char *name, size_t length, bool check_for_path_chars { #if defined(USE_MB) && defined(USE_MB_IDENT) last_char_is_space= my_isspace(system_charset_info, *name); - if (use_mb(system_charset_info)) + if (system_charset_info->use_mb()) { int len=my_ismbchar(system_charset_info, name, end); if (len) @@ -4778,7 +4777,7 @@ bool check_column_name(const char *name) { #if defined(USE_MB) && defined(USE_MB_IDENT) last_char_is_space= my_isspace(system_charset_info, *name); - if (use_mb(system_charset_info)) + if (system_charset_info->use_mb()) { int len=my_ismbchar(system_charset_info, name, name+system_charset_info->mbmaxlen); diff --git a/sql/transaction.cc b/sql/transaction.cc index aecee04c364..f0426b1fcc4 100644 --- a/sql/transaction.cc +++ b/sql/transaction.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -514,7 +515,8 @@ find_savepoint(THD *thd, LEX_CSTRING name) while (*sv) { - if (my_strnncoll(system_charset_info, (uchar *) name.str, name.length, + if (system_charset_info->strnncoll( + (uchar *) name.str, name.length, (uchar *) (*sv)->name, (*sv)->length) == 0) break; sv= &(*sv)->prev; diff --git a/sql/vers_string.h b/sql/vers_string.h index bde3f0dffed..4e173f86e6e 100644 --- a/sql/vers_string.h +++ b/sql/vers_string.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2018, MariaDB Corporation. + Copyright (c) 2018, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,9 +30,8 @@ struct Compare_table_names { DBUG_ASSERT(a.str[a.length] == 0); DBUG_ASSERT(b.str[b.length] == 0); - return my_strnncoll(table_alias_charset, - (uchar*)a.str, a.length, - (uchar*)b.str, b.length); + return table_alias_charset->strnncoll(a.str, a.length, + b.str, b.length); } }; diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 6f231ef2c36..2021e03bc62 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2004, 2015, Oracle and/or its affiliates. - Copyright (c) 2017, MariaDB Corporation. + Copyright (c) 2017, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -560,7 +560,7 @@ static bool append_ident(String *string, const char *name, size_t length, for (name_end= name+length; name < name_end; name+= clen) { uchar c= *(uchar *) name; - clen= my_charlen_fix(system_charset_info, name, name_end); + clen= system_charset_info->charlen_fix(name, name_end); if (clen == 1 && c == (uchar) quote_char && (result= string->append("e_char, 1, system_charset_info))) goto err; diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index 261074fa98d..eca580310ee 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -1,5 +1,6 @@ /* Copyright (c) 2008-2009, Patrick Galbraith & Antony Curtis +Copyright (c) 2020, MariaDB Corporation. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -510,7 +511,7 @@ bool append_ident(String *string, const char *name, size_t length, for (name_end= name+length; name < name_end; name+= clen) { uchar c= *(uchar *) name; - clen= my_charlen_fix(system_charset_info, name, name_end); + clen= system_charset_info->charlen_fix(name, name_end); if (clen == 1 && c == (uchar) quote_char && (result= string->append("e_char, 1, system_charset_info))) goto err; diff --git a/storage/heap/hp_create.c b/storage/heap/hp_create.c index 171756071eb..8bd653f1b84 100644 --- a/storage/heap/hp_create.c +++ b/storage/heap/hp_create.c @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2018, Oracle and/or its affiliates. - Copyright (c) 2010, 2018, MariaDB Corporation. + Copyright (c) 2010, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -93,7 +93,7 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info, keyinfo->seg[j].flag|= HA_SWAP_KEY; break; case HA_KEYTYPE_VARBINARY1: - /* Case-insensitiveness is handled in coll->hash_sort */ + /* Case-insensitiveness is handled in hash_sort */ keyinfo->seg[j].type= HA_KEYTYPE_VARTEXT1; /* fall through */ case HA_KEYTYPE_VARTEXT1: @@ -110,7 +110,7 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info, keyinfo->seg[j].bit_start= 1; break; case HA_KEYTYPE_VARBINARY2: - /* Case-insensitiveness is handled in coll->hash_sort */ + /* Case-insensitiveness is handled in hash_sort */ /* fall_through */ case HA_KEYTYPE_VARTEXT2: keyinfo->flag|= HA_VAR_LENGTH_KEY; diff --git a/storage/heap/hp_hash.c b/storage/heap/hp_hash.c index 5c4b3b50290..00967dca52f 100644 --- a/storage/heap/hp_hash.c +++ b/storage/heap/hp_hash.c @@ -1,5 +1,6 @@ /* Copyright (c) 2000, 2010, Oracle and/or its affiliates + Copyright (c) 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,6 +20,14 @@ #include "heapdef.h" #include <m_ctype.h> + +static inline size_t +hp_charpos(CHARSET_INFO *cs, const uchar *b, const uchar *e, size_t num) +{ + return my_ci_charpos(cs, (const char*) b, (const char *) e, num); +} + + static ulong hp_hashnr(HP_KEYDEF *keydef, const uchar *key); /* Find out how many rows there is in the given range @@ -242,10 +251,10 @@ static ulong hp_hashnr(HP_KEYDEF *keydef, const uchar *key) if (cs->mbmaxlen > 1) { size_t char_length; - char_length= my_charpos(cs, pos, pos + length, length/cs->mbmaxlen); + char_length= hp_charpos(cs, pos, pos + length, length/cs->mbmaxlen); set_if_smaller(length, char_length); } - cs->coll->hash_sort(cs, pos, length, &nr, &nr2); + my_ci_hash_sort(cs, pos, length, &nr, &nr2); } else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */ { @@ -255,12 +264,12 @@ static ulong hp_hashnr(HP_KEYDEF *keydef, const uchar *key) if (cs->mbmaxlen > 1) { size_t char_length; - char_length= my_charpos(cs, pos +pack_length, + char_length= hp_charpos(cs, pos +pack_length, pos +pack_length + length, seg->length/cs->mbmaxlen); set_if_smaller(length, char_length); } - cs->coll->hash_sort(cs, pos+pack_length, length, &nr, &nr2); + my_ci_hash_sort(cs, pos+pack_length, length, &nr, &nr2); key+= pack_length; } else @@ -302,11 +311,11 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const uchar *rec) size_t char_length= seg->length; if (cs->mbmaxlen > 1) { - char_length= my_charpos(cs, pos, pos + char_length, + char_length= hp_charpos(cs, pos, pos + char_length, char_length / cs->mbmaxlen); set_if_smaller(char_length, seg->length); /* QQ: ok to remove? */ } - cs->coll->hash_sort(cs, pos, char_length, &nr, &nr2); + my_ci_hash_sort(cs, pos, char_length, &nr, &nr2); } else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */ { @@ -316,14 +325,14 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const uchar *rec) if (cs->mbmaxlen > 1) { size_t char_length; - char_length= my_charpos(cs, pos + pack_length, + char_length= hp_charpos(cs, pos + pack_length, pos + pack_length + length, seg->length/cs->mbmaxlen); set_if_smaller(length, char_length); } else set_if_smaller(length, seg->length); - cs->coll->hash_sort(cs, pos+pack_length, length, &nr, &nr2); + my_ci_hash_sort(cs, pos+pack_length, length, &nr, &nr2); } else { @@ -392,18 +401,18 @@ int hp_rec_key_cmp(HP_KEYDEF *keydef, const uchar *rec1, const uchar *rec2) if (cs->mbmaxlen > 1) { size_t char_length= seg->length / cs->mbmaxlen; - char_length1= my_charpos(cs, pos1, pos1 + seg->length, char_length); + char_length1= hp_charpos(cs, pos1, pos1 + seg->length, char_length); set_if_smaller(char_length1, seg->length); - char_length2= my_charpos(cs, pos2, pos2 + seg->length, char_length); + char_length2= hp_charpos(cs, pos2, pos2 + seg->length, char_length); set_if_smaller(char_length2, seg->length); } else { char_length1= char_length2= seg->length; } - if (seg->charset->coll->strnncollsp(seg->charset, - pos1,char_length1, - pos2,char_length2)) + if (my_ci_strnncollsp(seg->charset, + pos1, char_length1, + pos2, char_length2)) return 1; } else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */ @@ -430,9 +439,9 @@ int hp_rec_key_cmp(HP_KEYDEF *keydef, const uchar *rec1, const uchar *rec2) size_t safe_length1= char_length1; size_t safe_length2= char_length2; size_t char_length= seg->length / cs->mbmaxlen; - char_length1= my_charpos(cs, pos1, pos1 + char_length1, char_length); + char_length1= hp_charpos(cs, pos1, pos1 + char_length1, char_length); set_if_smaller(char_length1, safe_length1); - char_length2= my_charpos(cs, pos2, pos2 + char_length2, char_length); + char_length2= hp_charpos(cs, pos2, pos2 + char_length2, char_length); set_if_smaller(char_length2, safe_length2); } else @@ -441,9 +450,9 @@ int hp_rec_key_cmp(HP_KEYDEF *keydef, const uchar *rec1, const uchar *rec2) set_if_smaller(char_length2, seg->length); } - if (cs->coll->strnncollsp(seg->charset, - pos1, char_length1, - pos2, char_length2)) + if (my_ci_strnncollsp(seg->charset, + pos1, char_length1, + pos2, char_length2)) return 1; } else @@ -498,9 +507,9 @@ int hp_key_cmp(HP_KEYDEF *keydef, const uchar *rec, const uchar *key) if (cs->mbmaxlen > 1) { size_t char_length= seg->length / cs->mbmaxlen; - char_length_key= my_charpos(cs, key, key + seg->length, char_length); + char_length_key= hp_charpos(cs, key, key + seg->length, char_length); set_if_smaller(char_length_key, seg->length); - char_length_rec= my_charpos(cs, pos, pos + seg->length, char_length); + char_length_rec= hp_charpos(cs, pos, pos + seg->length, char_length); set_if_smaller(char_length_rec, seg->length); } else @@ -509,9 +518,9 @@ int hp_key_cmp(HP_KEYDEF *keydef, const uchar *rec, const uchar *key) char_length_rec= seg->length; } - if (seg->charset->coll->strnncollsp(seg->charset, - (uchar*) pos, char_length_rec, - (uchar*) key, char_length_key)) + if (my_ci_strnncollsp(seg->charset, + pos, char_length_rec, + key, char_length_key)) return 1; } else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */ @@ -529,17 +538,17 @@ int hp_key_cmp(HP_KEYDEF *keydef, const uchar *rec, const uchar *key) { size_t char_length1, char_length2; char_length1= char_length2= seg->length / cs->mbmaxlen; - char_length1= my_charpos(cs, key, key + char_length_key, char_length1); + char_length1= hp_charpos(cs, key, key + char_length_key, char_length1); set_if_smaller(char_length_key, char_length1); - char_length2= my_charpos(cs, pos, pos + char_length_rec, char_length2); + char_length2= hp_charpos(cs, pos, pos + char_length_rec, char_length2); set_if_smaller(char_length_rec, char_length2); } else set_if_smaller(char_length_rec, seg->length); - if (cs->coll->strnncollsp(seg->charset, - (uchar*) pos, char_length_rec, - (uchar*) key, char_length_key)) + if (my_ci_strnncollsp(seg->charset, + pos, char_length_rec, + key, char_length_key)) return 1; } else @@ -578,7 +587,7 @@ void hp_make_key(HP_KEYDEF *keydef, uchar *key, const uchar *rec) *key++= MY_TEST(rec[seg->null_pos] & seg->null_bit); if (cs->mbmaxlen > 1) { - char_length= my_charpos(cs, pos, pos + seg->length, + char_length= hp_charpos(cs, pos, pos + seg->length, char_length / cs->mbmaxlen); set_if_smaller(char_length, seg->length); /* QQ: ok to remove? */ } @@ -598,7 +607,7 @@ void hp_make_key(HP_KEYDEF *keydef, uchar *key, const uchar *rec) #define FIX_LENGTH(cs, pos, length, char_length) \ do { \ if (length > char_length) \ - char_length= my_charpos(cs, pos, pos+length, char_length); \ + char_length= hp_charpos(cs, pos, pos+length, char_length); \ set_if_smaller(char_length,length); \ } while(0) @@ -676,12 +685,12 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, uchar *key, char_length= seg->length; if (seg->charset->mbmaxlen > 1) { - char_length= my_charpos(seg->charset, + char_length= hp_charpos(seg->charset, rec + seg->start, rec + seg->start + char_length, char_length / seg->charset->mbmaxlen); set_if_smaller(char_length, seg->length); /* QQ: ok to remove? */ if (char_length < seg->length) - seg->charset->cset->fill(seg->charset, (char*) key + char_length, + my_ci_fill(seg->charset, (char*) key + char_length, seg->length - char_length, ' '); } if (seg->type == HA_KEYTYPE_BIT && seg->bit_length) @@ -750,11 +759,11 @@ uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old, char_length= seg->length; if (seg->charset->mbmaxlen > 1) { - char_length= my_charpos(seg->charset, old, old+char_length, + char_length= hp_charpos(seg->charset, old, old+char_length, char_length / seg->charset->mbmaxlen); set_if_smaller(char_length, seg->length); /* QQ: ok to remove? */ if (char_length < seg->length) - seg->charset->cset->fill(seg->charset, (char*) key + char_length, + my_ci_fill(seg->charset, (char*) key + char_length, seg->length - char_length, ' '); } memcpy(key, old, (size_t) char_length); diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index e6990f61d1a..ddab1deaa26 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2019, MariaDB Corporation. +Copyright (c) 2016, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -4533,8 +4533,8 @@ fts_get_token_size( int ctype; int mbl; - mbl = cs->cset->ctype( - cs, &ctype, + mbl = cs->ctype( + &ctype, reinterpret_cast<uchar*>(start), reinterpret_cast<uchar*>(end)); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 56dc0087045..03c88858676 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2257,11 +2257,10 @@ static bool is_mysql_datadir_path(const char *path) if (!lower_case_file_system) return(memcmp(mysql_data_dir, path_dir, mysql_data_home_len)); - return(files_charset_info->coll->strnncoll(files_charset_info, - (uchar *) path_dir, path_len, - (uchar *) mysql_data_dir, - mysql_data_home_len, - TRUE)); + return(files_charset_info->strnncoll((uchar *) path_dir, path_len, + (uchar *) mysql_data_dir, + mysql_data_home_len, + TRUE)); } /*********************************************************************//** @@ -6325,13 +6324,13 @@ wsrep_innobase_mysql_sort( ut_a(str_length <= tmp_length); memcpy(tmp_str, str, str_length); - tmp_length = charset->coll->strnxfrm(charset, str, str_length, - str_length, tmp_str, - tmp_length, 0); + tmp_length = charset->strnxfrm(str, str_length, + str_length, tmp_str, + tmp_length, 0); DBUG_ASSERT(tmp_length <= str_length); if (wsrep_protocol_version < 3) { - tmp_length = charset->coll->strnxfrm( - charset, str, str_length, + tmp_length = charset->strnxfrm( + str, str_length, str_length, tmp_str, tmp_length, 0); DBUG_ASSERT(tmp_length <= str_length); } else { @@ -6339,8 +6338,8 @@ wsrep_innobase_mysql_sort( protocols < 3 truncated the sorted sring protocols >= 3 gets full sorted sring */ - tmp_length = charset->coll->strnxfrm( - charset, str, buf_length, + tmp_length = charset->strnxfrm( + str, buf_length, str_length, tmp_str, str_length, 0); DBUG_ASSERT(tmp_length <= buf_length); ret_length = tmp_length; @@ -6434,7 +6433,7 @@ innobase_strnxfrm( return(0); } - my_strnxfrm(cs, (uchar*) mystr, 2, str, len); + cs->strnxfrm((uchar*) mystr, 2, str, len); value = mach_read_from_2(mystr); @@ -6486,7 +6485,7 @@ innobase_fts_casedn_str( return(strlen(dst)); } else { - return(cs->cset->casedn(cs, src, src_len, dst, dst_len)); + return(cs->casedn(src, src_len, dst, dst_len)); } } @@ -6523,8 +6522,7 @@ innobase_mysql_fts_get_token( int ctype; - mbl = cs->cset->ctype( - cs, &ctype, doc, (const uchar*) end); + mbl = cs->ctype(&ctype, doc, (const uchar*) end); if (true_word_char(ctype, *doc)) { break; @@ -6542,8 +6540,7 @@ innobase_mysql_fts_get_token( int ctype; - mbl = cs->cset->ctype( - cs, &ctype, (uchar*) doc, (uchar*) end); + mbl = cs->ctype(&ctype, (uchar*) doc, (uchar*) end); if (true_word_char(ctype, *doc)) { mwc = 0; } else if (!misc_word_char(*doc) || mwc) { @@ -17198,7 +17195,7 @@ innobase_get_at_most_n_mbchars( character. */ if (charset->mbmaxlen > 1) { - /* my_charpos() returns the byte length of the first n_chars + /* charpos() returns the byte length of the first n_chars characters, or a value bigger than the length of str, if there were not enough full characters in str. @@ -17216,7 +17213,7 @@ innobase_get_at_most_n_mbchars( characters, and we can store in the column prefix index the whole string. */ - char_length= my_charpos(charset, str, str + data_len, n_chars); + char_length= charset->charpos(str, str + data_len, n_chars); if (char_length > data_len) { char_length = data_len; } diff --git a/storage/innobase/include/fts0tokenize.h b/storage/innobase/include/fts0tokenize.h index ddfb5bbabfd..1cddaf5bf67 100644 --- a/storage/innobase/include/fts0tokenize.h +++ b/storage/innobase/include/fts0tokenize.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2014, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -91,7 +92,7 @@ fts_get_word( while (doc < end) { for (; doc < end; doc += (mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1))) { - mbl = cs->cset->ctype(cs, &ctype, doc, end); + mbl = cs->ctype(&ctype, doc, end); if (true_word_char(ctype, *doc)) { break; @@ -153,7 +154,7 @@ fts_get_word( for (word->pos = doc; doc < end; length++, doc += (mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1))) { - mbl = cs->cset->ctype(cs, &ctype, doc, end); + mbl = cs->ctype(&ctype, doc, end); if (true_word_char(ctype, *doc)) { mwc = 0; diff --git a/storage/innobase/include/fts0types.ic b/storage/innobase/include/fts0types.ic index e40fc657d7f..4974a7a6802 100644 --- a/storage/innobase/include/fts0types.ic +++ b/storage/innobase/include/fts0types.ic @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -185,12 +185,12 @@ fts_select_index_by_hash( char_len = my_mbcharlen_ptr(cs, reinterpret_cast<const char*>(str), reinterpret_cast<const char*>(str + len)); */ - size_t char_len = size_t(cs->cset->charlen(cs, str, str + len)); + size_t char_len = size_t(cs->charlen(str, str + len)); ut_ad(char_len <= len); /* Get collation hash code */ - cs->coll->hash_sort(cs, str, char_len, &nr1, &nr2); + my_ci_hash_sort(cs, str, char_len, &nr1, &nr2); return(nr1 % FTS_NUM_AUX_INDEX); } diff --git a/storage/innobase/include/rem0cmp.ic b/storage/innobase/include/rem0cmp.ic index 4230543615a..6e21382d187 100644 --- a/storage/innobase/include/rem0cmp.ic +++ b/storage/innobase/include/rem0cmp.ic @@ -92,8 +92,7 @@ cmp_dfield_dfield_like_prefix( uint cs_num = (uint) dtype_get_charset_coll(type->prtype); if (CHARSET_INFO* cs = get_charset(cs_num, MYF(MY_WME))) { - return(cs->coll->strnncoll( - cs, + return(cs->strnncoll( static_cast<const uchar*>( dfield_get_data(dfield1)), dfield_get_len(dfield1), diff --git a/storage/innobase/rem/rem0cmp.cc b/storage/innobase/rem/rem0cmp.cc index c0e82bd3ad7..a103cafa356 100644 --- a/storage/innobase/rem/rem0cmp.cc +++ b/storage/innobase/rem/rem0cmp.cc @@ -85,8 +85,7 @@ innobase_mysql_cmp( uint cs_num = (uint) dtype_get_charset_coll(prtype); if (CHARSET_INFO* cs = get_charset(cs_num, MYF(MY_WME))) { - return(cs->coll->strnncollsp( - cs, a, a_length, b, b_length)); + return(cs->strnncollsp(a, a_length, b, b_length)); } ib::fatal() << "Unable to find charset-collation " << cs_num; @@ -356,9 +355,7 @@ cmp_whole_field( return(0); case DATA_VARCHAR: case DATA_CHAR: - return(my_charset_latin1.coll->strnncollsp( - &my_charset_latin1, - a, a_length, b, b_length)); + return(my_charset_latin1.strnncollsp(a, a_length, b, b_length)); case DATA_BLOB: if (prtype & DATA_BINARY_TYPE) { ib::error() << "Comparing a binary BLOB" diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index 11471b5f703..c91f2cc333c 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -2,7 +2,7 @@ Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. -Copyright (c) 2015, 2019, MariaDB Corporation. +Copyright (c) 2015, 2020, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -4059,7 +4059,7 @@ rec_field_len_in_chars( return SIZE_T_MAX; } - return(cs->cset->numchars(cs, rec_field, rec_field + rec_field_len)); + return cs->numchars(rec_field, rec_field + rec_field_len); } /** Avoid the clustered index lookup if all the following conditions diff --git a/storage/maria/ma_ft_parser.c b/storage/maria/ma_ft_parser.c index dbad6c4e7f5..2dfb4a77557 100644 --- a/storage/maria/ma_ft_parser.c +++ b/storage/maria/ma_ft_parser.c @@ -1,4 +1,5 @@ /* Copyright (C) 2006 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + Copyright (c) 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -126,7 +127,7 @@ uchar maria_ft_get_word(CHARSET_INFO *cs, const uchar **start, { for (; doc < end; doc+= (mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1))) { - mbl= cs->cset->ctype(cs, &ctype, doc, end); + mbl= my_ci_ctype(cs, &ctype, doc, end); if (true_word_char(ctype, *doc)) break; if (*doc == FTB_RQUOT && param->quot) @@ -166,7 +167,7 @@ uchar maria_ft_get_word(CHARSET_INFO *cs, const uchar **start, for (word->pos= doc; doc < end; length++, doc+= (mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1))) { - mbl= cs->cset->ctype(cs, &ctype, doc, end); + mbl= my_ci_ctype(cs, &ctype, doc, end); if (true_word_char(ctype, *doc)) mwc=0; else if (!misc_word_char(*doc) || mwc) @@ -219,7 +220,7 @@ uchar maria_ft_simple_get_word(CHARSET_INFO *cs, uchar **start, { if (doc >= end) DBUG_RETURN(0); - mbl= cs->cset->ctype(cs, &ctype, doc, end); + mbl= my_ci_ctype(cs, &ctype, doc, end); if (true_word_char(ctype, *doc)) break; } @@ -228,7 +229,7 @@ uchar maria_ft_simple_get_word(CHARSET_INFO *cs, uchar **start, for (word->pos= doc; doc < end; length++, doc+= (mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1))) { - mbl= cs->cset->ctype(cs, &ctype, doc, end); + mbl= my_ci_ctype(cs, &ctype, doc, end); if (true_word_char(ctype, *doc)) mwc= 0; else if (!misc_word_char(*doc) || mwc) diff --git a/storage/maria/ma_key.c b/storage/maria/ma_key.c index 9e804a1e9dc..1cc9068a16a 100644 --- a/storage/maria/ma_key.c +++ b/storage/maria/ma_key.c @@ -1,4 +1,5 @@ /* Copyright (C) 2006 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + Copyright (c) 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -32,7 +33,9 @@ static int _ma_put_key_in_record(MARIA_HA *info, uint keynr, #define FIX_LENGTH(cs, pos, length, char_length) \ do { \ if (length > char_length) \ - char_length= (uint) my_charpos(cs, pos, pos+length, char_length); \ + char_length= (uint) my_ci_charpos(cs, (const char *) pos, \ + (const char *) pos+length, \ + char_length); \ set_if_smaller(char_length,length); \ } while(0) @@ -237,7 +240,7 @@ MARIA_KEY *_ma_make_key(MARIA_HA *info, MARIA_KEY *int_key, uint keynr, { if (type != HA_KEYTYPE_NUM) { - length= (uint) cs->cset->lengthsp(cs, (const char*)pos, length); + length= (uint) my_ci_lengthsp(cs, (const char*)pos, length); } else { @@ -312,7 +315,7 @@ MARIA_KEY *_ma_make_key(MARIA_HA *info, MARIA_KEY *int_key, uint keynr, FIX_LENGTH(cs, pos, length, char_length); memcpy(key, pos, char_length); if (length > char_length) - cs->cset->fill(cs, (char*) key+char_length, length-char_length, ' '); + my_ci_fill(cs, (char*) key+char_length, length-char_length, ' '); key+= length; } _ma_dpointer(info->s, key, filepos); @@ -438,7 +441,7 @@ MARIA_KEY *_ma_pack_key(register MARIA_HA *info, MARIA_KEY *int_key, FIX_LENGTH(cs, pos, length, char_length); memcpy(key, pos, char_length); if (length > char_length) - cs->cset->fill(cs, (char*) key+char_length, length-char_length, ' '); + my_ci_fill(cs, (char*) key+char_length, length-char_length, ' '); key+= length; } if (last_used_keyseg) @@ -545,8 +548,7 @@ static int _ma_put_key_in_record(register MARIA_HA *info, uint keynr, if (keyseg->type != (int) HA_KEYTYPE_NUM) { memcpy(pos,key,(size_t) length); - keyseg->charset->cset->fill(keyseg->charset, - (char*) pos + length, + my_ci_fill(keyseg->charset, (char*) pos + length, keyseg->length - length, ' '); } diff --git a/storage/maria/ma_test1.c b/storage/maria/ma_test1.c index 8a4d1e15917..0a116c21c24 100644 --- a/storage/maria/ma_test1.c +++ b/storage/maria/ma_test1.c @@ -1,4 +1,5 @@ /* Copyright (C) 2006 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + Copyright (c) 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -675,8 +676,7 @@ static void update_record(uchar *record) ptr=blob_key; memcpy(pos+4,&ptr,sizeof(char*)); /* Store pointer to new key */ if (keyinfo[0].seg[0].type != HA_KEYTYPE_NUM) - default_charset_info->cset->casedn(default_charset_info, - (char*) blob_key, length, + my_ci_casedn(default_charset_info, (char*) blob_key, length, (char*) blob_key, length); pos+=recinfo[0].length; } @@ -684,16 +684,14 @@ static void update_record(uchar *record) { uint pack_length= HA_VARCHAR_PACKLENGTH(recinfo[0].length-1); uint length= pack_length == 1 ? (uint) *(uchar*) pos : uint2korr(pos); - default_charset_info->cset->casedn(default_charset_info, - (char*) pos + pack_length, length, + my_ci_casedn(default_charset_info, (char*) pos + pack_length, length, (char*) pos + pack_length, length); pos+=recinfo[0].length; } else { if (keyinfo[0].seg[0].type != HA_KEYTYPE_NUM) - default_charset_info->cset->casedn(default_charset_info, - (char*) pos, keyinfo[0].seg[0].length, + my_ci_casedn(default_charset_info, (char*) pos, keyinfo[0].seg[0].length, (char*) pos, keyinfo[0].seg[0].length); pos+=recinfo[0].length; } diff --git a/storage/maria/ma_unique.c b/storage/maria/ma_unique.c index ce7967608b9..c9ad27c2a6c 100644 --- a/storage/maria/ma_unique.c +++ b/storage/maria/ma_unique.c @@ -1,4 +1,5 @@ /* Copyright (C) 2006 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + Copyright (c) 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -145,9 +146,9 @@ ha_checksum _ma_unique_hash(MARIA_UNIQUEDEF *def, const uchar *record) if (type == HA_KEYTYPE_TEXT || type == HA_KEYTYPE_VARTEXT1 || type == HA_KEYTYPE_VARTEXT2) { - keyseg->charset->coll->hash_sort(keyseg->charset, - (const uchar*) pos, length, &seed1, - &seed2); + my_ci_hash_sort(keyseg->charset, + (const uchar*) pos, length, + &seed1, &seed2); crc+= seed1; } else diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c index b400990d934..9f62250f760 100644 --- a/storage/myisam/ft_parser.c +++ b/storage/myisam/ft_parser.c @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -122,7 +123,7 @@ uchar ft_get_word(CHARSET_INFO *cs, const uchar **start, const uchar *end, { for (; doc < end; doc+= (mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1))) { - mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end); + mbl= my_ci_ctype(cs, &ctype, (uchar*)doc, (uchar*)end); if (true_word_char(ctype, *doc)) break; if (*doc == FTB_RQUOT && param->quot) @@ -161,7 +162,7 @@ uchar ft_get_word(CHARSET_INFO *cs, const uchar **start, const uchar *end, for (word->pos= doc; doc < end; length++, doc+= (mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1))) { - mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end); + mbl= my_ci_ctype(cs, &ctype, (uchar*)doc, (uchar*)end); if (true_word_char(ctype, *doc)) mwc=0; else if (!misc_word_char(*doc) || mwc) @@ -214,7 +215,7 @@ uchar ft_simple_get_word(CHARSET_INFO *cs, uchar **start, const uchar *end, { if (doc >= end) DBUG_RETURN(0); - mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end); + mbl= my_ci_ctype(cs, &ctype, (uchar*)doc, (uchar*)end); if (true_word_char(ctype, *doc)) break; } @@ -223,7 +224,7 @@ uchar ft_simple_get_word(CHARSET_INFO *cs, uchar **start, const uchar *end, for (word->pos= doc; doc < end; length++, doc+= (mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1))) { - mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end); + mbl= my_ci_ctype(cs, &ctype, (uchar*)doc, (uchar*)end); if (true_word_char(ctype, *doc)) mwc= 0; else if (!misc_word_char(*doc) || mwc) diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c index dd838a05ada..496fa852f14 100644 --- a/storage/myisam/mi_key.c +++ b/storage/myisam/mi_key.c @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,7 +28,9 @@ #define FIX_LENGTH(cs, pos, length, char_length) \ do { \ if (length > char_length) \ - char_length= my_charpos(cs, pos, pos+length, char_length); \ + char_length= my_ci_charpos(cs, (const char *) pos, \ + (const char *) pos+length, \ + char_length); \ set_if_smaller(char_length,length); \ } while(0) @@ -109,7 +112,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, { if (type != HA_KEYTYPE_NUM) { - length= cs->cset->lengthsp(cs, (char*) pos, length); + length= my_ci_lengthsp(cs, (char*) pos, length); } else { @@ -183,7 +186,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, FIX_LENGTH(cs, pos, length, char_length); memcpy((uchar*) key, pos, char_length); if (length > char_length) - cs->cset->fill(cs, (char*) key+char_length, length-char_length, ' '); + my_ci_fill(cs, (char*) key+char_length, length-char_length, ' '); key+= length; } _mi_dpointer(info,key,filepos); @@ -261,7 +264,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, } else if (type != HA_KEYTYPE_BINARY) { - length= cs->cset->lengthsp(cs, (char*) pos, length); + length= my_ci_lengthsp(cs, (char*) pos, length); } FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); @@ -292,7 +295,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, FIX_LENGTH(cs, pos, length, char_length); memcpy((uchar*) key, pos, char_length); if (length > char_length) - cs->cset->fill(cs, (char*) key+char_length, length-char_length, ' '); + my_ci_fill(cs, (char*) key+char_length, length-char_length, ' '); key+= length; } if (last_used_keyseg) @@ -380,8 +383,7 @@ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr, if (keyseg->type != (int) HA_KEYTYPE_NUM) { memcpy(pos,key,(size_t) length); - keyseg->charset->cset->fill(keyseg->charset, - (char*) pos + length, + my_ci_fill(keyseg->charset, (char*) pos + length, keyseg->length - length, ' '); } diff --git a/storage/myisam/mi_test1.c b/storage/myisam/mi_test1.c index daeaf957b4d..92a9c65b232 100644 --- a/storage/myisam/mi_test1.c +++ b/storage/myisam/mi_test1.c @@ -1,5 +1,6 @@ /* Copyright (c) 2000, 2011, Oracle and/or its affiliates + Copyright (c) 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -479,8 +480,7 @@ static void update_record(uchar *record) ptr=blob_key; memcpy(pos+4, &ptr, sizeof(char*)); /* Store pointer to new key */ if (keyinfo[0].seg[0].type != HA_KEYTYPE_NUM) - default_charset_info->cset->casedn(default_charset_info, - (char*) blob_key, length, + my_ci_casedn(default_charset_info, (char*) blob_key, length, (char*) blob_key, length); pos+=recinfo[1].length; } @@ -488,16 +488,14 @@ static void update_record(uchar *record) { uint pack_length= HA_VARCHAR_PACKLENGTH(recinfo[1].length-1); uint length= pack_length == 1 ? (uint) *(uchar*) pos : uint2korr(pos); - default_charset_info->cset->casedn(default_charset_info, - (char*) pos + pack_length, length, + my_ci_casedn(default_charset_info, (char*) pos + pack_length, length, (char*) pos + pack_length, length); pos+=recinfo[1].length; } else { if (keyinfo[0].seg[0].type != HA_KEYTYPE_NUM) - default_charset_info->cset->casedn(default_charset_info, - (char*) pos, keyinfo[0].seg[0].length, + my_ci_casedn(default_charset_info, (char*) pos, keyinfo[0].seg[0].length, (char*) pos, keyinfo[0].seg[0].length); pos+=recinfo[1].length; } diff --git a/storage/myisam/mi_unique.c b/storage/myisam/mi_unique.c index 5d16efb96a1..e1d7aeaa711 100644 --- a/storage/myisam/mi_unique.c +++ b/storage/myisam/mi_unique.c @@ -1,5 +1,6 @@ /* Copyright (c) 2000, 2010, Oracle and/or its affiliates + Copyright (c) 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -121,9 +122,9 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const uchar *record) if (type == HA_KEYTYPE_TEXT || type == HA_KEYTYPE_VARTEXT1 || type == HA_KEYTYPE_VARTEXT2) { - keyseg->charset->coll->hash_sort(keyseg->charset, - (const uchar*) pos, length, &seed1, - &seed2); + my_ci_hash_sort(keyseg->charset, + (const uchar*) pos, length, + &seed1, &seed2); crc^= seed1; } else diff --git a/storage/perfschema/pfs_instr_class.cc b/storage/perfschema/pfs_instr_class.cc index bde0836a250..fcfdfa2e097 100644 --- a/storage/perfschema/pfs_instr_class.cc +++ b/storage/perfschema/pfs_instr_class.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -633,7 +634,7 @@ static void configure_instr_class(PFS_instr_class *entry) Consecutive wildcards affect the count. */ - if (!my_wildcmp(&my_charset_latin1, + if (!my_charset_latin1.wildcmp( entry->m_name, entry->m_name+entry->m_name_length, e->m_name, e->m_name+e->m_name_length, '\\', '?','%')) diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc index 0d43d4da5c4..d8b5b50b4c4 100644 --- a/storage/rocksdb/rdb_datadic.cc +++ b/storage/rocksdb/rdb_datadic.cc @@ -1,5 +1,6 @@ /* Copyright (c) 2012,2013 Monty Program Ab + Copyright (c) 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2122,14 +2123,14 @@ int Rdb_key_def::unpack_utf8_str( while (src < src_end) { my_wc_t wc = (src[0] << 8) | src[1]; src += 2; - int res = cset->cset->wc_mb(cset, wc, dst, dst_end); + int res = cset->wc_mb(wc, dst, dst_end); DBUG_ASSERT(res > 0 && res <= 3); if (res < 0) return UNPACK_FAILURE; dst += res; } - cset->cset->fill(cset, reinterpret_cast<char *>(dst), dst_end - dst, - cset->pad_char); + cset->fill(reinterpret_cast<char *>(dst), dst_end - dst, + cset->pad_char); return UNPACK_SUCCESS; } @@ -2252,8 +2253,8 @@ void Rdb_key_def::pack_with_varchar_encoding( const size_t value_length = (field_var->length_bytes == 1) ? (uint)*field->ptr : uint2korr(field->ptr); - size_t xfrm_len = charset->coll->strnxfrm( - charset, buf, fpi->m_max_image_len, field_var->char_length(), + size_t xfrm_len = charset->strnxfrm( + buf, fpi->m_max_image_len, field_var->char_length(), field_var->ptr + field_var->length_bytes, value_length, 0); /* Got a mem-comparable image in 'buf'. Now, produce varlength encoding */ @@ -2364,11 +2365,11 @@ void Rdb_key_def::pack_with_varchar_space_pad( ? (uint)*field->ptr : uint2korr(field->ptr); - const size_t trimmed_len = charset->cset->lengthsp( - charset, (const char *)field_var->ptr + field_var->length_bytes, + const size_t trimmed_len = charset->lengthsp( + (const char *)field_var->ptr + field_var->length_bytes, value_length); - const size_t xfrm_len = charset->coll->strnxfrm( - charset, buf, fpi->m_max_image_len, field_var->char_length(), + const size_t xfrm_len = charset->strnxfrm( + buf, fpi->m_max_image_len, field_var->char_length(), field_var->ptr + field_var->length_bytes, trimmed_len, 0); /* Got a mem-comparable image in 'buf'. Now, produce varlength encoding */ @@ -2500,7 +2501,7 @@ static int unpack_charset( for (uint ii = 0; ii < src_len; ii += 2) { my_wc_t wc = (src[ii] << 8) | src[ii + 1]; - int res = cset->cset->wc_mb(cset, wc, dst + used, dst_end); + int res = cset->wc_mb(wc, dst + used, dst_end); DBUG_ASSERT(res > 0 && res <= 3); if (res < 0) { return UNPACK_FAILURE; @@ -2656,7 +2657,7 @@ int Rdb_key_def::unpack_binary_or_utf8_varchar_space_pad( my_wc_t wc = (src[0] << 8) | src[1]; src += 2; const CHARSET_INFO *cset = fpi->m_varchar_charset; - int res = cset->cset->wc_mb(cset, wc, dst, dst_end); + int res = cset->wc_mb(wc, dst, dst_end); DBUG_ASSERT(res <= 3); if (res <= 0) return UNPACK_FAILURE; dst += res; @@ -3054,14 +3055,14 @@ static void rdb_get_mem_comparable_space(const CHARSET_INFO *const cs, // multi-byte form of the ' ' (space) character uchar space_mb[MAX_MULTI_BYTE_CHAR_SIZE]; - const size_t space_mb_len = cs->cset->wc_mb( - cs, (my_wc_t)cs->pad_char, space_mb, space_mb + sizeof(space_mb)); + const size_t space_mb_len = cs->wc_mb( + (my_wc_t)cs->pad_char, space_mb, space_mb + sizeof(space_mb)); // mem-comparable image of the space character std::array<uchar, 20> space; - const size_t space_len = cs->coll->strnxfrm( - cs, space.data(), sizeof(space), 1, space_mb, space_mb_len, 0); + const size_t space_len = cs->strnxfrm( + space.data(), sizeof(space), 1, space_mb, space_mb_len, 0); Rdb_charset_space_info *const info = new Rdb_charset_space_info; info->space_xfrm_len = space_len; info->space_mb_len = space_mb_len; @@ -3313,7 +3314,7 @@ bool Rdb_field_packing::setup(const Rdb_key_def *const key_descr, field->field_length = field->char_length() * cs->mbmaxlen. */ const CHARSET_INFO *cs = field->charset(); - m_max_image_len = cs->coll->strnxfrmlen(cs, field->field_length); + m_max_image_len = cs->strnxfrmlen(field->field_length); } const bool is_varchar = (type == MYSQL_TYPE_VARCHAR); const CHARSET_INFO *cs = field->charset(); diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 8d635296854..079ca8d20d4 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -1,5 +1,5 @@ /* Copyright (C) 2008-2019 Kentoku Shiba - Copyright (C) 2019 MariaDB corp + Copyright (C) 2019, 2020, MariaDB corp This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1478,7 +1478,7 @@ int spider_db_append_name_with_quote_str_internal( { head_code = *name; #ifdef SPIDER_HAS_MY_CHARLEN - if ((length = my_charlen(cs, name, name_end)) < 1) + if ((length = my_ci_charlen(cs, (const uchar *) name, (const uchar *) name_end)) < 1) #else if (!(length = my_mbcharlen(cs, (uchar) head_code))) #endif diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 218eff970f7..ef405c68410 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -1,4 +1,5 @@ /* Copyright (C) 2012-2018 Kentoku Shiba + Copyright (c) 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -11641,13 +11642,13 @@ int spider_mbase_handler::append_limit( str->q_append(SPIDER_SQL_LIMIT_STR, SPIDER_SQL_LIMIT_LEN); if (offset) { - length = (uint32) (my_charset_bin.cset->longlong10_to_str)( - &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, offset); + length = (uint32) (my_charset_bin.longlong10_to_str)( + buf, SPIDER_LONGLONG_LEN + 1, -10, offset); str->q_append(buf, length); str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); } - length = (uint32) (my_charset_bin.cset->longlong10_to_str)( - &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, limit); + length = (uint32) (my_charset_bin.longlong10_to_str)( + buf, SPIDER_LONGLONG_LEN + 1, -10, limit); str->q_append(buf, length); } DBUG_RETURN(0); @@ -15783,13 +15784,13 @@ int spider_mbase_copy_table::append_limit( sql.q_append(SPIDER_SQL_LIMIT_STR, SPIDER_SQL_LIMIT_LEN); if (offset) { - length = (uint32) (my_charset_bin.cset->longlong10_to_str)( - &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, offset); + length = (uint32) (my_charset_bin.longlong10_to_str)( + buf, SPIDER_LONGLONG_LEN + 1, -10, offset); sql.q_append(buf, length); sql.q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); } - length = (uint32) (my_charset_bin.cset->longlong10_to_str)( - &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, limit); + length = (uint32) (my_charset_bin.longlong10_to_str)( + buf, SPIDER_LONGLONG_LEN + 1, -10, limit); sql.q_append(buf, length); } DBUG_RETURN(0); diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index 1a14537cd9f..74b1cae3c03 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -1,4 +1,5 @@ /* Copyright (C) 2012-2018 Kentoku Shiba + Copyright (c) 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -9109,20 +9110,20 @@ int spider_oracle_handler::append_limit( ((SPIDER_LONGLONG_LEN) * 2))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_BETWEEN_STR, SPIDER_SQL_BETWEEN_LEN); - length = (uint32) (my_charset_bin.cset->longlong10_to_str)( - &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, offset + 1); + length = (uint32) (my_charset_bin.longlong10_to_str)( + buf, SPIDER_LONGLONG_LEN + 1, -10, offset + 1); str->q_append(buf, length); str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); - length = (uint32) (my_charset_bin.cset->longlong10_to_str)( - &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, limit + offset); + length = (uint32) (my_charset_bin.longlong10_to_str)( + buf, SPIDER_LONGLONG_LEN + 1, -10, limit + offset); str->q_append(buf, length); } else { if (str->reserve(SPIDER_SQL_HS_LTEQUAL_LEN + (SPIDER_LONGLONG_LEN))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_HS_LTEQUAL_STR, SPIDER_SQL_HS_LTEQUAL_LEN); - length = (uint32) (my_charset_bin.cset->longlong10_to_str)( - &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, limit); + length = (uint32) (my_charset_bin.longlong10_to_str)( + buf, SPIDER_LONGLONG_LEN + 1, -10, limit); str->q_append(buf, length); } if (update_rownum_appended) @@ -13401,20 +13402,20 @@ int spider_oracle_copy_table::append_limit( ((SPIDER_LONGLONG_LEN) * 2))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); sql.q_append(SPIDER_SQL_BETWEEN_STR, SPIDER_SQL_BETWEEN_LEN); - length = (uint32) (my_charset_bin.cset->longlong10_to_str)( - &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, offset); + length = (uint32) (my_charset_bin.longlong10_to_str)( + buf, SPIDER_LONGLONG_LEN + 1, -10, offset); sql.q_append(buf, length); sql.q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); - length = (uint32) (my_charset_bin.cset->longlong10_to_str)( - &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, limit); + length = (uint32) (my_charset_bin.longlong10_to_str)( + buf, SPIDER_LONGLONG_LEN + 1, -10, limit); sql.q_append(buf, length); } else { if (sql.reserve(SPIDER_SQL_HS_LTEQUAL_LEN + (SPIDER_LONGLONG_LEN))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); sql.q_append(SPIDER_SQL_HS_LTEQUAL_STR, SPIDER_SQL_HS_LTEQUAL_LEN); - length = (uint32) (my_charset_bin.cset->longlong10_to_str)( - &my_charset_bin, buf, SPIDER_LONGLONG_LEN + 1, -10, limit); + length = (uint32) (my_charset_bin.longlong10_to_str)( + buf, SPIDER_LONGLONG_LEN + 1, -10, limit); sql.q_append(buf, length); } } diff --git a/storage/tokudb/hatoku_cmp.cc b/storage/tokudb/hatoku_cmp.cc index 5f82d1e48be..51f447da13e 100644 --- a/storage/tokudb/hatoku_cmp.cc +++ b/storage/tokudb/hatoku_cmp.cc @@ -6,6 +6,7 @@ This file is part of TokuDB Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. +Copyright (c) 2020, MariaDB Corporation. TokuDBis is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, @@ -727,8 +728,7 @@ static inline uchar* pack_toku_blob( max_num_bytes/charset->mbmaxlen : max_num_bytes); if (length > local_char_length) { - local_char_length= my_charpos( - charset, + local_char_length= charset->charpos( blob_buf, blob_buf+length, local_char_length @@ -817,8 +817,7 @@ static uchar* pack_toku_varstring_from_desc( key_part_length/charset->mbmaxlen : key_part_length); if (length > local_char_length) { - local_char_length= my_charpos( - charset, + local_char_length= charset->charpos( from_desc, from_desc+length, local_char_length @@ -880,8 +879,7 @@ static inline uchar* pack_toku_varstring( max_num_bytes/charset->mbmaxlen : max_num_bytes); if (length > local_char_length) { - local_char_length= my_charpos( - charset, + local_char_length= charset->charpos( from_mysql+length_bytes_in_mysql, from_mysql+length_bytes_in_mysql+length, local_char_length @@ -917,8 +915,7 @@ static inline int cmp_toku_string( charset = get_charset_from_num(charset_number); - ret_val = charset->coll->strnncollsp( - charset, + ret_val = charset->strnncollsp( a_buf, a_num_bytes, b_buf, diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index f2683726151..e7a218bdc47 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2009, 2014, SkySQL Ab. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -158,7 +158,7 @@ int my_strcasecmp_mb(CHARSET_INFO * cs,const char *s, const char *t) if (*s++ != *t++) return 1; } - else if (my_charlen(cs, t, t + cs->mbmaxlen) > 1) + else if (my_ci_charlen(cs, (const uchar *) t, (const uchar *) t + cs->mbmaxlen) > 1) return 1; else if (map[(uchar) *s++] != map[(uchar) *t++]) return 1; @@ -354,8 +354,8 @@ my_append_fix_badly_formed_tail(CHARSET_INFO *cs, for ( ; nchars; nchars--) { int chlen; - if ((chlen= cs->cset->charlen(cs, (const uchar*) from, - (const uchar *) from_end)) > 0) + if ((chlen= my_ci_charlen(cs, (const uchar*) from, + (const uchar *) from_end)) > 0) { /* Found a valid character */ /* chlen == 1..MBMAXLEN */ DBUG_ASSERT(chlen <= (int) cs->mbmaxlen); @@ -381,7 +381,7 @@ bad: if (!status->m_well_formed_error_pos) status->m_well_formed_error_pos= from; - if ((chlen= cs->cset->wc_mb(cs, '?', (uchar*) to, (uchar *) to_end)) <= 0) + if ((chlen= my_ci_wc_mb(cs, '?', (uchar*) to, (uchar *) to_end)) <= 0) break; /* Question mark does not fit into the destination */ to+= chlen; from++; @@ -403,8 +403,7 @@ my_copy_fix_mb(CHARSET_INFO *cs, size_t fixed_length; set_if_smaller(src_length, dst_length); - well_formed_nchars= cs->cset->well_formed_char_length(cs, - src, src + src_length, + well_formed_nchars= my_ci_well_formed_char_length(cs, src, src + src_length, nchars, status); DBUG_ASSERT(well_formed_nchars <= nchars); memmove(dst, src, (well_formed_length= status->m_source_end_pos - src)); @@ -450,8 +449,8 @@ uint my_instr_mb(CHARSET_INFO *cs, { int mb_len; - if (!cs->coll->strnncoll(cs, (uchar*) b, s_length, - (uchar*) s, s_length, 0)) + if (!my_ci_strnncoll(cs, (const uchar *) b, s_length, + (const uchar *) s, s_length, 0)) { if (nmatch) { @@ -660,7 +659,7 @@ my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)), static void pad_max_char(CHARSET_INFO *cs, char *str, char *end) { char buf[10]; - char buflen= cs->cset->native_to_mb(cs, cs->max_sort_char, (uchar*) buf, + char buflen= my_ci_native_to_mb(cs, cs->max_sort_char, (uchar*) buf, (uchar*) buf + sizeof(buf)); DBUG_ASSERT(buflen > 0); do @@ -875,7 +874,7 @@ my_like_range_generic(CHARSET_INFO *cs, { my_wc_t wc, wc2; int res; - if ((res= cs->cset->mb_wc(cs, &wc, (uchar*) ptr, (uchar*) end)) <= 0) + if ((res= my_ci_mb_wc(cs, &wc, (uchar*) ptr, (uchar*) end)) <= 0) { if (res == MY_CS_ILSEQ) /* Bad sequence */ return TRUE; /* min_length and max_length are not important */ @@ -885,7 +884,7 @@ my_like_range_generic(CHARSET_INFO *cs, if (wc == (my_wc_t) escape) { - if ((res= cs->cset->mb_wc(cs, &wc, (uchar*) ptr, (uchar*) end)) <= 0) + if ((res= my_ci_mb_wc(cs, &wc, (uchar*) ptr, (uchar*) end)) <= 0) { if (res == MY_CS_ILSEQ) return TRUE; /* min_length and max_length are not important */ @@ -899,26 +898,24 @@ my_like_range_generic(CHARSET_INFO *cs, ptr+= res; /* Put escape character to min_str and max_str */ - if ((res= cs->cset->wc_mb(cs, wc, - (uchar*) min_str, (uchar*) min_end)) <= 0) + if ((res= my_ci_wc_mb(cs, wc, (uchar*) min_str, (uchar*) min_end)) <= 0) goto pad_set_lengths; /* No space */ min_str+= res; - if ((res= cs->cset->wc_mb(cs, wc, - (uchar*) max_str, (uchar*) max_end)) <= 0) + if ((res= my_ci_wc_mb(cs, wc, (uchar*) max_str, (uchar*) max_end)) <= 0) goto pad_set_lengths; /* No space */ max_str+= res; continue; } else if (wc == (my_wc_t) w_one) { - if ((res= cs->cset->wc_mb(cs, cs->min_sort_char, - (uchar*) min_str, (uchar*) min_end)) <= 0) + if ((res= my_ci_wc_mb(cs, cs->min_sort_char, + (uchar*) min_str, (uchar*) min_end)) <= 0) goto pad_set_lengths; min_str+= res; - if ((res= cs->cset->wc_mb(cs, cs->max_sort_char, - (uchar*) max_str, (uchar*) max_end)) <= 0) + if ((res= my_ci_wc_mb(cs, cs->max_sort_char, + (uchar*) max_str, (uchar*) max_end)) <= 0) goto pad_set_lengths; max_str+= res; continue; @@ -939,7 +936,7 @@ my_like_range_generic(CHARSET_INFO *cs, if (contractions && my_uca_can_be_contraction_head(contractions, wc) && - (res= cs->cset->mb_wc(cs, &wc2, (uchar*) ptr, (uchar*) end)) > 0) + (res= my_ci_mb_wc(cs, &wc2, (uchar*) ptr, (uchar*) end)) > 0) { const uint16 *weight; if ((wc2 == (my_wc_t) w_one || wc2 == (my_wc_t) w_many)) @@ -964,13 +961,11 @@ my_like_range_generic(CHARSET_INFO *cs, charlen--; /* Put contraction head */ - if ((res= cs->cset->wc_mb(cs, wc, - (uchar*) min_str, (uchar*) min_end)) <= 0) + if ((res= my_ci_wc_mb(cs, wc, (uchar*) min_str, (uchar*) min_end)) <= 0) goto pad_set_lengths; min_str+= res; - if ((res= cs->cset->wc_mb(cs, wc, - (uchar*) max_str, (uchar*) max_end)) <= 0) + if ((res= my_ci_wc_mb(cs, wc, (uchar*) max_str, (uchar*) max_end)) <= 0) goto pad_set_lengths; max_str+= res; wc= wc2; /* Prepare to put contraction tail */ @@ -978,12 +973,10 @@ my_like_range_generic(CHARSET_INFO *cs, } /* Normal character, or contraction tail */ - if ((res= cs->cset->wc_mb(cs, wc, - (uchar*) min_str, (uchar*) min_end)) <= 0) + if ((res= my_ci_wc_mb(cs, wc, (uchar*) min_str, (uchar*) min_end)) <= 0) goto pad_set_lengths; min_str+= res; - if ((res= cs->cset->wc_mb(cs, wc, - (uchar*) max_str, (uchar*) max_end)) <= 0) + if ((res= my_ci_wc_mb(cs, wc, (uchar*) max_str, (uchar*) max_end)) <= 0) goto pad_set_lengths; max_str+= res; } @@ -1000,9 +993,9 @@ pad_min_max: Make sure to call fill() with proper "length" argument. */ res_length_diff= res_length % cs->mbminlen; - cs->cset->fill(cs, min_str, min_end - min_str - res_length_diff, + my_ci_fill(cs, min_str, min_end - min_str - res_length_diff, cs->min_sort_char); - cs->cset->fill(cs, max_str, max_end - max_str - res_length_diff, + my_ci_fill(cs, max_str, max_end - max_str - res_length_diff, cs->max_sort_char); /* In case of incomplete characters set the remainder to 0x00's */ @@ -1354,7 +1347,7 @@ size_t my_numcells_mb(CHARSET_INFO *cs, const char *b, const char *e) { int mb_len; uint pg; - if ((mb_len= cs->cset->mb_wc(cs, &wc, (uchar*) b, (uchar*) e)) <= 0) + if ((mb_len= my_ci_mb_wc(cs, &wc, (uchar*) b, (uchar*) e)) <= 0) { mb_len= 1; /* Let's think a wrong sequence takes 1 dysplay cell */ b++; @@ -1381,7 +1374,7 @@ int my_mb_ctype_mb(CHARSET_INFO *cs, int *ctype, const uchar *s, const uchar *e) { my_wc_t wc; - int res= cs->cset->mb_wc(cs, &wc, s, e); + int res= my_ci_mb_wc(cs, &wc, s, e); if (res <= 0 || wc > 0xFFFF) *ctype= 0; else diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 17cb51ff8cb..ccf6f12b415 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -1,5 +1,5 @@ /* Copyright (c) 2002, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB Corporation. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1446,7 +1446,7 @@ my_cset_init_8bit(struct charset_info_st *cs, MY_CHARSET_LOADER *loader) cs->caseup_multiply= 1; cs->casedn_multiply= 1; cs->pad_char= ' '; - if (!cs->to_lower || !cs->to_upper || !cs->ctype || !cs->tab_to_uni) + if (!cs->to_lower || !cs->to_upper || !cs->m_ctype || !cs->tab_to_uni) return TRUE; return create_fromuni(cs, loader); } @@ -1496,7 +1496,7 @@ int my_mb_ctype_8bit(CHARSET_INFO *cs, int *ctype, *ctype= 0; return MY_CS_TOOSMALL; } - *ctype= cs->ctype[*s + 1]; + *ctype= cs->m_ctype[*s + 1]; return 1; } @@ -2022,14 +2022,14 @@ my_strxfrm_pad_desc_and_reverse(CHARSET_INFO *cs, if (nweights && frmend < strend && (flags & MY_STRXFRM_PAD_WITH_SPACE)) { uint fill_length= MY_MIN((uint) (strend - frmend), nweights * cs->mbminlen); - cs->cset->fill(cs, (char*) frmend, fill_length, cs->pad_char); + my_ci_fill(cs, (char*) frmend, fill_length, cs->pad_char); frmend+= fill_length; } my_strxfrm_desc_and_reverse(str, frmend, flags, level); if ((flags & MY_STRXFRM_PAD_TO_MAXLEN) && frmend < strend) { size_t fill_length= strend - frmend; - cs->cset->fill(cs, (char*) frmend, fill_length, cs->pad_char); + my_ci_fill(cs, (char*) frmend, fill_length, cs->pad_char); frmend= strend; } return frmend - str; diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index cbf50c638fd..a046bf352c4 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2011, Oracle and/or its affiliates. - Copyright (c) 2009-2011, Monty Program Ab + Copyright (c) 2009, 2020, MariaDB Corporation. Copyright (C) 2003 by Sathit Jittanupat <jsat66@hotmail.com,jsat66@yahoo.com> * solving bug crash with long text field string @@ -613,7 +613,7 @@ my_strnxfrm_tis620(CHARSET_INFO *cs, if ((flags & MY_STRXFRM_PAD_TO_MAXLEN) && len < dstlen0) { size_t fill_length= dstlen0 - len; - cs->cset->fill(cs, (char*) dst + len, fill_length, cs->pad_char); + my_ci_fill(cs, (char*) dst + len, fill_length, cs->pad_char); len= dstlen0; } return len; diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 99a0d0f46ae..94b73335a4f 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -1,5 +1,5 @@ /* Copyright (c) 2004, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2015, MariaDB + Copyright (c) 2009, 2020, MariaDB This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -31507,8 +31507,7 @@ my_uca_scanner_contraction_find(my_uca_scanner *scanner, my_wc_t *wc) flag<<= 1) { int mblen; - if ((mblen= scanner->cs->cset->mb_wc(scanner->cs, &wc[clen], - s, scanner->send)) <= 0) + if ((mblen= my_ci_mb_wc(scanner->cs, &wc[clen], s, scanner->send)) <= 0) break; beg[clen]= s= s + mblen; if (!my_uca_can_be_contraction_part(&scanner->level->contractions, @@ -32343,8 +32342,7 @@ static my_coll_lexem_num my_coll_lexem_next(MY_COLL_LEXEM *lexem) { CHARSET_INFO *cs= &my_charset_utf8mb3_general_ci; my_wc_t wc; - int nbytes= cs->cset->mb_wc(cs, &wc, - (uchar *) beg, (uchar *) lexem->end); + int nbytes= my_ci_mb_wc(cs, &wc, (uchar *) beg, (uchar *) lexem->end); if (nbytes > 0) { rc= MY_COLL_LEXEM_CHAR; @@ -33720,7 +33718,7 @@ static my_bool my_coll_init_uca(struct charset_info_st *cs, MY_CHARSET_LOADER *loader) { cs->pad_char= ' '; - cs->ctype= my_charset_utf8mb3_unicode_ci.ctype; + cs->m_ctype= my_charset_utf8mb3_unicode_ci.m_ctype; if (!cs->caseinfo) cs->caseinfo= &my_unicase_default; return create_tailoring(cs, loader); @@ -33774,7 +33772,7 @@ static void my_uca_handler_map(struct charset_info_st *cs, instead of generic. */ #define MY_FUNCTION_NAME(x) my_uca_ ## x ## _generic -#define MY_MB_WC(scanner, wc, beg, end) (scanner->cs->cset->mb_wc(scanner->cs, wc, beg, end)) +#define MY_MB_WC(scanner, wc, beg, end) (my_ci_mb_wc(scanner->cs, wc, beg, end)) #define MY_LIKE_RANGE my_like_range_generic #define MY_UCA_ASCII_OPTIMIZE 0 #define MY_UCA_COMPILE_CONTRACTIONS 1 diff --git a/strings/ctype-uca.ic b/strings/ctype-uca.ic index b7108eb7f9d..e47f1e1fd82 100644 --- a/strings/ctype-uca.ic +++ b/strings/ctype-uca.ic @@ -1,5 +1,5 @@ /* - Copyright (c) 2018 MariaDB Corporation + Copyright (c) 2018, 2020, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -671,7 +671,7 @@ MY_FUNCTION_NAME(strnxfrm)(CHARSET_INFO *cs, */ if (flags & MY_STRXFRM_PAD_WITH_SPACE) - srclen= cs->cset->lengthsp(cs, (const char*) src, srclen); + srclen= my_ci_lengthsp(cs, (const char*) src, srclen); dst= MY_FUNCTION_NAME(strnxfrm_onelevel)(cs, &cs->uca->level[0], dst, de, nweights, src, srclen, flags); diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 71530b0a7c1..e4234a9582a 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1,5 +1,5 @@ /* Copyright (c) 2003, 2013, Oracle and/or its affiliates - Copyright (c) 2009, 2016, MariaDB + Copyright (c) 2009, 2020, MariaDB This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -143,12 +143,12 @@ my_copy_incomplete_char(CHARSET_INFO *cs, Make sure we didn't pad to an incorrect character. */ - if (cs->cset->charlen(cs, (uchar *) dst, (uchar *) dst + cs->mbminlen) == + if (my_ci_charlen(cs, (uchar *) dst, (uchar *) dst + cs->mbminlen) == (int) cs->mbminlen) return MY_CHAR_COPY_OK; if (fix && - cs->cset->wc_mb(cs, '?', (uchar *) dst, (uchar *) dst + cs->mbminlen) == + my_ci_wc_mb(cs, '?', (uchar *) dst, (uchar *) dst + cs->mbminlen) == (int) cs->mbminlen) return MY_CHAR_COPY_FIXED; @@ -733,7 +733,7 @@ my_l10tostr_mb2_or_mb4(CHARSET_INFO *cs, for ( db= dst, de= dst + len ; (dst < de) && *p ; p++) { - int cnvres= cs->cset->wc_mb(cs,(my_wc_t)p[0],(uchar*) dst, (uchar*) de); + int cnvres= my_ci_wc_mb(cs, (my_wc_t) p[0], (uchar*) dst, (uchar*) de); if (cnvres > 0) dst+= cnvres; else @@ -796,7 +796,7 @@ cnv: for ( db= dst, de= dst + len ; (dst < de) && *p ; p++) { - int cnvres= cs->cset->wc_mb(cs, (my_wc_t) p[0], (uchar*) dst, (uchar*) de); + int cnvres= my_ci_wc_mb(cs, (my_wc_t) p[0], (uchar*) dst, (uchar*) de); if (cnvres > 0) dst+= cnvres; else @@ -1057,7 +1057,7 @@ my_fill_mb2(CHARSET_INFO *cs, char *s, size_t slen, int fill) DBUG_ASSERT((slen % 2) == 0); - buflen= cs->cset->wc_mb(cs, (my_wc_t) fill, (uchar*) buf, + buflen= my_ci_wc_mb(cs, (my_wc_t) fill, (uchar*) buf, (uchar*) buf + sizeof(buf)); DBUG_ASSERT(buflen > 0); @@ -1367,7 +1367,7 @@ static void my_hash_sort_utf16(CHARSET_INFO *cs, const uchar *s, size_t slen, ulong *nr1, ulong *nr2) { - size_t lengthsp= cs->cset->lengthsp(cs, (const char *) s, slen); + size_t lengthsp= my_ci_lengthsp(cs, (const char *) s, slen); my_hash_sort_utf16_nopad(cs, s, lengthsp, nr1, nr2); } @@ -1402,7 +1402,7 @@ static int my_charlen_utf16(CHARSET_INFO *cs, const uchar *str, const uchar *end) { my_wc_t wc; - return cs->cset->mb_wc(cs, &wc, str, end); + return my_ci_mb_wc(cs, &wc, str, end); } @@ -1492,7 +1492,7 @@ static void my_hash_sort_utf16_bin(CHARSET_INFO *cs, const uchar *pos, size_t len, ulong *nr1, ulong *nr2) { - size_t lengthsp= cs->cset->lengthsp(cs, (const char *) pos, len); + size_t lengthsp= my_ci_lengthsp(cs, (const char *) pos, len); my_hash_sort_utf16_nopad_bin(cs, pos, lengthsp, nr1, nr2); } @@ -1733,7 +1733,7 @@ struct charset_info_st my_charset_utf16_nopad_bin= #define MY_FUNCTION_NAME(x) my_ ## x ## _utf16le_general_ci #define DEFINE_STRNXFRM_UNICODE #define DEFINE_STRNXFRM_UNICODE_NOPAD -#define MY_MB_WC(cs, pwc, s, e) (cs->cset->mb_wc(cs, pwc, s, e)) +#define MY_MB_WC(cs, pwc, s, e) (my_ci_mb_wc(cs, pwc, s, e)) #define OPTIMIZE_ASCII 0 #define UNICASE_MAXCHAR MY_UNICASE_INFO_DEFAULT_MAXCHAR #define UNICASE_PAGE0 my_unicase_default_page00 @@ -2599,8 +2599,7 @@ void my_fill_utf32(CHARSET_INFO *cs, #ifdef DBUG_ASSERT_EXISTS buflen= #endif - cs->cset->wc_mb(cs, (my_wc_t) fill, (uchar*) buf, - (uchar*) buf + sizeof(buf)); + my_ci_wc_mb(cs, (my_wc_t) fill, (uchar*) buf, (uchar*) buf + sizeof(buf)); DBUG_ASSERT(buflen == 4); while (s < e) { diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index bef6d198e22..3329b6d23ef 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2017, MariaDB + Copyright (c) 2009, 2020, MariaDB This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -4647,7 +4647,7 @@ my_strnxfrm_unicode_full_bin_internal(CHARSET_INFO *cs, for (; dst < de && *nweights; (*nweights)--) { int res; - if ((res= cs->cset->mb_wc(cs, &wc, src, se)) <= 0) + if ((res= my_ci_mb_wc(cs, &wc, src, se)) <= 0) break; src+= res; *dst++= (uchar) (wc >> 16); @@ -5332,7 +5332,7 @@ my_fill_utf8mb3_mb(CHARSET_INFO *cs, char *str, size_t length, int fill) { char *end= str + length; char buf[10]; - char buflen= cs->cset->native_to_mb(cs, (my_wc_t) fill, (uchar*) buf, + char buflen= my_ci_native_to_mb(cs, (my_wc_t) fill, (uchar*) buf, (uchar*) buf + sizeof(buf)); DBUG_ASSERT(buflen > 0); for ( ; str + buflen <= end ; ) @@ -7026,7 +7026,7 @@ static int my_charlen_filename(CHARSET_INFO *cs, const uchar *str, const uchar *end) { my_wc_t wc; - return cs->cset->mb_wc(cs, &wc, str, end); + return my_ci_mb_wc(cs, &wc, str, end); } diff --git a/strings/ctype.c b/strings/ctype.c index 40736ed4b5a..3fbe4143da2 100644 --- a/strings/ctype.c +++ b/strings/ctype.c @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2014, SkySQL Ab. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -434,7 +434,7 @@ scan_one_character(const char *s, const char *e, my_wc_t *wc) } else /* Non-escaped character */ { - int rc= cs->cset->mb_wc(cs, wc, (uchar *) s, (uchar *) e); + int rc= my_ci_mb_wc(cs, wc, (uchar *) s, (uchar *) e); if (rc > 0) return (size_t) rc; } @@ -639,7 +639,7 @@ static int cs_value(MY_XML_PARSER *st,const char *attr, size_t len) break; case _CS_CTYPEMAP: fill_uchar(i->ctype,MY_CS_CTYPE_TABLE_SIZE,attr,len); - i->cs.ctype=i->ctype; + i->cs.m_ctype=i->ctype; break; /* Special purpose commands */ @@ -867,8 +867,7 @@ my_string_metadata_get_mb(MY_STRING_METADATA *metadata, metadata->char_length++) { my_wc_t wc; - int mblen= cs->cset->mb_wc(cs, &wc, (const uchar *) str, - (const uchar *) strend); + int mblen= my_ci_mb_wc(cs, &wc, (const uchar *) str, (const uchar *) strend); if (mblen > 0) /* Assigned character */ { if (wc > 0x7F) @@ -929,7 +928,7 @@ my_string_repertoire(CHARSET_INFO *cs, const char *str, size_t length) my_wc_t wc; int chlen; for (; - (chlen= cs->cset->mb_wc(cs, &wc, (uchar*) str, (uchar*) strend)) > 0; + (chlen= my_ci_mb_wc(cs, &wc, (uchar*) str, (uchar*) strend)) > 0; str+= chlen) { if (wc > 0x7F) @@ -1053,7 +1052,7 @@ my_wc_to_printable_generic(CHARSET_INFO *cs, my_wc_t wc, if (my_is_printable(wc)) { - int mblen= cs->cset->wc_mb(cs, wc, str, end); + int mblen= my_ci_wc_mb(cs, wc, str, end); if (mblen > 0) return mblen; } @@ -1068,7 +1067,7 @@ my_wc_to_printable_generic(CHARSET_INFO *cs, my_wc_t wc, str0= str; for (i= 0; i < length; i++) { - if (cs->cset->wc_mb(cs, tmp[i], str, end) != (int) cs->mbminlen) + if (my_ci_wc_mb(cs, tmp[i], str, end) != (int) cs->mbminlen) { DBUG_ASSERT(0); return MY_CS_ILSEQ; diff --git a/strings/json_lib.c b/strings/json_lib.c index be2aa168e35..ea9961a15d0 100644 --- a/strings/json_lib.c +++ b/strings/json_lib.c @@ -1,3 +1,18 @@ +/* Copyright (c) 2016, 2020, MariaDB Corporation. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + #include <my_global.h> #include <string.h> #include <m_ctype.h> @@ -1510,8 +1525,7 @@ int json_append_ascii(CHARSET_INFO *json_cs, while (ascii < ascii_end) { int c_len; - if ((c_len= json_cs->cset->wc_mb(json_cs, (my_wc_t) *ascii, - json, json_end)) > 0) + if ((c_len= my_ci_wc_mb(json_cs, (my_wc_t) *ascii, json, json_end)) > 0) { json+= c_len; ascii++; @@ -1537,7 +1551,7 @@ int json_unescape(CHARSET_INFO *json_cs, while (json_read_string_const_chr(&s) == 0) { int c_len; - if ((c_len= res_cs->cset->wc_mb(res_cs, s.c_next, res, res_end)) > 0) + if ((c_len= my_ci_wc_mb(res_cs, s.c_next, res, res_end)) > 0) { res+= c_len; continue; @@ -1548,7 +1562,7 @@ int json_unescape(CHARSET_INFO *json_cs, Result charset doesn't support the json's character. Let's replace it with the '?' symbol. */ - if ((c_len= res_cs->cset->wc_mb(res_cs, '?', res, res_end)) > 0) + if ((c_len= my_ci_wc_mb(res_cs, '?', res, res_end)) > 0) { res+= c_len; continue; @@ -1607,14 +1621,14 @@ int json_escape(CHARSET_INFO *str_cs, { my_wc_t c_chr; int c_len; - if ((c_len= str_cs->cset->mb_wc(str_cs, &c_chr, str, str_end)) > 0) + if ((c_len= my_ci_mb_wc(str_cs, &c_chr, str, str_end)) > 0) { enum json_esc_char_classes c_class; str+= c_len; if (c_chr >= 0x60 || (c_class= json_escape_chr_map[c_chr]) == ESC_) { - if ((c_len= json_cs->cset->wc_mb(json_cs, c_chr, json, json_end)) > 0) + if ((c_len= my_ci_wc_mb(json_cs, c_chr, json, json_end)) > 0) { json+= c_len; continue; @@ -1629,9 +1643,8 @@ int json_escape(CHARSET_INFO *str_cs, c_class= ESC_U; } - if ((c_len= json_cs->cset->wc_mb(json_cs, '\\', json, json_end)) <= 0 || - (c_len= json_cs->cset->wc_mb(json_cs, - (c_class == ESC_BS) ? c_chr : c_class, + if ((c_len= my_ci_wc_mb(json_cs, '\\', json, json_end)) <= 0 || + (c_len= my_ci_wc_mb(json_cs, (c_class == ESC_BS) ? c_chr : c_class, json+= c_len, json_end)) <= 0) { /* JSON buffer is depleted. */ diff --git a/strings/my_strchr.c b/strings/my_strchr.c index 6b1564c7ee1..323cbd0a37f 100644 --- a/strings/my_strchr.c +++ b/strings/my_strchr.c @@ -1,5 +1,5 @@ /* Copyright (c) 2005, 2011, Oracle and/or its affiliates. - Copyright (c) 2009-2011, Monty Program Ab + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -38,7 +38,8 @@ const char *acc_end= (ACC) + (LEN); \ for (ptr_str= (STR) ; ptr_str < (END) ; ptr_str+= mbl) \ { \ - mbl= my_charlen_fix((CS), ptr_str, (END)); \ + mbl= my_ci_charlen_fix((CS), (const uchar *) ptr_str, \ + (const uchar *) (END)); \ if (mbl < 2) \ { \ DBUG_ASSERT(mbl == 1); \ diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c index 5a161612bc5..add0bd422e8 100644 --- a/strings/my_vsnprintf.c +++ b/strings/my_vsnprintf.c @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2011, Oracle and/or its affiliates. - Copyright (c) 2009-2011, Monty Program Ab + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -167,7 +167,7 @@ static char *backtick_string(CHARSET_INFO *cs, char *to, const char *end, for ( ; par < par_end; par+= char_len) { uchar c= *(uchar *) par; - char_len= my_charlen_fix(cs, par, par_end); + char_len= my_ci_charlen_fix(cs, (const uchar *) par, (const uchar *) par_end); if (char_len == 1 && c == (uchar) quote_char ) { if (start + 1 >= end) diff --git a/strings/strcoll.ic b/strings/strcoll.ic index e7d614ebdf5..d30535de0d5 100644 --- a/strings/strcoll.ic +++ b/strings/strcoll.ic @@ -1,5 +1,6 @@ /* Copyright (c) 2015, MariaDB Foundation + Copyright (c) 2015, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -156,7 +157,7 @@ bad: Compare two strings according to the collation, without handling the PAD SPACE property. - Note, cs->coll->strnncoll() is usually used to compare identifiers. + Note, strnncoll() is usually used to compare identifiers. Perhaps we should eventually (in 10.2?) create a new collation my_charset_utf8mb3_general_ci_no_pad and have only one comparison function in MY_COLLATION_HANDLER. @@ -307,11 +308,11 @@ MY_FUNCTION_NAME(strnxfrm)(CHARSET_INFO *cs, for (; dst < de && src < se && nweights; nweights--) { - if (my_charlen(cs, (const char *) src, (const char *) se) > 1) + if (my_ci_charlen(cs, src, se) > 1) { /* Note, it is safe not to check (src < se) - in the code below, because my_charlen() would + in the code below, because my_ci_charlen() would not return 2 if src was too short */ uint16 e= WEIGHT_MB2_FRM(src[0], src[1]); diff --git a/unittest/strings/strings-t.c b/unittest/strings/strings-t.c index fb526477234..768f0ba6b65 100644 --- a/unittest/strings/strings-t.c +++ b/unittest/strings/strings-t.c @@ -1,4 +1,5 @@ /* Copyright (c) 2010, Oracle and/or its affiliates + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,8 +29,8 @@ test_like_range_for_charset(CHARSET_INFO *cs, const char *src, size_t src_len) size_t min_len, max_len, min_well_formed_len, max_well_formed_len; int error= 0; - cs->coll->like_range(cs, src, src_len, '\\', '_', '%', - sizeof(min_str), min_str, max_str, &min_len, &max_len); + my_ci_like_range(cs, src, src_len, '\\', '_', '%', + sizeof(min_str), min_str, max_str, &min_len, &max_len); diag("min_len=%d\tmax_len=%d\t%s", (int) min_len, (int) max_len, cs->name); min_well_formed_len= my_well_formed_length(cs, min_str, min_str + min_len, @@ -626,8 +627,8 @@ strcollsp(CHARSET_INFO *cs, const STRNNCOLL_PARAM *param) for (p= param; p->a; p++) { char ahex[64], bhex[64]; - int res= cs->coll->strnncollsp(cs, (uchar *) p->a, p->alen, - (uchar *) p->b, p->blen); + int res= my_ci_strnncollsp(cs, (const uchar *) p->a, p->alen, + (const uchar *) p->b, p->blen); str2hex(ahex, sizeof(ahex), p->a, p->alen); str2hex(bhex, sizeof(bhex), p->b, p->blen); diag("%-20s %-10s %-10s %10d %10d%s", @@ -640,8 +641,8 @@ strcollsp(CHARSET_INFO *cs, const STRNNCOLL_PARAM *param) else { /* Test in reverse order */ - res= cs->coll->strnncollsp(cs, (uchar *) p->b, p->blen, - (uchar *) p->a, p->alen); + res= my_ci_strnncollsp(cs, (const uchar *) p->b, p->blen, + (const uchar *) p->a, p->alen); if (!eqres(res, -p->res)) { diag("Comparison in reverse order failed. Expected %d, got %d", @@ -776,9 +777,9 @@ int main() } ok(failed == 0, "Testing my_like_range_xxx() functions"); - diag("Testing cs->coll->strnncollsp()"); + diag("my_ci_strnncollsp()"); failed= test_strcollsp(); - ok(failed == 0, "Testing cs->coll->strnncollsp()"); + ok(failed == 0, "Testing my_ci_strnncollsp()"); return exit_status(); } |