GreatSQL社区

搜索

[已解决] Cannot convert string '\xE9\x87...' from utf8mb3 to binary

1129 4 2023-2-23 16:22
8.0.32查一个视图中的中文报错,默认字符集utf8mb4和utf8mb4_0900_ai_ci
视图引用的表字段为utf8mb3,未在视图上指定字符集,显示为utf8mb4和utf8mb4_0900_ai_ci
select * from t1 where name ='金'
查询无结果 show warnnings报Cannot convert string '\xE9\x87...' from utf8mb3 to binary,
直接查源表的对应字段无问题。
这个怎么解决?

全部回复(4)
nyp30 2023-2-23 19:39:23
复现
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';
nyp30

2

主题

0

博客

9

贡献

新手上路

Rank: 1

积分
14

合作电话:010-64087828

社区邮箱:greatsql@greatdb.com

社区公众号
社区小助手
QQ群
GMT+8, 2024-5-19 05:54 , Processed in 0.017515 second(s), 14 queries , Redis On.
快速回复 返回顶部 返回列表