MySQL 8.0.40
Source Code Documentation
charset.cc File Reference
#include "my_config.h"
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <algorithm>
#include <mutex>
#include <unordered_map>
#include "m_ctype.h"
#include "m_string.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_dir.h"
#include "my_inttypes.h"
#include "my_io.h"
#include "my_loglevel.h"
#include "my_macros.h"
#include "my_sys.h"
#include "my_thread.h"
#include "my_xml.h"
#include "mysql/psi/mysql_file.h"
#include "mysql/psi/mysql_mutex.h"
#include "mysql/service_mysql_alloc.h"
#include "mysys/mysys_priv.h"
#include "mysys_err.h"
#include "sql_chars.h"

Macros

#define MY_CS_BUFFER_SIZE   (MY_CS_NAME_SIZE * 8)
 
#define MY_MAX_ALLOWED_BUF   1024 * 1024
 
#define MY_CHARSET_INDEX   "Index.xml"
 

Functions

static void map_coll_name_to_number (const char *name, int num)
 
static void map_cs_name_to_number (const char *name, int num, int state)
 
static uint get_collation_number_internal (const char *name)
 
static void simple_cs_init_functions (CHARSET_INFO *cs)
 
static bool cs_copy_data (CHARSET_INFO *to, CHARSET_INFO *from)
 
static bool simple_cs_is_full (CHARSET_INFO *cs)
 
static void copy_uca_collation (CHARSET_INFO *to, CHARSET_INFO *from)
 
static void clear_cs_info (CHARSET_INFO *cs)
 
static void default_reporter (enum loglevel level, uint ecode,...)
 Report character set initialization errors and warnings. More...
 
static bool my_read_charset_file (MY_CHARSET_LOADER *loader, const char *filename, myf myflags)
 
char * get_charsets_dir (char *buf)
 
void add_compiled_collation (CHARSET_INFO *cs)
 
static void init_available_charsets (void)
 
static const char * get_collation_name_alias (const char *name, char *buf, size_t bufsize)
 
uint get_collation_number (const char *name)
 
static uint get_charset_number_internal (const char *charset_name, uint cs_flags)
 
static const char * get_charset_name_alias (const char *name)
 
uint get_charset_number (const char *charset_name, uint cs_flags)
 
const char * get_collation_name (uint charset_number)
 
static CHARSET_INFOget_internal_charset (MY_CHARSET_LOADER *loader_arg, uint cs_number, myf flags)
 
CHARSET_INFOget_charset (uint cs_number, myf flags)
 
CHARSET_INFOmy_collation_get_by_name (MY_CHARSET_LOADER *loader, const char *name, myf flags)
 Find collation by name: extended version of get_charset_by_name() to return error messages to the caller. More...
 
CHARSET_INFOget_charset_by_name (const char *cs_name, myf flags)
 
CHARSET_INFOmy_charset_get_by_name (MY_CHARSET_LOADER *loader, const char *cs_name, uint cs_flags, myf flags)
 Find character set by name: extended version of get_charset_by_csname() to return error messages to the caller. More...
 
CHARSET_INFOget_charset_by_csname (const char *cs_name, uint cs_flags, myf flags)
 
bool resolve_charset (const char *cs_name, const CHARSET_INFO *default_cs, const CHARSET_INFO **cs)
 Resolve character set by the character set name (utf8, latin1, ...). More...
 
bool resolve_collation (const char *cl_name, const CHARSET_INFO *default_cl, const CHARSET_INFO **cl)
 Resolve collation by the collation name (utf8_general_ci, ...). More...
 
size_t escape_string_for_mysql (const CHARSET_INFO *charset_info, char *to, size_t to_length, const char *from, size_t length)
 
size_t escape_quotes_for_mysql (CHARSET_INFO *charset_info, char *to, size_t to_length, const char *from, size_t length, char quote)
 
void charset_uninit ()
 

Variables

CHARSET_INFO my_charset_ucs2_unicode_ci
 
CHARSET_INFO my_charset_utf8mb4_unicode_ci
 
CHARSET_INFO my_charset_utf16_unicode_ci
 
CHARSET_INFO my_charset_utf32_unicode_ci
 
CHARSET_INFO my_charset_cp932_japanese_ci
 
std::unordered_map< std::string, int > * coll_name_num_map = nullptr
 
std::unordered_map< std::string, int > * cs_name_pri_num_map = nullptr
 
std::unordered_map< std::string, int > * cs_name_bin_num_map = nullptr
 
my_error_reporter my_charset_error_reporter = default_reporter
 
const char * charsets_dir = nullptr
 
CHARSET_INFOall_charsets [MY_ALL_CHARSETS_SIZE] = {nullptr}
 
CHARSET_INFOdefault_charset_info = &my_charset_latin1
 
static std::once_flag charsets_initialized
 

Macro Definition Documentation

◆ MY_CHARSET_INDEX

#define MY_CHARSET_INDEX   "Index.xml"

◆ MY_CS_BUFFER_SIZE

#define MY_CS_BUFFER_SIZE   (MY_CS_NAME_SIZE * 8)

◆ MY_MAX_ALLOWED_BUF

#define MY_MAX_ALLOWED_BUF   1024 * 1024

Function Documentation

◆ clear_cs_info()

static void clear_cs_info ( CHARSET_INFO cs)
static

◆ copy_uca_collation()

static void copy_uca_collation ( CHARSET_INFO to,
CHARSET_INFO from 
)
static

◆ cs_copy_data()

static bool cs_copy_data ( CHARSET_INFO to,
CHARSET_INFO from 
)
static

◆ default_reporter()

static void default_reporter ( enum loglevel  level,
uint  ecode,
  ... 
)
static

Report character set initialization errors and warnings.

Be silent by default: no warnings on the client side.

◆ get_charset_name_alias()

static const char * get_charset_name_alias ( const char *  name)
static

◆ get_charset_number_internal()

static uint get_charset_number_internal ( const char *  charset_name,
uint  cs_flags 
)
static

◆ get_collation_name_alias()

static const char * get_collation_name_alias ( const char *  name,
char *  buf,
size_t  bufsize 
)
static

◆ get_collation_number_internal()

static uint get_collation_number_internal ( const char *  name)
static

◆ get_internal_charset()

static CHARSET_INFO * get_internal_charset ( MY_CHARSET_LOADER loader_arg,
uint  cs_number,
myf  flags 
)
static

◆ init_available_charsets()

static void init_available_charsets ( void  )
static

◆ map_coll_name_to_number()

static void map_coll_name_to_number ( const char *  name,
int  num 
)
static

◆ map_cs_name_to_number()

static void map_cs_name_to_number ( const char *  name,
int  num,
int  state 
)
static

◆ my_read_charset_file()

static bool my_read_charset_file ( MY_CHARSET_LOADER loader,
const char *  filename,
myf  myflags 
)
static

◆ simple_cs_init_functions()

static void simple_cs_init_functions ( CHARSET_INFO cs)
static

◆ simple_cs_is_full()

static bool simple_cs_is_full ( CHARSET_INFO cs)
static

Variable Documentation

◆ charsets_initialized

std::once_flag charsets_initialized
static

◆ coll_name_num_map

std::unordered_map<std::string, int>* coll_name_num_map = nullptr

◆ cs_name_bin_num_map

std::unordered_map<std::string, int>* cs_name_bin_num_map = nullptr

◆ cs_name_pri_num_map

std::unordered_map<std::string, int>* cs_name_pri_num_map = nullptr

◆ my_charset_cp932_japanese_ci

CHARSET_INFO my_charset_cp932_japanese_ci
extern

◆ my_charset_ucs2_unicode_ci

CHARSET_INFO my_charset_ucs2_unicode_ci
extern

◆ my_charset_utf16_unicode_ci

CHARSET_INFO my_charset_utf16_unicode_ci
extern

◆ my_charset_utf32_unicode_ci

CHARSET_INFO my_charset_utf32_unicode_ci
extern

◆ my_charset_utf8mb4_unicode_ci

CHARSET_INFO my_charset_utf8mb4_unicode_ci
extern