17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_FUNCTION_STR_CONV_CHARSET_H
21
#define DRIZZLED_FUNCTION_STR_CONV_CHARSET_H
22
23
#include <drizzled/function/str/strfunc.h>
26
28
class Item_func_conv_charset :public Item_str_func
28
30
bool use_cached_value;
31
const charset_info_st *conv_charset; // keep it public
32
Item_func_conv_charset(Item *a, const charset_info_st * const cs) :Item_str_func(a)
33
const CHARSET_INFO *conv_charset; // keep it public
34
Item_func_conv_charset(Item *a, const CHARSET_INFO * const cs) :Item_str_func(a)
33
35
{ conv_charset= cs; use_cached_value= 0; safe= 0; }
34
Item_func_conv_charset(Item *a, const charset_info_st * const cs, bool cache_if_const)
36
Item_func_conv_charset(Item *a, const CHARSET_INFO * const cs, bool cache_if_const)
37
39
assert(args[0]->fixed);
39
41
if (cache_if_const && args[0]->const_item())
41
44
String tmp, *str= args[0]->val_str(&tmp);
45
if (!str || str_value.copy(str->ptr(), str->length(),
46
str->charset(), conv_charset, &errors))
45
str_value.copy(str->ptr(), str->length(), conv_charset);
46
48
use_cached_value= 1;
47
49
str_value.mark_as_const();
52
use_cached_value= false;
54
56
Conversion from and to "binary" is safe.
55
57
Conversion to Unicode is safe.
63
65
String *val_str(String *);
64
66
void fix_length_and_dec();
65
67
const char *func_name() const { return "convert"; }
66
virtual void print(String *str);
68
virtual void print(String *str, enum_query_type query_type);
69
71
} /* namespace drizzled */
73
#endif /* DRIZZLED_FUNCTION_STR_CONV_CHARSET_H */