Skip to content

Commit

Permalink
Bug #34025412 Rename utf8_xxx functions and data structures to utf8mb…
Browse files Browse the repository at this point in the history
…3_xxx [noclose]

For better code readability/maintainability, rename functions and data
structures used for handling utf8mb3 charsets and collations.

This patch renames my_charset_utf8_xxx to my_charset_utf8mb3_xxx.

Change-Id: I7f198007b365e780e814f8b5b9ddbfdf06a50c67
  • Loading branch information
Tor Didriksen committed May 5, 2022
1 parent b67d9ed commit 83f688b
Show file tree
Hide file tree
Showing 83 changed files with 345 additions and 338 deletions.
8 changes: 4 additions & 4 deletions include/m_ctype.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,10 @@ extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_utf8mb4_0900_bin;

extern CHARSET_INFO my_charset_latin1_bin;
extern CHARSET_INFO my_charset_utf32_unicode_ci;
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_utf8_general_ci;
extern CHARSET_INFO my_charset_utf8_tolower_ci;
extern CHARSET_INFO my_charset_utf8_unicode_ci;
extern CHARSET_INFO my_charset_utf8_bin;
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_utf8mb3_general_ci;
extern CHARSET_INFO my_charset_utf8mb3_tolower_ci;
extern CHARSET_INFO my_charset_utf8mb3_unicode_ci;
extern CHARSET_INFO my_charset_utf8mb3_bin;
extern CHARSET_INFO my_charset_utf8mb4_bin;
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_utf8mb4_general_ci;

Expand Down
108 changes: 54 additions & 54 deletions mysys/charset-def.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,32 +148,32 @@ extern CHARSET_INFO my_charset_utf16_sinhala_uca_ci;
extern CHARSET_INFO my_charset_utf16_unicode_520_ci;
extern CHARSET_INFO my_charset_utf16_vietnamese_ci;

extern CHARSET_INFO my_charset_utf8_tolower_ci;
extern CHARSET_INFO my_charset_utf8_bin;
extern CHARSET_INFO my_charset_utf8_general_mysql500_ci;
extern CHARSET_INFO my_charset_utf8_german2_uca_ci;
extern CHARSET_INFO my_charset_utf8_icelandic_uca_ci;
extern CHARSET_INFO my_charset_utf8_latvian_uca_ci;
extern CHARSET_INFO my_charset_utf8_romanian_uca_ci;
extern CHARSET_INFO my_charset_utf8_slovenian_uca_ci;
extern CHARSET_INFO my_charset_utf8_polish_uca_ci;
extern CHARSET_INFO my_charset_utf8_estonian_uca_ci;
extern CHARSET_INFO my_charset_utf8_spanish_uca_ci;
extern CHARSET_INFO my_charset_utf8_swedish_uca_ci;
extern CHARSET_INFO my_charset_utf8_turkish_uca_ci;
extern CHARSET_INFO my_charset_utf8_czech_uca_ci;
extern CHARSET_INFO my_charset_utf8_danish_uca_ci;
extern CHARSET_INFO my_charset_utf8_lithuanian_uca_ci;
extern CHARSET_INFO my_charset_utf8_slovak_uca_ci;
extern CHARSET_INFO my_charset_utf8_spanish2_uca_ci;
extern CHARSET_INFO my_charset_utf8_roman_uca_ci;
extern CHARSET_INFO my_charset_utf8_persian_uca_ci;
extern CHARSET_INFO my_charset_utf8_esperanto_uca_ci;
extern CHARSET_INFO my_charset_utf8_hungarian_uca_ci;
extern CHARSET_INFO my_charset_utf8_croatian_uca_ci;
extern CHARSET_INFO my_charset_utf8_sinhala_uca_ci;
extern CHARSET_INFO my_charset_utf8_unicode_520_ci;
extern CHARSET_INFO my_charset_utf8_vietnamese_ci;
extern CHARSET_INFO my_charset_utf8mb3_tolower_ci;
extern CHARSET_INFO my_charset_utf8mb3_bin;
extern CHARSET_INFO my_charset_utf8mb3_general_mysql500_ci;
extern CHARSET_INFO my_charset_utf8mb3_german2_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_icelandic_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_latvian_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_romanian_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_slovenian_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_polish_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_estonian_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_spanish_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_swedish_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_turkish_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_czech_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_danish_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_lithuanian_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_slovak_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_spanish2_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_roman_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_persian_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_esperanto_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_hungarian_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_croatian_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_sinhala_uca_ci;
extern CHARSET_INFO my_charset_utf8mb3_unicode_520_ci;
extern CHARSET_INFO my_charset_utf8mb3_vietnamese_ci;

extern CHARSET_INFO my_charset_utf8mb4_general_ci;
extern CHARSET_INFO my_charset_utf8mb4_unicode_ci;
Expand Down Expand Up @@ -339,34 +339,34 @@ bool init_compiled_charsets(myf flags [[maybe_unused]]) {
add_compiled_collation(&my_charset_ujis_japanese_ci);
add_compiled_collation(&my_charset_ujis_bin);

add_compiled_collation(&my_charset_utf8_general_ci);
add_compiled_collation(&my_charset_utf8_tolower_ci);
add_compiled_collation(&my_charset_utf8_bin);
add_compiled_collation(&my_charset_utf8_general_mysql500_ci);
add_compiled_collation(&my_charset_utf8_unicode_ci);
add_compiled_collation(&my_charset_utf8_german2_uca_ci);
add_compiled_collation(&my_charset_utf8_icelandic_uca_ci);
add_compiled_collation(&my_charset_utf8_latvian_uca_ci);
add_compiled_collation(&my_charset_utf8_romanian_uca_ci);
add_compiled_collation(&my_charset_utf8_slovenian_uca_ci);
add_compiled_collation(&my_charset_utf8_polish_uca_ci);
add_compiled_collation(&my_charset_utf8_estonian_uca_ci);
add_compiled_collation(&my_charset_utf8_spanish_uca_ci);
add_compiled_collation(&my_charset_utf8_swedish_uca_ci);
add_compiled_collation(&my_charset_utf8_turkish_uca_ci);
add_compiled_collation(&my_charset_utf8_czech_uca_ci);
add_compiled_collation(&my_charset_utf8_danish_uca_ci);
add_compiled_collation(&my_charset_utf8_lithuanian_uca_ci);
add_compiled_collation(&my_charset_utf8_slovak_uca_ci);
add_compiled_collation(&my_charset_utf8_spanish2_uca_ci);
add_compiled_collation(&my_charset_utf8_roman_uca_ci);
add_compiled_collation(&my_charset_utf8_persian_uca_ci);
add_compiled_collation(&my_charset_utf8_esperanto_uca_ci);
add_compiled_collation(&my_charset_utf8_hungarian_uca_ci);
add_compiled_collation(&my_charset_utf8_croatian_uca_ci);
add_compiled_collation(&my_charset_utf8_sinhala_uca_ci);
add_compiled_collation(&my_charset_utf8_unicode_520_ci);
add_compiled_collation(&my_charset_utf8_vietnamese_ci);
add_compiled_collation(&my_charset_utf8mb3_general_ci);
add_compiled_collation(&my_charset_utf8mb3_tolower_ci);
add_compiled_collation(&my_charset_utf8mb3_bin);
add_compiled_collation(&my_charset_utf8mb3_general_mysql500_ci);
add_compiled_collation(&my_charset_utf8mb3_unicode_ci);
add_compiled_collation(&my_charset_utf8mb3_german2_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_icelandic_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_latvian_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_romanian_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_slovenian_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_polish_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_estonian_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_spanish_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_swedish_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_turkish_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_czech_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_danish_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_lithuanian_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_slovak_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_spanish2_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_roman_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_persian_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_esperanto_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_hungarian_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_croatian_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_sinhala_uca_ci);
add_compiled_collation(&my_charset_utf8mb3_unicode_520_ci);
add_compiled_collation(&my_charset_utf8mb3_vietnamese_ci);

// utf8mb4 is the only character set with more than two binary collations. For
// backward compatibility, we want the deprecated BINARY type attribute to use
Expand Down
4 changes: 2 additions & 2 deletions mysys/charset.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ static int add_collation(CHARSET_INFO *cs) {
newcs->state |= MY_CS_AVAILABLE | MY_CS_LOADED | MY_CS_NONASCII;
} else if (!strcmp(cs->csname, "utf8") ||
!strcmp(cs->csname, "utf8mb3")) {
copy_uca_collation(newcs, &my_charset_utf8_unicode_ci);
newcs->ctype = my_charset_utf8_unicode_ci.ctype;
copy_uca_collation(newcs, &my_charset_utf8mb3_unicode_ci);
newcs->ctype = my_charset_utf8mb3_unicode_ci.ctype;
if (init_state_maps(newcs)) return MY_XML_ERROR;
} else if (!strcmp(cs->csname, "utf8mb4")) {
copy_uca_collation(newcs, &my_charset_utf8mb4_unicode_ci);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class Sql_service_interface {
*/
Sql_service_interface(
enum cs_text_or_binary cs_txt_bin = CS_TEXT_REPRESENTATION,
const CHARSET_INFO *cs_charset = &my_charset_utf8_general_ci);
const CHARSET_INFO *cs_charset = &my_charset_utf8mb3_general_ci);

/**
Sql_service_interface destructor
Expand Down Expand Up @@ -162,7 +162,7 @@ class Sql_service_interface {
long execute_query(
std::string sql_string, Sql_resultset *rset,
enum cs_text_or_binary cs_txt_bin = CS_TEXT_REPRESENTATION,
const CHARSET_INFO *cs_charset = &my_charset_utf8_general_ci);
const CHARSET_INFO *cs_charset = &my_charset_utf8mb3_general_ci);

/**
Executes a server command in a session.
Expand All @@ -185,7 +185,7 @@ class Sql_service_interface {
long execute(COM_DATA cmd, enum enum_server_command cmd_type,
Sql_resultset *rset,
enum cs_text_or_binary cs_txt_bin = CS_TEXT_REPRESENTATION,
const CHARSET_INFO *cs_charset = &my_charset_utf8_general_ci);
const CHARSET_INFO *cs_charset = &my_charset_utf8mb3_general_ci);

/**
Set send result type to CS_TEXT_REPRESENTATION or
Expand Down
2 changes: 1 addition & 1 deletion plugin/group_replication/src/plugin_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void plugin_escape_string(std::string &string_to_escape) {
size_t length = string_to_escape.length();
char *end_string =
(char *)my_malloc(PSI_NOT_INSTRUMENTED, 2 * length + 1, MYF(0));
escape_string_for_mysql(&my_charset_utf8_general_ci, end_string,
escape_string_for_mysql(&my_charset_utf8mb3_general_ci, end_string,
2 * length + 1, string_to_escape.c_str(), length);
string_to_escape.assign(end_string);
my_free(end_string);
Expand Down
2 changes: 1 addition & 1 deletion plugin/test_service_sql_api/test_session_attach.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static void exec_test_cmd(MYSQL_SESSION session, const char *test_cmd) {

const bool failed =
0 != command_service_run_command(session, COM_QUERY, &cmd,
&my_charset_utf8_general_ci, &sql_cbs,
&my_charset_utf8mb3_general_ci, &sql_cbs,
CS_BINARY_REPRESENTATION, nullptr);

if (failed) {
Expand Down
6 changes: 3 additions & 3 deletions plugin/test_service_sql_api/test_session_detach.cc
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,9 @@ static void exec_test_cmd(MYSQL_SESSION session, const char *test_cmd,
memset(&cmd, 0, sizeof(cmd));
cmd.com_query.query = test_cmd;
cmd.com_query.length = strlen(cmd.com_query.query);
int fail = command_service_run_command(session, COM_QUERY, &cmd,
&my_charset_utf8_general_ci, &sql_cbs,
CS_BINARY_REPRESENTATION, ctx);
int fail = command_service_run_command(
session, COM_QUERY, &cmd, &my_charset_utf8mb3_general_ci, &sql_cbs,
CS_BINARY_REPRESENTATION, ctx);

if (fail)
LogPluginErrMsg(ERROR_LEVEL, ER_LOG_PRINTF_MSG,
Expand Down
18 changes: 9 additions & 9 deletions plugin/test_service_sql_api/test_session_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,8 @@ static void exec_test_cmd(MYSQL_SESSION session, const char *query,
cmd.com_query.length = strlen(cmd.com_query.query);
WRITE_VAL("%s\n", query);
int fail = command_service_run_command(session, COM_QUERY, &cmd,
&my_charset_utf8_general_ci, &sql_cbs,
CS_TEXT_REPRESENTATION, ctx);
&my_charset_utf8mb3_general_ci,
&sql_cbs, CS_TEXT_REPRESENTATION, ctx);
if (fail) {
srv_session_close(session);
if (!expect_error)
Expand Down Expand Up @@ -584,9 +584,9 @@ static void test_com_init_db(void *p [[maybe_unused]], MYSQL_SESSION st_session,
cmd.com_init_db.db_name = db_name;
cmd.com_init_db.length = strlen(db_name);

int fail = command_service_run_command(st_session, COM_INIT_DB, &cmd,
&my_charset_utf8_general_ci, &sql_cbs,
CS_TEXT_REPRESENTATION, plugin_ctx);
int fail = command_service_run_command(
st_session, COM_INIT_DB, &cmd, &my_charset_utf8mb3_general_ci, &sql_cbs,
CS_TEXT_REPRESENTATION, plugin_ctx);

if (fail) {
LogPluginErr(ERROR_LEVEL, ER_LOG_PRINTF_MSG, "run_statement code: %d\n",
Expand Down Expand Up @@ -931,9 +931,9 @@ static void test_sql(void *p) {
cmd.com_query.query = buffer_query;
cmd.com_query.length = strlen(buffer_query);

int fail = command_service_run_command(session_2, COM_QUERY, &cmd,
&my_charset_utf8_general_ci, &sql_cbs,
CS_TEXT_REPRESENTATION, plugin_ctx);
int fail = command_service_run_command(
session_2, COM_QUERY, &cmd, &my_charset_utf8mb3_general_ci, &sql_cbs,
CS_TEXT_REPRESENTATION, plugin_ctx);

if (fail) {
LogPluginErr(ERROR_LEVEL, ER_LOG_PRINTF_MSG, "run_statement code: %d\n",
Expand All @@ -953,7 +953,7 @@ static void test_sql(void *p) {
cmd.com_query.length = strlen(buffer_query);

fail = command_service_run_command(session_2, COM_QUERY, &cmd,
&my_charset_utf8_general_ci, &sql_cbs,
&my_charset_utf8mb3_general_ci, &sql_cbs,
CS_TEXT_REPRESENTATION, plugin_ctx);

if (fail) {
Expand Down
4 changes: 2 additions & 2 deletions plugin/test_service_sql_api/test_sql_2_sessions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,8 @@ static void exec_test_cmd(MYSQL_SESSION session, const char *test_cmd,
cmd.com_query.query = test_cmd;
cmd.com_query.length = strlen(cmd.com_query.query);
int fail = command_service_run_command(session, COM_QUERY, &cmd,
&my_charset_utf8_general_ci, &sql_cbs,
CS_TEXT_REPRESENTATION, ctx);
&my_charset_utf8mb3_general_ci,
&sql_cbs, CS_TEXT_REPRESENTATION, ctx);
if (fail) {
if (!srv_session_close(session))
LogPluginErrMsg(ERROR_LEVEL, ER_LOG_PRINTF_MSG,
Expand Down
2 changes: 1 addition & 1 deletion plugin/test_service_sql_api/test_sql_9_sessions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ static void exec_test_cmd(MYSQL_SESSION session, const char *test_cmd,
cmd.com_query.query = (char *)test_cmd;
cmd.com_query.length = strlen(cmd.com_query.query);
fail = command_service_run_command(session, select_prot, COM_QUERY, &cmd,
&my_charset_utf8_general_ci);
&my_charset_utf8mb3_general_ci);
if (fail)
LogPluginErrMsg(ERROR_LEVEL, ER_LOG_PRINTF_MSG,
"test_sql_9_sessions - ret code : %d", fail);
Expand Down
4 changes: 2 additions & 2 deletions plugin/test_service_sql_api/test_sql_all_col_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,8 @@ static void exec_test_cmd(MYSQL_SESSION session, const char *test_cmd,
cmd.com_query.query = test_cmd;
cmd.com_query.length = strlen(cmd.com_query.query);
int fail = command_service_run_command(session, COM_QUERY, &cmd,
&my_charset_utf8_general_ci, &sql_cbs,
text_or_binary, ctx);
&my_charset_utf8mb3_general_ci,
&sql_cbs, text_or_binary, ctx);
if (fail)
LogPluginErrMsg(ERROR_LEVEL, ER_LOG_PRINTF_MSG,
"test_sql_all_col_types - ret code : %d", fail);
Expand Down
Loading

0 comments on commit 83f688b

Please sign in to comment.