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

相关推荐
Nturmoils26 分钟前
查库存的 SQL 时灵时不灵,最后发现是 WHERE 里两个函数在打架
数据库
不想纳尼的青春1 小时前
where = 的作用?会影响性能吗?count(*) 和 count()哪个快?
数据库·oracle
倔强的石头_2 小时前
Spring Boot 接入金仓数据库:配置分层、启动自检与常见错误
数据库
黑桃小柒72 小时前
Django模型关系:从一对多到多对多全解析
数据库·django·sqlite
上海安当技术2 小时前
统一身份认证平台怎么落地?11 个异构业务系统接入 ASP 的完整实施路径
数据库·servlet·架构·kubernetes·jenkins
全栈派森2 小时前
告别大表膨胀!MySQL 冷热分离落地全过程(含 CDC 与单行锁抢占实战)
大数据·mysql
篮框坏了3 小时前
大事务 DELETE 锁表排查:删 3344 万行,一个清理任务变成周期炸弹
mysql
在水一缸3 小时前
PGSimCity:当数据库内核变成一座可以漫步的城市
数据库·postgresql·可视化·开源项目·数据库内核·pgsimcity·技术科普
jnrjian3 小时前
psql 执行多个 sql 文件
数据库·sql
LinuxGeek10243 小时前
Kylin-Server-V11、openEuler-22.03和openEuler-24.03适配原生rpm的MySQL 8.4.11版本正式发布
大数据·mysql·kylin