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

相关推荐
薛定谔的悦几秒前
光伏-储能-负荷联合预测:给 EMS 装上“预知能力“
java·数据库·人工智能·python·储能
阿演2 分钟前
DataDjinn v0.1.6 更新:增加在线更新功能,Redis 数据源支持,表格预览和连接体验继续增强
数据库·redis·缓存·数据库连接工具
数据库小学妹3 分钟前
InnoDB内存架构解密:Buffer Pool与性能优化实战
数据库·经验分享·sql·性能优化·架构
Lyyaoo.7 分钟前
【MySQL】SQL优化
android·sql·mysql
AI人工智能+电脑小能手8 分钟前
【大白话说Java面试题 第89题】【Mysql篇】第19题:Hash 索引和 B+ 树索引的区别?它们在使用方面的区别?
java·数据库·mysql·面试·哈希算法
一只fish18 分钟前
Oracle官方文档翻译《Database Concepts 26ai》第17章-内存架构
数据库·oracle
元宝骑士34 分钟前
MySQL 实战:跨表排序 + 指定类型置顶四种写法
后端·mysql
比企谷八幡36 分钟前
一张表在磁盘上长什么样:Heap File 入门
数据库·oracle
流星白龙38 分钟前
【MySQL高阶】11.InnoDB存储引擎
数据库·mysql
wangbing11251 小时前
SQL Server2008 R2版自动备份问题
数据库