GA

2023/04/21

MySQL 8.0.32にデフォルトコレーションをutf8mb4_general_ciにするパッチを当てる

地味にgrepから始める。

$ grep -r 'utf8mb4_0900_ai_ci' | grep -v mysql-test | grep -v scripts/fill_help_tables.sql | grep -v gunit

client/mysqltest.cc:    &my_charset_utf8mb4_0900_ai_ci; /* Default charset */
cmake/character_sets.cmake:  SET(DEFAULT_COLLATION "utf8mb4_0900_ai_ci")
include/m_ctype.h:extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_utf8mb4_0900_ai_ci;
man/myisamchk.1:Character set:       utf8mb4_0900_ai_ci (255)
mysys/charset-def.cc:extern CHARSET_INFO my_charset_utf8mb4_0900_ai_ci;
mysys/charset-def.cc:  add_compiled_collation(&my_charset_utf8mb4_0900_ai_ci);
plugin/x/src/mysql_variables.cc:  return &my_charset_utf8mb4_0900_ai_ci;
router/src/routing/src/sql_lexer.cc:            if (underscore_cs == &my_charset_utf8mb4_0900_ai_ci) {
router/src/routing/src/sql_lexer_thd.h:        &my_charset_utf8mb4_0900_ai_ci};
share/messages_to_clients.txt:  eng "Invalid default collation %s: utf8mb4_0900_ai_ci or utf8mb4_general_ci expected"
share/messages_to_error_log.txt:  eng "Invalid default collation %s: utf8mb4_0900_ai_ci or utf8mb4_general_ci expected"
sql/create_field.cc:  if (!has_explicit_collation && fld_charset == &my_charset_utf8mb4_0900_ai_ci)
sql/dd/info_schema/show.cc:      &my_charset_utf8mb4_0900_ai_ci) {
sql/dd/info_schema/show.cc:      &my_charset_utf8mb4_0900_ai_ci) {
sql/dd/info_schema/show.cc:    // ... WHEN <ID of utf8mb4_0900_ai_ci> ...
sql/dd/info_schema/show.cc:        new (mem_root) Item_uint(my_charset_utf8mb4_0900_ai_ci.number);
sql/dd/info_schema/show.cc:    //   WHEN <ID of utf8mb4_0900_ai_ci> THEN FALSE
sql/gis/st_units_of_measure.cc:      &my_charset_utf8mb4_0900_ai_ci, PSI_INSTRUMENT_ME);
sql/histograms/equi_height_bucket.cc:  strings "110", "120" and "130" in utf8mb4_0900_ai_ci gives us the following
sql/item_geofunc.cc:                              &my_charset_utf8mb4_0900_ai_ci,
sql/mysqld.cc:      &my_charset_utf8mb4_0900_ai_ci;
sql/parse_tree_nodes.cc:    if (cs2 == &my_charset_utf8mb4_0900_ai_ci &&
sql/server_component/mysql_string_service.cc:  return to_api(&my_charset_utf8mb4_0900_ai_ci);
sql/sql_db.cc:        create_info->default_table_charset == &my_charset_utf8mb4_0900_ai_ci)
sql/sql_lex.cc:            if (underscore_cs == &my_charset_utf8mb4_0900_ai_ci) {
sql/sql_show.cc:        create.default_table_charset == &my_charset_utf8mb4_0900_ai_ci) {
sql/sql_show.cc:          (field->charset() == &my_charset_utf8mb4_0900_ai_ci &&
sql/sql_show.cc:           share->table_charset != &my_charset_utf8mb4_0900_ai_ci)) {
sql/sql_show.cc:            share->table_charset == &my_charset_utf8mb4_0900_ai_ci) {
sql/sql_table.cc:        create_info->default_table_charset == &my_charset_utf8mb4_0900_ai_ci) {
sql/sys_vars.cc:  if (cs == &my_charset_utf8mb4_0900_ai_ci ||
sql/sys_vars.cc:    DEFAULT(&my_charset_utf8mb4_0900_ai_ci), NO_MUTEX_GUARD, IN_BINLOG,
storage/perfschema/pfs_name.cc:const CHARSET_INFO *PFS_routine_name::m_cs = &my_charset_utf8mb4_0900_ai_ci;
strings/ctype-uca.cc:CHARSET_INFO my_charset_utf8mb4_0900_ai_ci = {

ちくちくとutf8mb4_0900_ai_ciをutf8mb4_general_ciと入れ替える作業をした。

$ diff -r mysql-8.0.32.orig mysql-8.0.32

diff -r mysql-8.0.32.orig/client/mysqltest.cc mysql-8.0.32/client/mysqltest.cc
344c344
<     &my_charset_utf8mb4_0900_ai_ci; /* Default charset */
---
>     &my_charset_utf8mb4_general_ci; /* Default charset */
diff -r mysql-8.0.32.orig/cmake/character_sets.cmake mysql-8.0.32/cmake/character_sets.cmake
29c29
<   SET(DEFAULT_COLLATION "utf8mb4_0900_ai_ci")
---
>   SET(DEFAULT_COLLATION "utf8mb4_general_ci")
diff -r mysql-8.0.32.orig/plugin/x/src/mysql_variables.cc mysql-8.0.32/plugin/x/src/mysql_variables.cc
39c39
<   return &my_charset_utf8mb4_0900_ai_ci;
---
>   return &my_charset_utf8mb4_general_ci;
diff -r mysql-8.0.32.orig/router/src/routing/src/sql_lexer_thd.h mysql-8.0.32/router/src/routing/src/sql_lexer_thd.h
58c58
<         &my_charset_utf8mb4_0900_ai_ci};
---
>         &my_charset_utf8mb4_general_ci};
diff -r mysql-8.0.32.orig/sql/create_field.cc mysql-8.0.32/sql/create_field.cc
214c214
<   if (!has_explicit_collation && fld_charset == &my_charset_utf8mb4_0900_ai_ci)
---
>   if (!has_explicit_collation && fld_charset == &my_charset_utf8mb4_general_ci)
diff -r mysql-8.0.32.orig/sql/dd/info_schema/show.cc mysql-8.0.32/sql/dd/info_schema/show.cc
84c84
<       &my_charset_utf8mb4_0900_ai_ci) {
---
>       &my_charset_utf8mb4_general_ci) {
104c104
<     // ... 'utf8mb4_general_ci' ...
---
>     // ... 'utf8mb4_0900_ai_ci' ...
106c106
<         Item_string(STRING_WITH_LEN("utf8mb4_general_ci"), system_charset_info);
---
>         Item_string(STRING_WITH_LEN("utf8mb4_0900_ai_ci"), system_charset_info);
210c210
<       &my_charset_utf8mb4_0900_ai_ci) {
---
>       &my_charset_utf8mb4_general_ci) {
234c234
<     // ... WHEN <ID of utf8mb4_0900_ai_ci> ...
---
>     // ... WHEN <ID of utf8mb4_general_ci> ...
236c236
<         new (mem_root) Item_uint(my_charset_utf8mb4_0900_ai_ci.number);
---
>         new (mem_root) Item_uint(my_charset_utf8mb4_general_ci.number);
diff -r mysql-8.0.32.orig/sql/gis/st_units_of_measure.cc mysql-8.0.32/sql/gis/st_units_of_measure.cc
30c30
<       &my_charset_utf8mb4_0900_ai_ci, PSI_INSTRUMENT_ME);
---
>       &my_charset_utf8mb4_general_ci, PSI_INSTRUMENT_ME);
diff -r mysql-8.0.32.orig/sql/item_geofunc.cc mysql-8.0.32/sql/item_geofunc.cc
5279c5279
<                               &my_charset_utf8mb4_0900_ai_ci,
---
>                               &my_charset_utf8mb4_general_ci,
diff -r mysql-8.0.32.orig/sql/mysqld.cc mysql-8.0.32/sql/mysqld.cc
5089c5089
<       &my_charset_utf8mb4_0900_ai_ci;
---
>       &my_charset_utf8mb4_general_ci;
diff -r mysql-8.0.32.orig/sql/parse_tree_nodes.cc mysql-8.0.32/sql/parse_tree_nodes.cc
236c236
<     if (cs2 == &my_charset_utf8mb4_0900_ai_ci &&
---
>     if (cs2 == &my_charset_utf8mb4_general_ci &&
diff -r mysql-8.0.32.orig/sql/server_component/mysql_string_service.cc mysql-8.0.32/sql/server_component/mysql_string_service.cc
62c62
<   return to_api(&my_charset_utf8mb4_0900_ai_ci);
---
>   return to_api(&my_charset_utf8mb4_general_ci);
diff -r mysql-8.0.32.orig/sql/sql_db.cc mysql-8.0.32/sql/sql_db.cc
301c301
<         create_info->default_table_charset == &my_charset_utf8mb4_0900_ai_ci)
---
>         create_info->default_table_charset == &my_charset_utf8mb4_general_ci)
diff -r mysql-8.0.32.orig/sql/sql_lex.cc mysql-8.0.32/sql/sql_lex.cc
1538c1538
<             if (underscore_cs == &my_charset_utf8mb4_0900_ai_ci) {
---
>             if (underscore_cs == &my_charset_utf8mb4_general_ci) {
diff -r mysql-8.0.32.orig/sql/sql_show.cc mysql-8.0.32/sql/sql_show.cc
1336c1336
<         create.default_table_charset == &my_charset_utf8mb4_0900_ai_ci) {
---
>         create.default_table_charset == &my_charset_utf8mb4_general_ci) {
2025,2026c2025,2026
<           (field->charset() == &my_charset_utf8mb4_0900_ai_ci &&
<            share->table_charset != &my_charset_utf8mb4_0900_ai_ci)) {
---
>           (field->charset() == &my_charset_utf8mb4_general_ci &&
>            share->table_charset != &my_charset_utf8mb4_general_ci)) {
2357c2357
<             share->table_charset == &my_charset_utf8mb4_0900_ai_ci) {
---
>             share->table_charset == &my_charset_utf8mb4_general_ci) {
diff -r mysql-8.0.32.orig/sql/sql_table.cc mysql-8.0.32/sql/sql_table.cc
8410c8410
<         create_info->default_table_charset == &my_charset_utf8mb4_0900_ai_ci) {
---
>         create_info->default_table_charset == &my_charset_utf8mb4_general_ci) {
diff -r mysql-8.0.32.orig/sql/sys_vars.cc mysql-8.0.32/sql/sys_vars.cc
7193c7193
<     DEFAULT(&my_charset_utf8mb4_0900_ai_ci), NO_MUTEX_GUARD, IN_BINLOG,
---
>     DEFAULT(&my_charset_utf8mb4_general_ci), NO_MUTEX_GUARD, IN_BINLOG,
diff -r mysql-8.0.32.orig/storage/perfschema/pfs_name.cc mysql-8.0.32/storage/perfschema/pfs_name.cc
61c61
< const CHARSET_INFO *PFS_routine_name::m_cs = &my_charset_utf8mb4_0900_ai_ci;
---
> const CHARSET_INFO *PFS_routine_name::m_cs = &my_charset_utf8mb4_general_ci;
diff -r mysql-8.0.32.orig/strings/ctype-uca.cc mysql-8.0.32/strings/ctype-uca.cc
9568c9568
<     MY_CS_UTF8MB4_UCA_FLAGS | MY_CS_PRIMARY, /* state    */
---
>     MY_CS_UTF8MB4_UCA_FLAGS,                 /* state    */
diff -r mysql-8.0.32.orig/strings/ctype-utf8.cc mysql-8.0.32/strings/ctype-utf8.cc
7766c7766
<         MY_CS_UNICODE_SUPPLEMENT, /* state  */
---
>         MY_CS_UNICODE_SUPPLEMENT | MY_CS_PRIMARY , /* state  */

で、コンパイル

$ cmake3 -DWITH_BOOST=~/mysql-8.0.32/boost ~/mysql-8.0.32
$ make -j8
mysql> CREATE DATABASE d1;
Query OK, 1 row affected (0.00 sec)

mysql> SHOW CREATE DATABASE d1;
+----------+------------------------------------------------------------------------------------------------------------------------------+
| Database | Create Database                                                                                                              |
+----------+------------------------------------------------------------------------------------------------------------------------------+
| d1       | CREATE DATABASE `d1` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ /*!80016 DEFAULT ENCRYPTION='N' */ |
+----------+------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> SHOW COLLATION LIKE 'utf8mb4_general_ci';
+--------------------+---------+----+---------+----------+---------+---------------+
| Collation          | Charset | Id | Default | Compiled | Sortlen | Pad_attribute |
+--------------------+---------+----+---------+----------+---------+---------------+
| utf8mb4_general_ci | utf8mb4 | 45 | Yes     | Yes      |       1 | PAD SPACE     |
+--------------------+---------+----+---------+----------+---------+---------------+
1 row in set (0.01 sec)

Vanilla版ではutf8mb4_general_ciのDefaultはEmptyだけど、パッチ版はYesになってる。

mysql80 8> SHOW COLLATION LIKE 'utf8mb4_general_ci';
+--------------------+---------+----+---------+----------+---------+---------------+
| Collation          | Charset | Id | Default | Compiled | Sortlen | Pad_attribute |
+--------------------+---------+----+---------+----------+---------+---------------+
| utf8mb4_general_ci | utf8mb4 | 45 |         | Yes      |       1 | PAD SPACE     |
+--------------------+---------+----+---------+----------+---------+---------------+
1 row in set (0.01 sec)

ちょっと使ってみよう。

0 件のコメント :

コメントを投稿