summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2020-01-26 20:27:13 +0400
committerAlexander Barkov <bar@mariadb.com>2020-01-28 12:29:23 +0400
commitf1e13fdc8d9e78f4529aa60b6a9b49c6ff063c66 (patch)
treece84da1deeea573be5be7db7d739a4c9ba9b40f8 /sql
parentdd68ba74f357aca074609cbd77491ed4ba390369 (diff)
downloadmariadb-git-f1e13fdc8d9e78f4529aa60b6a9b49c6ff063c66.tar.gz
MDEV-21581 Helper functions and methods for CHARSET_INFO
Diffstat (limited to 'sql')
-rw-r--r--sql/create_options.cc46
-rw-r--r--sql/debug_sync.cc12
-rw-r--r--sql/discover.cc11
-rw-r--r--sql/events.cc6
-rw-r--r--sql/field.cc212
-rw-r--r--sql/field.h13
-rw-r--r--sql/field_conv.cc27
-rw-r--r--sql/filesort.cc21
-rw-r--r--sql/gstream.cc4
-rw-r--r--sql/ha_partition.cc8
-rw-r--r--sql/handler.cc17
-rw-r--r--sql/item.cc21
-rw-r--r--sql/item_cmpfunc.cc23
-rw-r--r--sql/item_func.cc38
-rw-r--r--sql/item_func.h10
-rw-r--r--sql/item_jsonfunc.cc18
-rw-r--r--sql/item_strfunc.cc82
-rw-r--r--sql/item_sum.h8
-rw-r--r--sql/item_timefunc.cc17
-rw-r--r--sql/item_xmlfunc.cc18
-rw-r--r--sql/key.cc41
-rw-r--r--sql/mysqld.cc11
-rw-r--r--sql/mysqld.h5
-rw-r--r--sql/opt_range.cc15
-rw-r--r--sql/procedure.h11
-rw-r--r--sql/rpl_filter.cc9
-rw-r--r--sql/slave.cc4
-rw-r--r--sql/sp.cc7
-rw-r--r--sql/sp.h6
-rw-r--r--sql/sp_pcontext.cc11
-rw-r--r--sql/sp_pcontext.h6
-rw-r--r--sql/spatial.cc22
-rw-r--r--sql/sql_acl.cc6
-rw-r--r--sql/sql_class.cc4
-rw-r--r--sql/sql_class.h14
-rw-r--r--sql/sql_lex.cc26
-rw-r--r--sql/sql_load.cc16
-rw-r--r--sql/sql_parse.cc10
-rw-r--r--sql/sql_partition.cc12
-rw-r--r--sql/sql_plugin.cc15
-rw-r--r--sql/sql_repl.cc4
-rw-r--r--sql/sql_select.cc10
-rw-r--r--sql/sql_show.cc41
-rw-r--r--sql/sql_signal.cc5
-rw-r--r--sql/sql_string.cc13
-rw-r--r--sql/sql_string.h13
-rw-r--r--sql/sql_table.cc21
-rw-r--r--sql/sql_time.cc18
-rw-r--r--sql/sql_type.cc7
-rw-r--r--sql/sql_type.h13
-rw-r--r--sql/sql_type_string.cc15
-rw-r--r--sql/sql_yacc.yy4
-rw-r--r--sql/strfunc.cc15
-rw-r--r--sql/table.cc11
-rw-r--r--sql/transaction.cc4
-rw-r--r--sql/vers_string.h7
56 files changed, 489 insertions, 575 deletions
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,
- &not_used);
+ return my_charset_bin.strntod((char*) ptr, field_length, &end_not_used, &not_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,
- &not_used);
- return my_strntoll(&my_charset_bin, (char*) ptr, field_length, 10, NULL,
- &not_used);
+ return my_charset_bin.strntoull((char*) ptr, field_length, 10, NULL, &not_used);
+ return my_charset_bin.strntoll((char*) ptr, field_length, 10, NULL, &not_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);
diff --git a/sql/sp.h b/sql/sp.h
index 49bf1eb93cf..69dde53b34c 100644
--- a/sql/sp.h
+++ b/sql/sp.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
@@ -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);
}
};