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

相关推荐
Aloudata12 分钟前
人工逐级追查 SQL vs 数据血缘追溯:监管报表异常排查
大数据·数据库·sql
果粒蹬i1 小时前
实时计算平台是什么?工业物联网选型,DolphinDB 拆解
数据库·物联网·实时计算·dolphindb
zxcvb1531 小时前
MySQL三种备份方式:原理、优缺点与实操选型指南
数据库·mysql
夜雪一千1 小时前
PostgreSQL 自定义函数入门
数据库·postgresql
香蕉大香蕉(06敬畏市场)2 小时前
事务隔离级别、MVCC 与锁:一条线串起来
java·服务器·数据库·人工智能·面试·博客
CoderYanger2 小时前
Java EE 进阶:16. Spring原理(第一弹)
java·服务器·数据库·后端·spring·java-ee·github
开开心心就好2 小时前
游戏安装报错缺环境?运行库整合包补上
java·mysql·游戏·pdf·ocr·音视频·lua
herinspace2 小时前
管家婆实用帖-SQL 2000如何修改混合模式
服务器·数据库·sql·管家婆软件·合肥管家婆软件·安徽功长网络科技有限公司
霸道流氓气质2 小时前
分布式序列号生成:基于 Redis 原子自增的编号方案
数据库·redis·分布式
Yuzhiyuxia3 小时前
【AI Agent 面试系列】LangGraph 设计思想与基础概念
数据库