1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_FUNCTIONS_STR_CONV_CHARSET_H
21
#define DRIZZLED_FUNCTIONS_STR_CONV_CHARSET_H
23
#include <drizzled/functions/str/strfunc.h>
25
class Item_func_conv_charset :public Item_str_func
27
bool use_cached_value;
30
const CHARSET_INFO *conv_charset; // keep it public
31
Item_func_conv_charset(Item *a, const CHARSET_INFO * const cs) :Item_str_func(a)
32
{ conv_charset= cs; use_cached_value= 0; safe= 0; }
33
Item_func_conv_charset(Item *a, const CHARSET_INFO * const cs, bool cache_if_const)
36
assert(args[0]->fixed);
38
if (cache_if_const && args[0]->const_item())
41
String tmp, *str= args[0]->val_str(&tmp);
42
if (!str || str_value.copy(str->ptr(), str->length(),
43
str->charset(), conv_charset, &errors))
46
str_value.mark_as_const();
53
Conversion from and to "binary" is safe.
54
Conversion to Unicode is safe.
55
Other kind of conversions are potentially lossy.
57
safe= (args[0]->collation.collation == &my_charset_bin ||
58
cs == &my_charset_bin ||
59
(cs->state & MY_CS_UNICODE));
62
String *val_str(String *);
63
void fix_length_and_dec();
64
const char *func_name() const { return "convert"; }
65
virtual void print(String *str, enum_query_type query_type);
68
#endif /* DRIZZLED_FUNCTIONS_STR_CONV_CHARSET_H */