summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2018-07-19 13:02:14 +0400
committerAlexander Barkov <bar@mariadb.com>2018-07-19 13:02:14 +0400
commite2ac4098ed507957ba6dac9b408d31054a8e6b6d (patch)
treec0213f7d7dad51e96117afe64ae46c1e9364c513 /sql
parentab58493db22d870cb6a470d6b0551cfc70dd09f3 (diff)
downloadmariadb-git-e2ac4098ed507957ba6dac9b408d31054a8e6b6d.tar.gz
Simplify caseup() and casedn() in charsets
After the MDEV-13118 fix there's no code in the server that wants caseup/casedn to change the argument in place for simple charsets. Let's remove this logic and always return the result in a new string for all charsets, both simple and complex. 1. Removing the optimization that *some* character sets used in casedn() and caseup(), which allowed (and required) to change the case in-place, overwriting the string passed as the "src" argument. Now all CHARSET_INFO's work in the same way: non of them change the source string in-place, all of them now convert case from the source string to the destination string, leaving the source string untouched. 2. Adding "const" qualifier to the "char *src" parameter to caseup() and casedn(). 3. Removing duplicate implementations in ctype-mb.c. Now both caseup() and casedn() implementations for all CJK character sets use internally the same function my_casefold_mb() (the former my_casefold_mb_varlen()). 4. Removing the "unused" attribute from parameters of some my_case{up|dn}_xxx() implementations, as the affected parameters are now *used* in the code. Previously these parameters were used only in DBUG_ASSERT().
Diffstat (limited to 'sql')
-rw-r--r--sql/item_strfunc.cc15
1 files changed, 3 insertions, 12 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 160e740a9f7..ba9f14fb63f 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1572,19 +1572,10 @@ String *Item_str_conv::val_str(String *str)
str->alloc((alloced_length= res->length() * multiply)))))
return 0;
- if (multiply == 1)
- {
- str->copy(*res); // Should not fail (it was alloced above)
- len= converter(collation.collation, (char*) str->ptr(), str->length(),
- (char*) str->ptr(), alloced_length);
- }
- else
- {
- len= converter(collation.collation, (char*) res->ptr(), res->length(),
- (char*) str->ptr(), alloced_length);
- str->set_charset(collation.collation);
- }
+ len= converter(collation.collation, (char*) res->ptr(), res->length(),
+ (char*) str->ptr(), alloced_length);
DBUG_ASSERT(len <= alloced_length);
+ str->set_charset(collation.collation);
str->length(len);
return str;
}