17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#include <drizzled/server_includes.h>
21
21
#include <drizzled/dtcollation.h>
23
23
#include <drizzled/definitions.h>
24
#include "drizzled/internal/my_sys.h"
25
#include "drizzled/charset_info.h"
24
#include <mysys/my_sys.h>
25
#include <mystrings/m_ctype.h>
26
26
#include <drizzled/error.h>
27
27
#include <drizzled/function/str/conv_charset.h>
28
28
#include <drizzled/session.h>
29
#include "drizzled/charset.h"
32
left_is_superset(const DTCollation &left, const DTCollation &right)
34
/* Allow convert to Unicode */
35
if (left.collation->state & MY_CS_UNICODE &&
36
(left.derivation < right.derivation ||
37
(left.derivation == right.derivation &&
38
!(right.collation->state & MY_CS_UNICODE))))
40
/* Allow convert from ASCII */
41
if (right.repertoire == MY_REPERTOIRE_ASCII &&
42
(left.derivation < right.derivation ||
43
(left.derivation == right.derivation &&
44
!(left.repertoire == MY_REPERTOIRE_ASCII))))
46
/* Disallow conversion otherwise */
34
51
DTCollation::DTCollation()
36
53
collation= &my_charset_bin;
37
54
derivation= DERIVATION_NONE;
55
repertoire= MY_REPERTOIRE_UNICODE30;
44
62
collation= collation_arg;
45
63
derivation= derivation_arg;
64
set_repertoire_from_charset(collation_arg);
66
void DTCollation::set_repertoire_from_charset(const CHARSET_INFO * const cs)
68
repertoire= cs->state & MY_CS_PUREASCII ?
69
MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30;
59
84
collation= collation_arg;
60
85
derivation= derivation_arg;
86
set_repertoire_from_charset(collation_arg);
90
void DTCollation::set(const CHARSET_INFO * const collation_arg,
91
Derivation derivation_arg,
92
uint32_t repertoire_arg)
94
collation= collation_arg;
95
derivation= derivation_arg;
96
repertoire= repertoire_arg;
64
100
void DTCollation::set(const CHARSET_INFO * const collation_arg)
66
102
collation= collation_arg;
103
set_repertoire_from_charset(collation_arg);
106
143
else if ((flags & MY_COLL_ALLOW_SUPERSET_CONV) &&
107
collation->state & MY_CS_UNICODE &&
108
(derivation < dt.derivation ||
109
(derivation == dt.derivation &&
110
!(dt.collation->state & MY_CS_UNICODE))))
144
left_is_superset(*this, dt))
114
148
else if ((flags & MY_COLL_ALLOW_SUPERSET_CONV) &&
115
dt.collation->state & MY_CS_UNICODE &&
116
(dt.derivation < derivation ||
117
(dt.derivation == derivation &&
118
!(collation->state & MY_CS_UNICODE))))
149
left_is_superset(dt, *this))
157
188
if (derivation == DERIVATION_EXPLICIT)
159
set(0, DERIVATION_NONE);
190
set(0, DERIVATION_NONE, 0);
162
193
if (collation->state & MY_CS_BINSORT)
164
195
if (dt.collation->state & MY_CS_BINSORT)
169
200
const CHARSET_INFO * const bin= get_charset_by_csname(collation->csname, MY_CS_BINSORT);
170
201
set(bin, DERIVATION_NONE);
204
repertoire|= dt.repertoire;
268
if (!(conv= (*arg)->safe_charset_converter(coll.collation)))
299
if (!(conv= (*arg)->safe_charset_converter(coll.collation)) &&
300
((*arg)->collation.repertoire == MY_REPERTOIRE_ASCII))
301
conv= new Item_func_conv_charset(*arg, coll.collation, 1);
270
305
if (nargs >=2 && nargs <= 3)