MySQL 8.0.32 union 语句中文查不到数据

关键字

MySQL union 语句,中文查不到数据

问题描述

MySQL 8.0.32 union 语句,中文查不到数据

解决问题思路

复制代码
1、Create a table `test` with two fields, such as id and name
mysql>create table test ( id int unsigned auto_increment key, name varchar(50))ENGINE=INNODB;
2、Insert data into the table. The name field is Chinese characters, such as "姜志福"
mysql>insert into  test(id,name) values(1,'姜志福');
3、Use the union statement to query, such as:
select * from (
select * from test 
union all 
select * from test 
)a  where id = 1 and name = '姜志福'

最终排查为这是MySQL BUG
https://bugs.mysql.com/bug.php?id=110005

临时解决可以关闭 derived_condition_pushdown 特性
set optimizer_switch='derived_condition_pushdown=off';

https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-32.html

A condition pushdown into a UNION of queries having LIKE clauses did not preserve the correct character set, leading to an (erroneous) empty result.
We solve this problem in two parts:
By refactoring resolution of LIKE expressions, in which character set determination and propagation were previously performed in two separate blocks of the code that were not always consistent with one another.
By adding, in the internal parse_expression() function, a character set prefix to any literal character string that is cloned.
(Bug #107787, Bug #34359297, Bug #34589153)



https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-33.html

When cloning a condition to push down to a derived table, characters in strings representing conditions were converted to utfmb4 correctly only for values less than 128 (the ASCII subset), and code points outside the ASCII subset were converted to invalid characters, causing the resulting character strings to become invalid. For derived tables without UNION, this led to problems when a column name from the derived table used characters outside the ASCII subset, and was used in the WHERE condition. For derived tables with UNION, it created problems when a character outside the ASCII subset was present in a WHERE condition.
We fix these issues by initializing the string used for representing the condition in such cases to the connection character set. (Bug #109699, Bug #34996488)

问题总结

MySQL 8.0.32 存在UNION语句 中文查不到数据的BUG

相关推荐
YIAN8 分钟前
手撸社区后端:一套可落地的用户 - 文章 - 互动体系 MySQL 表设计与优化思路
后端·mysql
蓝速科技9 分钟前
企业展厅数字人导览效果提升与选型实战指南丨蓝速科技
大数据·运维·数据库·人工智能·科技·microsoft
奔跑吧树袋熊16 分钟前
多租户隔离该做到哪一层:从连接池到 ORM 的取舍
开发语言·数据库·oracle·系统架构
码农学院17 分钟前
零售电商GEO踩坑复盘:把 MySQL 商品库自动映射成 Product Schema 的完整方案
人工智能·mysql·零售·geo
罗光记28 分钟前
全能 Go Agent 框架 Covonaut v1.1.2发布:终端对话加入旁问与三档输出
数据库·经验分享·其他·百度·新浪微博
Htr_1 小时前
Anysite.io 使用指南:把整个 Web 变成 AI 智能体的数据库
前端·数据库·人工智能
Lyra_Infra1 小时前
记一次麒麟 Linux 下达梦数据库 (DM8) 部署与 MySQL 命令行无界面迁移踩坑指南
数据库·后端·dba
晚安日记wanna1 小时前
只会答加索引MySQL 调优还能聊这 7 个点
数据库·面试
YHHLAI1 小时前
从零理解 Agent Memory 管理:内存记忆、文件持久化与上下文截断
数据库·oracle
cspttty1 小时前
2026市场分析师校招能力模型:SQL、Excel、BI与业务分析
大数据·数据库