00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021
00022 #include <drizzled/function/str/str_conv.h>
00023
00024 namespace drizzled
00025 {
00026
00027 String *Item_str_conv::val_str(String *str)
00028 {
00029 assert(fixed == 1);
00030 String *res;
00031 if (!(res=args[0]->val_str(str)))
00032 {
00033 null_value=1;
00034 return 0;
00035 }
00036 null_value=0;
00037 if (multiply == 1)
00038 {
00039 uint32_t len;
00040 res= copy_if_not_alloced(str,res,res->length());
00041 len= converter(collation.collation, (char*) res->ptr(), res->length(),
00042 (char*) res->ptr(), res->length());
00043 assert(len <= res->length());
00044 res->length(len);
00045 }
00046 else
00047 {
00048 uint32_t len= res->length() * multiply;
00049 tmp_value.alloc(len);
00050 tmp_value.set_charset(collation.collation);
00051 len= converter(collation.collation, (char*) res->ptr(), res->length(),
00052 (char*) tmp_value.ptr(), len);
00053 tmp_value.length(len);
00054 res= &tmp_value;
00055 }
00056 return res;
00057 }
00058
00059 void Item_func_lcase::fix_length_and_dec()
00060 {
00061 collation.set(args[0]->collation);
00062 multiply= collation.collation->casedn_multiply;
00063 converter= collation.collation->cset->casedn;
00064 max_length= args[0]->max_length * multiply;
00065 }
00066
00067 void Item_func_ucase::fix_length_and_dec()
00068 {
00069 collation.set(args[0]->collation);
00070 multiply= collation.collation->caseup_multiply;
00071 converter= collation.collation->cset->caseup;
00072 max_length= args[0]->max_length * multiply;
00073 }
00074
00075 }