summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/item_strfunc.cc35
-rw-r--r--sql/item_strfunc.h27
-rw-r--r--sql/mysql_priv.h3
-rw-r--r--sql/sql_string.h2
4 files changed, 40 insertions, 27 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 4808159fe98..c43f65c731c 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -902,7 +902,7 @@ void Item_func_insert::fix_length_and_dec()
}
-String *Item_func_lcase::val_str(String *str)
+String *Item_str_conv::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
String *res;
@@ -912,24 +912,25 @@ String *Item_func_lcase::val_str(String *str)
return 0; /* purecov: inspected */
}
null_value=0;
- res=copy_if_not_alloced(str,res,res->length());
- res->casedn();
- return res;
-}
-
-
-String *Item_func_ucase::val_str(String *str)
-{
- DBUG_ASSERT(fixed == 1);
- String *res;
- if (!(res=args[0]->val_str(str)))
+ if (multiply == 1)
{
- null_value=1; /* purecov: inspected */
- return 0; /* purecov: inspected */
+ uint len;
+ res= copy_if_not_alloced(str,res,res->length());
+ len= converter(collation.collation, (char*) res->ptr(), res->length(),
+ (char*) res->ptr(), res->length());
+ DBUG_ASSERT(len <= res->length());
+ res->length(len);
+ }
+ else
+ {
+ uint len= res->length() * multiply;
+ tmp_value.alloc(len);
+ tmp_value.set_charset(collation.collation);
+ len= converter(collation.collation, (char*) res->ptr(), res->length(),
+ (char*) tmp_value.ptr(), len);
+ tmp_value.length(len);
+ res= &tmp_value;
}
- null_value=0;
- res=copy_if_not_alloced(str,res,res->length());
- res->caseup();
return res;
}
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 95979408ccb..6df90cebdff 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -133,13 +133,14 @@ public:
class Item_str_conv :public Item_str_func
{
+protected:
+ uint multiply;
+ uint (*converter)(CHARSET_INFO *cs, char *src, uint srclen,
+ char *dst, uint dstlen);
+ String tmp_value;
public:
Item_str_conv(Item *item) :Item_str_func(item) {}
- void fix_length_and_dec()
- {
- collation.set(args[0]->collation);
- max_length = args[0]->max_length;
- }
+ String *val_str(String *);
};
@@ -147,16 +148,28 @@ class Item_func_lcase :public Item_str_conv
{
public:
Item_func_lcase(Item *item) :Item_str_conv(item) {}
- String *val_str(String *);
const char *func_name() const { return "lcase"; }
+ void fix_length_and_dec()
+ {
+ collation.set(args[0]->collation);
+ multiply= collation.collation->casedn_multiply;
+ converter= collation.collation->cset->casedn;
+ max_length= args[0]->max_length * multiply;
+ }
};
class Item_func_ucase :public Item_str_conv
{
public:
Item_func_ucase(Item *item) :Item_str_conv(item) {}
- String *val_str(String *);
const char *func_name() const { return "ucase"; }
+ void fix_length_and_dec()
+ {
+ collation.set(args[0]->collation);
+ multiply= collation.collation->caseup_multiply;
+ converter= collation.collation->cset->caseup;
+ max_length= args[0]->max_length * multiply;
+ }
};
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 7adb175ed1b..93494b72968 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -1354,7 +1354,8 @@ inline void mark_as_null_row(TABLE *table)
inline void table_case_convert(char * name, uint length)
{
if (lower_case_table_names)
- my_casedn(files_charset_info, name, length);
+ files_charset_info->cset->casedn(files_charset_info,
+ name, length, name, length);
}
inline const char *table_case_name(HA_CREATE_INFO *info, const char *name)
diff --git a/sql/sql_string.h b/sql/sql_string.h
index c05305d9265..ddae6368228 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -261,8 +261,6 @@ public:
}
bool fill(uint32 max_length,char fill);
void strip_sp();
- inline void caseup() { my_caseup(str_charset,Ptr,str_length); }
- inline void casedn() { my_casedn(str_charset,Ptr,str_length); }
friend int sortcmp(const String *a,const String *b, CHARSET_INFO *cs);
friend int stringcmp(const String *a,const String *b);
friend String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);