summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <bar@mysql.com>2005-01-11 19:58:53 +0400
committerunknown <bar@mysql.com>2005-01-11 19:58:53 +0400
commit7bb97a4ad8aee442d657de23093d1c9f4a2013d5 (patch)
treeecc798e982cba9fd21a33110f4949e5c6f437bf4 /sql
parent427bdc28ee59cb17f18738279727b48387345db2 (diff)
downloadmariadb-git-7bb97a4ad8aee442d657de23093d1c9f4a2013d5.tar.gz
Bug #7730 Server crash using soundex on an utf8 table
Don't use my_tolower: it works only for 8bit charsets.
Diffstat (limited to 'sql')
-rw-r--r--sql/item_strfunc.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 2a63c5355a4..d0190af042e 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1562,9 +1562,14 @@ void Item_func_soundex::fix_length_and_dec()
else return 0
*/
-static char get_scode(CHARSET_INFO *cs,char *ptr)
+static char soundex_toupper(char ch)
{
- uchar ch=my_toupper(cs,*ptr);
+ return (ch >= 'a' && ch <= 'z') ? ch - 'a' + 'A' : ch;
+}
+
+static char get_scode(char *ptr)
+{
+ uchar ch= soundex_toupper(*ptr);
if (ch < 'A' || ch > 'Z')
{
// Thread extended alfa (country spec)
@@ -1594,8 +1599,8 @@ String *Item_func_soundex::val_str(String *str)
from++; /* purecov: inspected */
if (from == end)
return &my_empty_string; // No alpha characters.
- *to++ = my_toupper(cs,*from); // Copy first letter
- last_ch = get_scode(cs,from); // code of the first letter
+ *to++ = soundex_toupper(*from); // Copy first letter
+ last_ch = get_scode(from); // code of the first letter
// for the first 'double-letter check.
// Loop on input letters until
// end of input (null) or output
@@ -1604,7 +1609,7 @@ String *Item_func_soundex::val_str(String *str)
{
if (!my_isalpha(cs,*from))
continue;
- ch=get_scode(cs,from);
+ ch=get_scode(from);
if ((ch != '0') && (ch != last_ch)) // if not skipped or double
{
*to++ = ch; // letter, copy to output