#include "mysys_priv.h"#include "mysys_err.h"#include <m_ctype.h>#include <m_string.h>#include <my_dir.h>#include <my_xml.h>Include dependency graph for charset.c:

Go to the source code of this file.
| static int add_collation | ( | CHARSET_INFO * | cs | ) | [static] |
Definition at line 206 of file charset.c.
References all_charsets, charset_info_st::binary_number, bzero, charset_info_st::coll, charset_info_st::comment, cs_copy_data(), charset_info_st::cset, charset_info_st::csname, get_collation_number_internal(), charset_info_st::max_sort_char, charset_info_st::min_sort_char, my_charset_ucs2_general_uca, MY_CS_AVAILABLE, MY_CS_BINSORT, MY_CS_COMPILED, MY_CS_CSSORT, MY_CS_LOADED, MY_CS_PRIMARY, my_once_alloc(), my_once_strdup(), MY_WME, MY_XML_ERROR, MY_XML_OK, MYF, charset_info_st::name, NULL, charset_info_st::number, charset_info_st::primary_number, simple_cs_init_functions(), simple_cs_is_full(), charset_info_st::sort_order, sort_order, charset_info_st::state, strcmp(), and charset_info_st::strxfrm_multiply.
00207 { 00208 if (cs->name && (cs->number || 00209 (cs->number=get_collation_number_internal(cs->name)))) 00210 { 00211 if (!all_charsets[cs->number]) 00212 { 00213 if (!(all_charsets[cs->number]= 00214 (CHARSET_INFO*) my_once_alloc(sizeof(CHARSET_INFO),MYF(0)))) 00215 return MY_XML_ERROR; 00216 bzero((void*)all_charsets[cs->number],sizeof(CHARSET_INFO)); 00217 } 00218 00219 if (cs->primary_number == cs->number) 00220 cs->state |= MY_CS_PRIMARY; 00221 00222 if (cs->binary_number == cs->number) 00223 cs->state |= MY_CS_BINSORT; 00224 00225 all_charsets[cs->number]->state|= cs->state; 00226 00227 if (!(all_charsets[cs->number]->state & MY_CS_COMPILED)) 00228 { 00229 CHARSET_INFO *new= all_charsets[cs->number]; 00230 if (cs_copy_data(all_charsets[cs->number],cs)) 00231 return MY_XML_ERROR; 00232 00233 if (!strcmp(cs->csname,"ucs2") ) 00234 { 00235 #if defined(HAVE_CHARSET_ucs2) && defined(HAVE_UCA_COLLATIONS) 00236 new->cset= my_charset_ucs2_general_uca.cset; 00237 new->coll= my_charset_ucs2_general_uca.coll; 00238 new->strxfrm_multiply= my_charset_ucs2_general_uca.strxfrm_multiply; 00239 new->min_sort_char= my_charset_ucs2_general_uca.min_sort_char; 00240 new->max_sort_char= my_charset_ucs2_general_uca.max_sort_char; 00241 new->mbminlen= 2; 00242 new->mbmaxlen= 2; 00243 new->state |= MY_CS_AVAILABLE | MY_CS_LOADED; 00244 #endif 00245 } 00246 else 00247 { 00248 uchar *sort_order= all_charsets[cs->number]->sort_order; 00249 simple_cs_init_functions(all_charsets[cs->number]); 00250 new->mbminlen= 1; 00251 new->mbmaxlen= 1; 00252 if (simple_cs_is_full(all_charsets[cs->number])) 00253 { 00254 all_charsets[cs->number]->state |= MY_CS_LOADED; 00255 } 00256 all_charsets[cs->number]->state|= MY_CS_AVAILABLE; 00257 00258 /* 00259 Check if case sensitive sort order: A < a < B. 00260 We need MY_CS_FLAG for regex library, and for 00261 case sensitivity flag for 5.0 client protocol, 00262 to support isCaseSensitive() method in JDBC driver 00263 */ 00264 if (sort_order && sort_order['A'] < sort_order['a'] && 00265 sort_order['a'] < sort_order['B']) 00266 all_charsets[cs->number]->state|= MY_CS_CSSORT; 00267 } 00268 } 00269 else 00270 { 00271 /* 00272 We need the below to make get_charset_name() 00273 and get_charset_number() working even if a 00274 character set has not been really incompiled. 00275 The above functions are used for example 00276 in error message compiler extra/comp_err.c. 00277 If a character set was compiled, this information 00278 will get lost and overwritten in add_compiled_collation(). 00279 */ 00280 CHARSET_INFO *dst= all_charsets[cs->number]; 00281 dst->number= cs->number; 00282 if (cs->comment) 00283 if (!(dst->comment= my_once_strdup(cs->comment,MYF(MY_WME)))) 00284 return MY_XML_ERROR; 00285 if (cs->csname) 00286 if (!(dst->csname= my_once_strdup(cs->csname,MYF(MY_WME)))) 00287 return MY_XML_ERROR; 00288 if (cs->name) 00289 if (!(dst->name= my_once_strdup(cs->name,MYF(MY_WME)))) 00290 return MY_XML_ERROR; 00291 } 00292 cs->number= 0; 00293 cs->primary_number= 0; 00294 cs->binary_number= 0; 00295 cs->name= NULL; 00296 cs->state= 0; 00297 cs->sort_order= NULL; 00298 cs->state= 0; 00299 } 00300 return MY_XML_OK; 00301 }
Here is the call graph for this function:

| void add_compiled_collation | ( | CHARSET_INFO * | cs | ) |
Definition at line 371 of file charset.c.
References all_charsets, MY_CS_AVAILABLE, charset_info_st::number, and charset_info_st::state.
Referenced by init_compiled_charsets().
00372 { 00373 all_charsets[cs->number]= cs; 00374 cs->state|= MY_CS_AVAILABLE; 00375 }
Here is the caller graph for this function:

| static void* cs_alloc | ( | uint | size | ) | [static] |
Definition at line 377 of file charset.c.
References my_once_alloc(), MY_WME, and MYF.
00378 { 00379 return my_once_alloc(size, MYF(MY_WME)); 00380 }
Here is the call graph for this function:

| static int cs_copy_data | ( | CHARSET_INFO * | to, | |
| CHARSET_INFO * | from | |||
| ) | [static] |
Definition at line 134 of file charset.c.
References err, from, init_state_maps(), MY_CS_CTYPE_TABLE_SIZE, MY_CS_SORT_ORDER_TABLE_SIZE, MY_CS_TO_LOWER_TABLE_SIZE, MY_CS_TO_UNI_TABLE_SIZE, MY_CS_TO_UPPER_TABLE_SIZE, my_once_memdup(), my_once_strdup(), MY_WME, MYF, and to.
00135 { 00136 to->number= from->number ? from->number : to->number; 00137 00138 if (from->csname) 00139 if (!(to->csname= my_once_strdup(from->csname,MYF(MY_WME)))) 00140 goto err; 00141 00142 if (from->name) 00143 if (!(to->name= my_once_strdup(from->name,MYF(MY_WME)))) 00144 goto err; 00145 00146 if (from->comment) 00147 if (!(to->comment= my_once_strdup(from->comment,MYF(MY_WME)))) 00148 goto err; 00149 00150 if (from->ctype) 00151 { 00152 if (!(to->ctype= (uchar*) my_once_memdup((char*) from->ctype, 00153 MY_CS_CTYPE_TABLE_SIZE, 00154 MYF(MY_WME)))) 00155 goto err; 00156 if (init_state_maps(to)) 00157 goto err; 00158 } 00159 if (from->to_lower) 00160 if (!(to->to_lower= (uchar*) my_once_memdup((char*) from->to_lower, 00161 MY_CS_TO_LOWER_TABLE_SIZE, 00162 MYF(MY_WME)))) 00163 goto err; 00164 00165 if (from->to_upper) 00166 if (!(to->to_upper= (uchar*) my_once_memdup((char*) from->to_upper, 00167 MY_CS_TO_UPPER_TABLE_SIZE, 00168 MYF(MY_WME)))) 00169 goto err; 00170 if (from->sort_order) 00171 { 00172 if (!(to->sort_order= (uchar*) my_once_memdup((char*) from->sort_order, 00173 MY_CS_SORT_ORDER_TABLE_SIZE, 00174 MYF(MY_WME)))) 00175 goto err; 00176 00177 } 00178 if (from->tab_to_uni) 00179 { 00180 uint sz= MY_CS_TO_UNI_TABLE_SIZE*sizeof(uint16); 00181 if (!(to->tab_to_uni= (uint16*) my_once_memdup((char*)from->tab_to_uni, 00182 sz, MYF(MY_WME)))) 00183 goto err; 00184 } 00185 if (from->tailoring) 00186 if (!(to->tailoring= my_once_strdup(from->tailoring,MYF(MY_WME)))) 00187 goto err; 00188 00189 return 0; 00190 00191 err: 00192 return 1; 00193 }
Here is the call graph for this function:

| ulong escape_quotes_for_mysql | ( | CHARSET_INFO * | charset_info, | |
| char * | to, | |||
| ulong | to_length, | |||
| const char * | from, | |||
| ulong | length | |||
| ) |
Definition at line 739 of file charset.c.
References charset_info, FALSE, my_ismbchar, TRUE, USE_MB, and use_mb.
Referenced by mysql_real_escape_string().
00742 { 00743 const char *to_start= to; 00744 const char *end, *to_end=to_start + (to_length ? to_length-1 : 2*length); 00745 my_bool overflow= FALSE; 00746 #ifdef USE_MB 00747 my_bool use_mb_flag= use_mb(charset_info); 00748 #endif 00749 for (end= from + length; from < end; from++) 00750 { 00751 #ifdef USE_MB 00752 int tmp_length; 00753 if (use_mb_flag && (tmp_length= my_ismbchar(charset_info, from, end))) 00754 { 00755 if (to + tmp_length > to_end) 00756 { 00757 overflow= TRUE; 00758 break; 00759 } 00760 while (tmp_length--) 00761 *to++= *from++; 00762 from--; 00763 continue; 00764 } 00765 /* 00766 We don't have the same issue here with a non-multi-byte character being 00767 turned into a multi-byte character by the addition of an escaping 00768 character, because we are only escaping the ' character with itself. 00769 */ 00770 #endif 00771 if (*from == '\'') 00772 { 00773 if (to + 2 > to_end) 00774 { 00775 overflow= TRUE; 00776 break; 00777 } 00778 *to++= '\''; 00779 *to++= '\''; 00780 } 00781 else 00782 { 00783 if (to + 1 > to_end) 00784 { 00785 overflow= TRUE; 00786 break; 00787 } 00788 *to++= *from; 00789 } 00790 } 00791 *to= 0; 00792 return overflow ? (ulong)~0 : (ulong) (to - to_start); 00793 }
Here is the caller graph for this function:

| ulong escape_string_for_mysql | ( | CHARSET_INFO * | charset_info, | |
| char * | to, | |||
| ulong | to_length, | |||
| const char * | from, | |||
| ulong | length | |||
| ) |
Definition at line 599 of file charset.c.
References charset_info, FALSE, my_ismbchar, my_mbcharlen, TRUE, and use_mb.
Referenced by append_query_string(), insert_params_from_vars_with_log(), mysql_escape_string(), and mysql_real_escape_string().
00602 { 00603 const char *to_start= to; 00604 const char *end, *to_end=to_start + (to_length ? to_length-1 : 2*length); 00605 my_bool overflow= FALSE; 00606 #ifdef USE_MB 00607 my_bool use_mb_flag= use_mb(charset_info); 00608 #endif 00609 for (end= from + length; from < end; from++) 00610 { 00611 char escape= 0; 00612 #ifdef USE_MB 00613 int tmp_length; 00614 if (use_mb_flag && (tmp_length= my_ismbchar(charset_info, from, end))) 00615 { 00616 if (to + tmp_length > to_end) 00617 { 00618 overflow= TRUE; 00619 break; 00620 } 00621 while (tmp_length--) 00622 *to++= *from++; 00623 from--; 00624 continue; 00625 } 00626 /* 00627 If the next character appears to begin a multi-byte character, we 00628 escape that first byte of that apparent multi-byte character. (The 00629 character just looks like a multi-byte character -- if it were actually 00630 a multi-byte character, it would have been passed through in the test 00631 above.) 00632 00633 Without this check, we can create a problem by converting an invalid 00634 multi-byte character into a valid one. For example, 0xbf27 is not 00635 a valid GBK character, but 0xbf5c is. (0x27 = ', 0x5c = \) 00636 */ 00637 if (use_mb_flag && (tmp_length= my_mbcharlen(charset_info, *from)) > 1) 00638 escape= *from; 00639 else 00640 #endif 00641 switch (*from) { 00642 case 0: /* Must be escaped for 'mysql' */ 00643 escape= '0'; 00644 break; 00645 case '\n': /* Must be escaped for logs */ 00646 escape= 'n'; 00647 break; 00648 case '\r': 00649 escape= 'r'; 00650 break; 00651 case '\\': 00652 escape= '\\'; 00653 break; 00654 case '\'': 00655 escape= '\''; 00656 break; 00657 case '"': /* Better safe than sorry */ 00658 escape= '"'; 00659 break; 00660 case '\032': /* This gives problems on Win32 */ 00661 escape= 'Z'; 00662 break; 00663 } 00664 if (escape) 00665 { 00666 if (to + 2 > to_end) 00667 { 00668 overflow= TRUE; 00669 break; 00670 } 00671 *to++= '\\'; 00672 *to++= escape; 00673 } 00674 else 00675 { 00676 if (to + 1 > to_end) 00677 { 00678 overflow= TRUE; 00679 break; 00680 } 00681 *to++= *from; 00682 } 00683 } 00684 *to= 0; 00685 return overflow ? (ulong)~0 : (ulong) (to - to_start); 00686 }
Here is the caller graph for this function:

| void free_charsets | ( | void | ) |
Definition at line 431 of file charset.c.
References charset_initialized.
Referenced by clean_up(), my_end(), and mysql_server_end().
00432 { 00433 charset_initialized=0; 00434 }
Here is the caller graph for this function:

| CHARSET_INFO* get_charset | ( | uint | cs_number, | |
| myf | flags | |||
| ) |
Definition at line 505 of file charset.c.
References all_charsets, array_elements, default_charset_info, EE_UNKNOWN_CHARSET, FN_REFLEN, get_charsets_dir(), get_internal_charset(), init_available_charsets(), int10_to_str(), ME_BELL, MY_CHARSET_INDEX, my_error(), MY_WME, MYF, NULL, charset_info_st::number, and strmov().
Referenced by sys_var_collation::check(), sys_var_character_set::check(), do_verify_prepare_field(), Dbdict::handleTabInfo(), mi_open(), open_binary_frm(), NdbDictInterface::parseTableInfo(), read_texts(), and thd_init_client_charset().
00506 { 00507 CHARSET_INFO *cs; 00508 if (cs_number == default_charset_info->number) 00509 return default_charset_info; 00510 00511 (void) init_available_charsets(MYF(0)); /* If it isn't initialized */ 00512 00513 if (!cs_number || cs_number >= array_elements(all_charsets)-1) 00514 return NULL; 00515 00516 cs=get_internal_charset(cs_number, flags); 00517 00518 if (!cs && (flags & MY_WME)) 00519 { 00520 char index_file[FN_REFLEN], cs_string[23]; 00521 strmov(get_charsets_dir(index_file),MY_CHARSET_INDEX); 00522 cs_string[0]='#'; 00523 int10_to_str(cs_number, cs_string+1, 10); 00524 my_error(EE_UNKNOWN_CHARSET, MYF(ME_BELL), cs_string, index_file); 00525 } 00526 return cs; 00527 }
Here is the call graph for this function:

Here is the caller graph for this function:

| CHARSET_INFO* get_charset_by_csname | ( | const char * | cs_name, | |
| uint | cs_flags, | |||
| myf | flags | |||
| ) |
Definition at line 549 of file charset.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, EE_UNKNOWN_CHARSET, FN_REFLEN, get_charset_number(), get_charsets_dir(), get_internal_charset(), init_available_charsets(), ME_BELL, MY_CHARSET_INDEX, my_error(), MY_WME, MYF, NULL, and strmov().
Referenced by DTCollation::aggregate(), sys_var_character_set::check(), com_charset(), Event_timed::compile(), Item_func_md5::fix_length_and_dec(), Item_func_sha::fix_length_and_dec(), Item_func_set_collation::fix_length_and_dec(), get_old_charset_by_name(), get_options(), init_common_variables(), load_db_opt(), mysql_init_character_set(), mysql_prepare_table(), mysql_set_character_set(), MYSQLlex(), set_charset(), and usage().
00552 { 00553 uint cs_number; 00554 CHARSET_INFO *cs; 00555 DBUG_ENTER("get_charset_by_csname"); 00556 DBUG_PRINT("enter",("name: '%s'", cs_name)); 00557 00558 (void) init_available_charsets(MYF(0)); /* If it isn't initialized */ 00559 00560 cs_number= get_charset_number(cs_name, cs_flags); 00561 cs= cs_number ? get_internal_charset(cs_number, flags) : NULL; 00562 00563 if (!cs && (flags & MY_WME)) 00564 { 00565 char index_file[FN_REFLEN]; 00566 strmov(get_charsets_dir(index_file),MY_CHARSET_INDEX); 00567 my_error(EE_UNKNOWN_CHARSET, MYF(ME_BELL), cs_name, index_file); 00568 } 00569 00570 DBUG_RETURN(cs); 00571 }
Here is the call graph for this function:

Here is the caller graph for this function:

| CHARSET_INFO* get_charset_by_name | ( | const char * | cs_name, | |
| myf | flags | |||
| ) |
Definition at line 529 of file charset.c.
References EE_UNKNOWN_COLLATION, FN_REFLEN, get_charsets_dir(), get_collation_number(), get_internal_charset(), init_available_charsets(), ME_BELL, MY_CHARSET_INDEX, my_error(), MY_WME, MYF, NULL, and strmov().
Referenced by sys_var_collation::check(), Item_func_set_collation::fix_length_and_dec(), get_options(), init_common_variables(), load_db_opt(), main(), mysql_init_character_set(), and print_index().
00530 { 00531 uint cs_number; 00532 CHARSET_INFO *cs; 00533 (void) init_available_charsets(MYF(0)); /* If it isn't initialized */ 00534 00535 cs_number=get_collation_number(cs_name); 00536 cs= cs_number ? get_internal_charset(cs_number,flags) : NULL; 00537 00538 if (!cs && (flags & MY_WME)) 00539 { 00540 char index_file[FN_REFLEN]; 00541 strmov(get_charsets_dir(index_file),MY_CHARSET_INDEX); 00542 my_error(EE_UNKNOWN_COLLATION, MYF(ME_BELL), cs_name, index_file); 00543 } 00544 00545 return cs; 00546 }
Here is the call graph for this function:

Here is the caller graph for this function:

| const char* get_charset_name | ( | uint | charset_number | ) |
Definition at line 461 of file charset.c.
References all_charsets, init_available_charsets(), MYF, charset_info_st::name, and charset_info_st::number.
Referenced by descript(), open_table_error(), and print_field_types().
00462 { 00463 CHARSET_INFO *cs; 00464 init_available_charsets(MYF(0)); 00465 00466 cs=all_charsets[charset_number]; 00467 if (cs && (cs->number == charset_number) && cs->name ) 00468 return (char*) cs->name; 00469 00470 return (char*) "?"; /* this mimics find_type() */ 00471 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 444 of file charset.c.
References all_charsets, array_elements, init_available_charsets(), my_charset_latin1, my_strcasecmp, MYF, and charset_info_st::number.
Referenced by add_collation(), create_sys_files(), and get_charset_by_csname().
00445 { 00446 CHARSET_INFO **cs; 00447 init_available_charsets(MYF(0)); 00448 00449 for (cs= all_charsets; 00450 cs < all_charsets+array_elements(all_charsets)-1 ; 00451 cs++) 00452 { 00453 if ( cs[0] && cs[0]->csname && (cs[0]->state & cs_flags) && 00454 !my_strcasecmp(&my_charset_latin1, cs[0]->csname, charset_name)) 00455 return cs[0]->number; 00456 } 00457 return 0; 00458 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* get_charsets_dir | ( | char * | buf | ) |
Definition at line 346 of file charset.c.
References CHARSET_DIR, charsets_dir, convert_dirname(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, DEFAULT_CHARSET_HOME, FN_REFLEN, is_prefix(), NULL, NullS, SHAREDIR, strmake(), strxmov(), and test_if_hard_path().
Referenced by get_charset(), get_charset_by_csname(), get_charset_by_name(), get_internal_charset(), init_available_charsets(), mysql_init_character_set(), and mysql_set_character_set().
00347 { 00348 const char *sharedir= SHAREDIR; 00349 char *res; 00350 DBUG_ENTER("get_charsets_dir"); 00351 00352 if (charsets_dir != NULL) 00353 strmake(buf, charsets_dir, FN_REFLEN-1); 00354 else 00355 { 00356 if (test_if_hard_path(sharedir) || 00357 is_prefix(sharedir, DEFAULT_CHARSET_HOME)) 00358 strxmov(buf, sharedir, "/", CHARSET_DIR, NullS); 00359 else 00360 strxmov(buf, DEFAULT_CHARSET_HOME, "/", sharedir, "/", CHARSET_DIR, 00361 NullS); 00362 } 00363 res= convert_dirname(buf,buf,NullS); 00364 DBUG_PRINT("info",("charsets dir: '%s'", buf)); 00365 DBUG_RETURN(res); 00366 }
Here is the call graph for this function:

Here is the caller graph for this function:

| uint get_collation_number | ( | const char * | name | ) |
Definition at line 437 of file charset.c.
References get_collation_number_internal(), init_available_charsets(), and MYF.
Referenced by get_charset_by_name().
00438 { 00439 init_available_charsets(MYF(0)); 00440 return get_collation_number_internal(name); 00441 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static uint get_collation_number_internal | ( | const char * | name | ) | [static] |
Definition at line 42 of file charset.c.
References all_charsets, array_elements, my_charset_latin1, my_strcasecmp, and charset_info_st::number.
00043 { 00044 CHARSET_INFO **cs; 00045 for (cs= all_charsets; 00046 cs < all_charsets+array_elements(all_charsets)-1 ; 00047 cs++) 00048 { 00049 if ( cs[0] && cs[0]->name && 00050 !my_strcasecmp(&my_charset_latin1, cs[0]->name, name)) 00051 return cs[0]->number; 00052 } 00053 return 0; 00054 }
| static CHARSET_INFO* get_internal_charset | ( | uint | cs_number, | |
| myf | flags | |||
| ) | [static] |
Definition at line 474 of file charset.c.
References all_charsets, buf, charset_info_st::coll, cs_alloc(), charset_info_st::cset, charset_info_st::csname, FN_REFLEN, get_charsets_dir(), my_collation_handler_st::init, my_charset_handler_st::init, MY_CS_AVAILABLE, MY_CS_COMPILED, MY_CS_LOADED, MY_CS_READY, my_read_charset_file(), NULL, NullS, pthread_mutex_lock, pthread_mutex_unlock, charset_info_st::state, and strxmov().
00475 { 00476 char buf[FN_REFLEN]; 00477 CHARSET_INFO *cs; 00478 /* 00479 To make things thread safe we are not allowing other threads to interfere 00480 while we may changing the cs_info_table 00481 */ 00482 pthread_mutex_lock(&THR_LOCK_charset); 00483 if ((cs= all_charsets[cs_number])) 00484 { 00485 if (!(cs->state & MY_CS_COMPILED) && !(cs->state & MY_CS_LOADED)) 00486 { 00487 strxmov(get_charsets_dir(buf), cs->csname, ".xml", NullS); 00488 my_read_charset_file(buf,flags); 00489 } 00490 cs= (cs->state & MY_CS_AVAILABLE) ? cs : NULL; 00491 } 00492 if (cs && !(cs->state & MY_CS_READY)) 00493 { 00494 if ((cs->cset->init && cs->cset->init(cs, cs_alloc)) || 00495 (cs->coll->init && cs->coll->init(cs, cs_alloc))) 00496 cs= NULL; 00497 else 00498 cs->state|= MY_CS_READY; 00499 } 00500 pthread_mutex_unlock(&THR_LOCK_charset); 00501 return cs; 00502 }
Here is the call graph for this function:

Definition at line 386 of file charset.c.
References all_charsets, array_elements, bzero, charset_initialized, error, FALSE, FN_REFLEN, get_charsets_dir(), init_compiled_charsets(), init_state_maps(), MY_CHARSET_INDEX, my_read_charset_file(), NULL, pthread_mutex_lock, pthread_mutex_unlock, and strmov().
00388 { 00389 char fname[FN_REFLEN]; 00390 my_bool error=FALSE; 00391 /* 00392 We have to use charset_initialized to not lock on THR_LOCK_charset 00393 inside get_internal_charset... 00394 */ 00395 if (!charset_initialized) 00396 { 00397 CHARSET_INFO **cs; 00398 /* 00399 To make things thread safe we are not allowing other threads to interfere 00400 while we may changing the cs_info_table 00401 */ 00402 pthread_mutex_lock(&THR_LOCK_charset); 00403 if (!charset_initialized) 00404 { 00405 bzero(&all_charsets,sizeof(all_charsets)); 00406 init_compiled_charsets(myflags); 00407 00408 /* Copy compiled charsets */ 00409 for (cs=all_charsets; 00410 cs < all_charsets+array_elements(all_charsets)-1 ; 00411 cs++) 00412 { 00413 if (*cs) 00414 { 00415 if (cs[0]->ctype) 00416 if (init_state_maps(*cs)) 00417 *cs= NULL; 00418 } 00419 } 00420 00421 strmov(get_charsets_dir(fname), MY_CHARSET_INDEX); 00422 error= my_read_charset_file(fname,myflags); 00423 charset_initialized=1; 00424 } 00425 pthread_mutex_unlock(&THR_LOCK_charset); 00426 } 00427 return error; 00428 }
Here is the call graph for this function:

| static my_bool init_state_maps | ( | CHARSET_INFO * | cs | ) | [static] |
Definition at line 57 of file charset.c.
References charset_info_st::ident_map, my_isalpha, my_isdigit, my_isspace, MY_LEX_BOOL, MY_LEX_CHAR, MY_LEX_CMP_OP, MY_LEX_COMMENT, MY_LEX_END_LONG_COMMENT, MY_LEX_EOL, MY_LEX_ESCAPE, MY_LEX_IDENT, MY_LEX_IDENT_OR_BIN, MY_LEX_IDENT_OR_HEX, MY_LEX_IDENT_OR_NCHAR, MY_LEX_LONG_CMP_OP, MY_LEX_LONG_COMMENT, MY_LEX_NUMBER_IDENT, MY_LEX_REAL_OR_POINT, MY_LEX_SEMICOLON, MY_LEX_SET_VAR, MY_LEX_SKIP, MY_LEX_STRING, MY_LEX_STRING_OR_DELIMITER, MY_LEX_USER_END, MY_LEX_USER_VARIABLE_DELIMITER, my_mbcharlen, my_once_alloc(), MY_WME, MYF, and charset_info_st::state_map.
00058 { 00059 uint i; 00060 uchar *state_map; 00061 uchar *ident_map; 00062 00063 if (!(cs->state_map= (uchar*) my_once_alloc(256, MYF(MY_WME)))) 00064 return 1; 00065 00066 if (!(cs->ident_map= (uchar*) my_once_alloc(256, MYF(MY_WME)))) 00067 return 1; 00068 00069 state_map= cs->state_map; 00070 ident_map= cs->ident_map; 00071 00072 /* Fill state_map with states to get a faster parser */ 00073 for (i=0; i < 256 ; i++) 00074 { 00075 if (my_isalpha(cs,i)) 00076 state_map[i]=(uchar) MY_LEX_IDENT; 00077 else if (my_isdigit(cs,i)) 00078 state_map[i]=(uchar) MY_LEX_NUMBER_IDENT; 00079 #if defined(USE_MB) && defined(USE_MB_IDENT) 00080 else if (my_mbcharlen(cs, i)>1) 00081 state_map[i]=(uchar) MY_LEX_IDENT; 00082 #endif 00083 else if (my_isspace(cs,i)) 00084 state_map[i]=(uchar) MY_LEX_SKIP; 00085 else 00086 state_map[i]=(uchar) MY_LEX_CHAR; 00087 } 00088 state_map[(uchar)'_']=state_map[(uchar)'$']=(uchar) MY_LEX_IDENT; 00089 state_map[(uchar)'\'']=(uchar) MY_LEX_STRING; 00090 state_map[(uchar)'.']=(uchar) MY_LEX_REAL_OR_POINT; 00091 state_map[(uchar)'>']=state_map[(uchar)'=']=state_map[(uchar)'!']= (uchar) MY_LEX_CMP_OP; 00092 state_map[(uchar)'<']= (uchar) MY_LEX_LONG_CMP_OP; 00093 state_map[(uchar)'&']=state_map[(uchar)'|']=(uchar) MY_LEX_BOOL; 00094 state_map[(uchar)'#']=(uchar) MY_LEX_COMMENT; 00095 state_map[(uchar)';']=(uchar) MY_LEX_SEMICOLON; 00096 state_map[(uchar)':']=(uchar) MY_LEX_SET_VAR; 00097 state_map[0]=(uchar) MY_LEX_EOL; 00098 state_map[(uchar)'\\']= (uchar) MY_LEX_ESCAPE; 00099 state_map[(uchar)'/']= (uchar) MY_LEX_LONG_COMMENT; 00100 state_map[(uchar)'*']= (uchar) MY_LEX_END_LONG_COMMENT; 00101 state_map[(uchar)'@']= (uchar) MY_LEX_USER_END; 00102 state_map[(uchar) '`']= (uchar) MY_LEX_USER_VARIABLE_DELIMITER; 00103 state_map[(uchar)'"']= (uchar) MY_LEX_STRING_OR_DELIMITER; 00104 00105 /* 00106 Create a second map to make it faster to find identifiers 00107 */ 00108 for (i=0; i < 256 ; i++) 00109 { 00110 ident_map[i]= (uchar) (state_map[i] == MY_LEX_IDENT || 00111 state_map[i] == MY_LEX_NUMBER_IDENT); 00112 } 00113 00114 /* Special handling of hex and binary strings */ 00115 state_map[(uchar)'x']= state_map[(uchar)'X']= (uchar) MY_LEX_IDENT_OR_HEX; 00116 state_map[(uchar)'b']= state_map[(uchar)'B']= (uchar) MY_LEX_IDENT_OR_BIN; 00117 state_map[(uchar)'n']= state_map[(uchar)'N']= (uchar) MY_LEX_IDENT_OR_NCHAR; 00118 return 0; 00119 }
Here is the call graph for this function:

| my_bool my_charset_same | ( | CHARSET_INFO * | cs1, | |
| CHARSET_INFO * | cs2 | |||
| ) |
Definition at line 35 of file charset.c.
References charset_info_st::csname, and strcmp().
Referenced by DTCollation::aggregate(), fill_schema_coll_charset_app(), fill_schema_collation(), Item_func_set_collation::fix_length_and_dec(), Item_char_typecast::fix_length_and_dec(), init_common_variables(), mysql_init_character_set(), String::needs_conversion(), Item::set_name(), and Protocol::store_string_aux().
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 311 of file charset.c.
References add_collation(), buf, FALSE, my_close(), my_free, my_malloc(), MY_MAX_ALLOWED_BUF, my_open(), my_parse_charset_xml(), my_stat(), MY_STAT, my_xml_error_lineno(), my_xml_error_pos(), my_xml_error_string(), MYF, p, and TRUE.
00312 { 00313 char *buf; 00314 int fd; 00315 uint len; 00316 MY_STAT stat_info; 00317 00318 if (!my_stat(filename, &stat_info, MYF(myflags)) || 00319 ((len= (uint)stat_info.st_size) > MY_MAX_ALLOWED_BUF) || 00320 !(buf= (char *)my_malloc(len,myflags))) 00321 return TRUE; 00322 00323 if ((fd=my_open(filename,O_RDONLY,myflags)) < 0) 00324 { 00325 my_free(buf,myflags); 00326 return TRUE; 00327 } 00328 len=read(fd,buf,len); 00329 my_close(fd,myflags); 00330 00331 if (my_parse_charset_xml(buf,len,add_collation)) 00332 { 00333 #ifdef NOT_YET 00334 printf("ERROR at line %d pos %d '%s'\n", 00335 my_xml_error_lineno(&p)+1, 00336 my_xml_error_pos(&p), 00337 my_xml_error_string(&p)); 00338 #endif 00339 } 00340 00341 my_free(buf, myflags); 00342 return FALSE; 00343 }
Here is the call graph for this function:

| static void simple_cs_init_functions | ( | CHARSET_INFO * | cs | ) | [static] |
Definition at line 122 of file charset.c.
References charset_info_st::coll, charset_info_st::cset, my_charset_8bit_handler, my_collation_8bit_bin_handler, my_collation_8bit_simple_ci_handler, MY_CS_BINSORT, and charset_info_st::state.
00123 { 00124 if (cs->state & MY_CS_BINSORT) 00125 cs->coll= &my_collation_8bit_bin_handler; 00126 else 00127 cs->coll= &my_collation_8bit_simple_ci_handler; 00128 00129 cs->cset= &my_charset_8bit_handler; 00130 }
| static my_bool simple_cs_is_full | ( | CHARSET_INFO * | cs | ) | [static] |
Definition at line 197 of file charset.c.
References charset_info_st::csname, charset_info_st::ctype, MY_CS_BINSORT, charset_info_st::name, charset_info_st::number, charset_info_st::sort_order, charset_info_st::state, charset_info_st::tab_to_uni, charset_info_st::to_lower, and charset_info_st::to_upper.
00198 { 00199 return ((cs->csname && cs->tab_to_uni && cs->ctype && cs->to_upper && 00200 cs->to_lower) && 00201 (cs->number && cs->name && 00202 (cs->sort_order || (cs->state & MY_CS_BINSORT) ))); 00203 }
| CHARSET_INFO* all_charsets[256] |
Definition at line 368 of file charset.c.
Referenced by add_collation(), add_compiled_collation(), Dbdict::createTab_dih(), Dbtup::execTUP_ADD_ATTRREQ(), Dbtux::execTUX_ADD_ATTRREQ(), Dbtux::execTUX_BOUND_INFO(), fill_schema_charsets(), fill_schema_coll_charset_app(), fill_schema_collation(), get_charset(), get_charset_name(), get_charset_number(), get_collation_number_internal(), get_internal_charset(), Dbdict::handleTabInfo(), init_available_charsets(), main(), and print_index().
int charset_initialized = 0 [static] |
| const char* charsets_dir = NULL |
Definition at line 307 of file charset.c.
Referenced by fix_paths(), get_charsets_dir(), get_one_option(), main(), mysql_get_character_set_info(), mysql_init_character_set(), mysql_init_variables(), and mysql_set_character_set().
Definition at line 369 of file charset.c.
Referenced by append_unescaped(), Mysql_connection_thread::check_connection(), check_connection(), check_user(), do_test(), dump_leaf_key(), Instance_options::fill_instance_version(), Instance_options::fill_log_options(), find_token(), Instance_map::flush_instances(), ft_boolean_check_syntax_string(), ft_init_stopwords(), FT_STOPWORD_cmp(), get_charset(), get_word(), Abstract_option_cmd::init(), Instance_map::init(), User_map::init(), init_common_variables(), insert_params_from_vars_with_log(), insert_params_withlog(), Instance::is_name_valid(), load_db_opt(), main(), mi_open(), mysql_escape_string(), mysql_recreate_table(), open_binary_frm(), parse_version_number(), run_test(), sys_var_character_set_connection::set_default(), sys_var_character_set_client::set_default(), sys_var_character_set_results::set_default(), sys_var_character_set_server::set_default(), sys_var_character_set_database::set_default(), sys_var_collation_connection::set_default(), sys_var_collation_database::set_default(), sys_var_collation_server::set_default(), skip_spaces(), update_record(), usage(), and Item_func_concat_ws::val_str().
1.4.7

