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

相关推荐
QQ35967734523 分钟前
ArcGIS Pro实现基于 Excel 表格批量创建标准地理数据库(GDB)——高效数据库建库解决方案
数据库·arcgis·excel
学编程的小程1 小时前
突破局域网限制:MongoDB远程管理新体验
数据库·mongodb
波波烤鸭1 小时前
Redis 高可用实战源码解析(Sentinel + Cluster 整合应用)
数据库·redis·sentinel
l1t5 小时前
利用DeepSeek实现服务器客户端模式的DuckDB原型
服务器·c语言·数据库·人工智能·postgresql·协议·duckdb
MarkHard1239 小时前
如何利用redis使用一个滑动窗口限流
数据库·redis·缓存
island131410 小时前
【Redis#10】渐进式遍历 | 数据库管理 | redis_cli | RES
数据库·redis·bootstrap
心想事成的幸运大王11 小时前
Redis的过期策略
数据库·redis·缓存
倔强的石头_11 小时前
CentOS 上安装KingbaseES(ISO包)详细教程
数据库
2401_8979300611 小时前
使用Docker轻松部署Neo4j图数据库
数据库·docker·neo4j
诗句藏于尽头12 小时前
Django模型与数据库表映射的两种方式
数据库·python·django