00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #pragma once
00021
00022 #include <drizzled/function/str/strfunc.h>
00023
00024 namespace drizzled {
00025
00026 class Item_func_conv_charset :public Item_str_func
00027 {
00028 bool use_cached_value;
00029 public:
00030 bool safe;
00031 const charset_info_st *conv_charset;
00032 Item_func_conv_charset(Item *a, const charset_info_st * const cs) :Item_str_func(a)
00033 { conv_charset= cs; use_cached_value= 0; safe= 0; }
00034 Item_func_conv_charset(Item *a, const charset_info_st * const cs, bool cache_if_const)
00035 :Item_str_func(a)
00036 {
00037 assert(args[0]->fixed);
00038 conv_charset= cs;
00039 if (cache_if_const && args[0]->const_item())
00040 {
00041 String tmp, *str= args[0]->val_str(&tmp);
00042 if (!str)
00043 null_value= 1;
00044 else
00045 str_value.copy(str->ptr(), str->length(), conv_charset);
00046 use_cached_value= 1;
00047 str_value.mark_as_const();
00048 safe= true;
00049 }
00050 else
00051 {
00052 use_cached_value= false;
00053
00054
00055
00056
00057
00058 safe= (args[0]->collation.collation == &my_charset_bin ||
00059 cs == &my_charset_bin ||
00060 (cs->state & MY_CS_UNICODE));
00061 }
00062 }
00063 String *val_str(String *);
00064 void fix_length_and_dec();
00065 const char *func_name() const { return "convert"; }
00066 virtual void print(String *str);
00067 };
00068
00069 }
00070