为提高效率,请提供以下信息,问题描述清晰能够更快得到解决:
【TiDB 版本】
v5.0.0
【问题描述】
一、配置如下
1、new_collations_enabled_on_first_bootstrap: true
2、数据库字符集和排序规则
MySQL [testdb]> show create database testdb;
±---------±----------------------------------------------------------------------------------------------+
| Database | Create Database |
±---------±----------------------------------------------------------------------------------------------+
| testdb | CREATE DATABASE testdb
/*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ |
±---------±----------------------------------------------------------------------------------------------+
3、字符集参数
MySQL [testdb]> show global variables like ‘%coll%’;
±---------------------±-------------------+
| Variable_name | Value |
±---------------------±-------------------+
| collation_connection | utf8mb4_general_ci |
| collation_database | utf8mb4_general_ci |
| collation_server | utf8mb4_general_ci |
±---------------------±-------------------+
3 rows in set (0.31 sec)
4、排序规则参数
MySQL [testdb]> show global variables like ‘%char%’;
±-------------------------------------±-------------------------------------------------------+
| Variable_name | Value |
±-------------------------------------±-------------------------------------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql-5.6.25-osx10.8-x86_64/share/charsets/ |
| validate_password_special_char_count | 1 |
±-------------------------------------±-------------------------------------------------------+
9 rows in set (0.30 sec)
二、问题重现
如下所示,创建表test1时未指定CHARSET,建表后CHARSET和COLLATE继承了数据库的;
而创建表test2时指定CHARSET=utf8mb4,建表后CHARSET和COLLATE没有继承了数据库的COLLATE,这应该是1个bug。
MySQL [testdb]> CREATE TABLE test1
(
-> id
int(11) unsigned NOT NULL AUTO_INCREMENT,
-> c2
varchar(45) NOT NULL DEFAULT ‘’,
-> c3
varchar(500) DEFAULT NULL,
-> c4
mediumtext DEFAULT NULL,
-> c5
blob DEFAULT NULL,
-> c6
datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
-> c7
datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-> PRIMARY KEY (id
),
-> KEY idx_c2
(c2
)
-> ) ENGINE=InnoDB COMMENT=‘test1’;
Query OK, 0 rows affected (0.09 sec)
MySQL [testdb]> show create table test1;
| test1 | CREATE TABLE test1
(
id
int(11) unsigned NOT NULL AUTO_INCREMENT,
c2
varchar(45) COLLATE utf8mb4_general_ci NOT NULL DEFAULT ‘’,
c3
varchar(500) COLLATE utf8mb4_general_ci DEFAULT NULL,
c4
mediumtext COLLATE utf8mb4_general_ci DEFAULT NULL,
c5
blob DEFAULT NULL,
c6
datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
c7
datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id
) /*T![clustered_index] NONCLUSTERED */,
KEY idx_c2
(c2
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT=‘test1’
CREATE TABLE test2
(
-> id
int(11) unsigned NOT NULL AUTO_INCREMENT,
-> c2
varchar(45) NOT NULL DEFAULT ‘’,
-> c3
varchar(500) DEFAULT NULL,
-> c4
mediumtext DEFAULT NULL,
-> c5
blob DEFAULT NULL,
-> c6
datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
-> c7
datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-> PRIMARY KEY (id
),
-> KEY idx_c2
(c2
)
-> ) ENGINE=InnoDB CHARSET=utf8mb4 COMMENT=‘test2’;
Query OK, 0 rows affected (0.09 sec)
MySQL [testdb]> show create table test2;
CREATE TABLE test2
(
id
int(11) unsigned NOT NULL AUTO_INCREMENT,
c2
varchar(45) NOT NULL DEFAULT ‘’,
c3
varchar(500) DEFAULT NULL,
c4
mediumtext DEFAULT NULL,
c5
blob DEFAULT NULL,
c6
datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
c7
datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id
) /*T![clustered_index] NONCLUSTERED */,
KEY idx_c2
(c2
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT=‘test2’
若提问为性能优化、故障排查类问题,请下载脚本运行。终端输出的打印结果,请务必全选并复制粘贴上传。