Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

规则:建议列与表使用同一个字符集,对建表语句的JSON列误触发 #2536

Open
winfredLIN opened this issue Aug 12, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@winfredLIN
Copy link
Collaborator

版本信息(Version)

3.24.04

问题描述(Describe)

在对建表语句审核时,若开启规则:建议列与表使用同一个字符集,且建表语句中包含JSON列时,会错误的触发该规则
image
根据文档:
MySQL :: MySQL 8.4 Reference Manual :: 13.5 The JSON Data Type
JSON在mysql的存储中的存储形式是二进制(binary)
但把json格式的字符集认为是binary,是不准确的
实际上查询mysql,json格式没有字符集
img_v3_02dm_a97e7020-a46d-440d-9ed8-cc435efdd4cg

截图或日志(Log)

如何复现(To Reproduce)

  1. 开启规则:建议列与表使用同一个字符集
  2. 用SQLE的一个表的建表语句进行测试
CREATE TABLE `db_service_sync_tasks` (
  `uid` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` datetime(3) DEFAULT NULL,
  `updated_at` datetime(3) DEFAULT NULL,
  `name` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL,
  `source` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `url` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `db_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `cron_express` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `last_sync_err` longtext COLLATE utf8mb4_unicode_ci,
  `last_sync_success_time` datetime(3) DEFAULT NULL,
  `extra_parameters` json DEFAULT NULL,
  PRIMARY KEY (`uid`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci 

问题原因

image
在曾经的一次变更中,错误的将json的列的字符集设置为binary

解决方案

变更影响面

受影响的模块或功能

外部引用的潜在问题或风险

版本兼容性

测试建议

@winfredLIN winfredLIN added the bug Something isn't working label Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants