42
43
- Setting server default character set
45
bool my_charset_same(const charset_info_st *cs1, const charset_info_st *cs2)
47
return cs1 == cs2 || not strcmp(cs1->csname, cs2->csname);
46
bool my_charset_same(const charset_info_st *cs1, const charset_info_st *cs2)
48
return ((cs1 == cs2) || !strcmp(cs1->csname,cs2->csname));
50
static uint get_collation_number_internal(const char *name)
53
get_collation_number_internal(const char *name)
52
55
for (charset_info_st **cs= all_charsets;
53
56
cs < all_charsets+array_elements(all_charsets)-1;
64
static unsigned char* cs_alloc(size_t size)
67
static unsigned char *cs_alloc(size_t size)
66
69
memory_vector.push_back(new unsigned char[size]);
67
70
return memory_vector.back();
70
static void init_state_maps(charset_info_st *cs)
73
static bool init_state_maps(charset_info_st *cs)
72
cs->state_map= cs_alloc(256);
73
cs->ident_map= cs_alloc(256);
75
if (!(cs->state_map= cs_alloc(256)))
78
if (!(cs->ident_map= cs_alloc(256)))
75
81
unsigned char *state_map= cs->state_map;
76
82
unsigned char *ident_map= cs->ident_map;
130
137
cs->state|= MY_CS_AVAILABLE;
133
static void init_available_charsets(myf myflags)
140
static bool init_available_charsets(myf myflags)
136
144
We have to use charset_initialized to not lock on THR_LOCK_charset
137
145
inside get_internal_charset...
139
if (charset_initialized)
141
memset(&all_charsets, 0, sizeof(all_charsets));
142
init_compiled_charsets(myflags);
144
/* Copy compiled charsets */
145
for (charset_info_st**cs= all_charsets;
146
cs < all_charsets+array_elements(all_charsets)-1;
147
if (charset_initialized == false)
149
if (*cs && cs[0]->ctype)
150
init_state_maps(*cs);
149
charset_info_st **cs;
150
memset(&all_charsets, 0, sizeof(all_charsets));
151
init_compiled_charsets(myflags);
153
/* Copy compiled charsets */
154
for (cs=all_charsets;
155
cs < all_charsets+array_elements(all_charsets)-1 ;
161
if (init_state_maps(*cs))
166
charset_initialized= true;
168
assert(charset_initialized);
153
charset_initialized= true;
156
174
void free_charsets()
158
176
charset_initialized= false;
167
186
uint32_t get_collation_number(const char *name)
169
188
init_available_charsets(MYF(0));
170
189
return get_collation_number_internal(name);
173
193
uint32_t get_charset_number(const char *charset_name, uint32_t cs_flags)
175
195
charset_info_st **cs;
226
249
const charset_info_st *get_charset(uint32_t cs_number)
251
const charset_info_st *cs;
228
252
if (cs_number == default_charset_info->number)
229
253
return default_charset_info;
231
init_available_charsets(MYF(0)); /* If it isn't initialized */
255
(void) init_available_charsets(MYF(0)); /* If it isn't initialized */
233
257
if (!cs_number || cs_number >= array_elements(all_charsets)-1)
236
return get_internal_charset(cs_number);
260
cs= get_internal_charset(cs_number);
239
265
const charset_info_st *get_charset_by_name(const char *cs_name)
241
init_available_charsets(MYF(0)); /* If it isn't initialized */
242
uint32_t cs_number= get_collation_number(cs_name);
243
return cs_number ? get_internal_charset(cs_number) : NULL;
268
const charset_info_st *cs;
269
(void) init_available_charsets(MYF(0)); /* If it isn't initialized */
271
cs_number= get_collation_number(cs_name);
272
cs= cs_number ? get_internal_charset(cs_number) : NULL;
246
278
const charset_info_st *get_charset_by_csname(const char *cs_name, uint32_t cs_flags)
248
init_available_charsets(MYF(0)); /* If it isn't initialized */
249
uint32_t cs_number= get_charset_number(cs_name, cs_flags);
250
return cs_number ? get_internal_charset(cs_number) : NULL;
281
const charset_info_st *cs;
283
(void) init_available_charsets(MYF(0)); /* If it isn't initialized */
285
cs_number= get_charset_number(cs_name, cs_flags);
286
cs= cs_number ? get_internal_charset(cs_number) : NULL;