复现
CREATE TABLE `test` (
`ID` varchar(64) NOT NULL COMMENT 'id',
`NAME` varchar(200) DEFAULT NULL COMMENT '名称',
PRIMARY KEY (`ID`) USING BTREE
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
insert into test values('1','中国');
select * from (select name from test union all select name from test) b where b.name='中国';
官方8.0.32有关union的修改
8.0.32 修改了union的 一些bug可能和这个有个
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)
感谢一位大神提供的临时解决方案
set optimizer_switch='derived_condition_pushdown=off'; |