MySQL 8.0.26版本升級32版本查詢數(shù)據(jù)為空的解決方案
某業(yè)務(wù)系統(tǒng)將MySQL 8.0.26升級為GreatSQL 8.0.32-24 后,某些特定的SQL語句不能查詢到數(shù)據(jù)。經(jīng)測試 MySQL 8.0.32也存在相同的問題
此BUG已在 GreatSQL 8.0.32-25 版本中解決
MySQL 8.0.26版本升級32版本查詢數(shù)據(jù)為空的跟蹤
接到客戶反饋的問題后,對問題進(jìn)行了復(fù)現(xiàn)和分析。
版本信息
greatsql> select version(); +-----------+ | version() | +-----------+ | 8.0.32-24 | +-----------+ 1 row in set (0.00 sec)
建表語句
greatsql> show create table t_student; CREATE TABLE `t_student1` ( `id` int NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `age` int NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
表數(shù)據(jù)
greatsql> select * from t_student; +----+--------+-----+ | id | name | age | +----+--------+-----+ | 1 | abc | 10 | | 2 | 湯姆 | 20 | +----+--------+-----+ 2 rows in set (0.08 sec)
查詢數(shù)據(jù)
greatsql> select * from (select * from t_student union select * from t_student) temp where name='湯姆'; Empty set, 2 warnings (0.00 sec) greatsql> show warnings; +---------+------+-------------------------------------------------------------------------+ | Level | Code | Message | +---------+------+-------------------------------------------------------------------------+ | Warning | 1300 | Cannot convert string '\xE6\xB1\xA4\xE5\xA7\x86' from utf8mb4 to binary | | Warning | 1300 | Cannot convert string '\xE6\xB1\xA4\xE5\xA7\x86' from utf8mb4 to binary | +---------+------+-------------------------------------------------------------------------+ 2 rows in set (0.00 sec) greatsql> select * from (select * from t_student union select * from t_student) temp; +----+--------+-----+ | id | name | age | +----+--------+-----+ | 1 | abc | 10 | | 2 | 湯姆 | 20 | +----+--------+-----+ 2 rows in set (0.00 sec) greatsql> select * from (select * from t_student union select * from t_student) temp where name='abc'; +----+------+-----+ | id | name | age | +----+------+-----+ | 1 | abc | 10 | +----+------+-----+ 1 row in set (0.00 sec)
可以看到 直接查詢temp這個view或者 在視圖上添加英文過濾條件均能查詢出數(shù)據(jù),在view上添加中文過濾條件sql語句返回結(jié)果為空,有warnings提醒,warnings具體內(nèi)容為Cannot convert string
在官方網(wǎng)站進(jìn)行搜索,以下連接有相似內(nèi)容:
https://bugs.mysql.com/bug.php?id=110228
https://bugs.mysql.com/bug.php?id=110955
MySQL 8.0.32版本中對于UNION/UNION ALL 后的結(jié)果中的字符串字段過濾篩選不生效,客戶端中提示:
Cannot convert string '%\x...' from utf8mb4 to binary
官方已確認(rèn)是8.0.32中的一個bug,已在8.0.33版本中修復(fù),對于8.0.32版本,官方給出的解決方式如下:
set optimizer_switch="derived_condition_pushdown=off";
讓所有Session都生效,需要在配置文件中將optimizer_switch
設(shè)置為off
此BUG已在 GreatSQL 8.0.32-25 版本中解決
解決方法
方法一:
設(shè)置set optimizer_switch="derived_condition_pushdown=off";
后SQL語句能正常執(zhí)行
greatsql> set optimizer_switch='derived_condition_pushdown=off'; Query OK, 0 rows affected (0.00 sec) greatsql> select * from (select * from t_student union select * from t_student) temp where name='湯姆'; +----+--------+-----+ | id | name | age | +----+--------+-----+ | 2 | 湯姆 | 20 | +----+--------+-----+ 1 row in set (0.00 sec)
方法二:
對單個SQL語句設(shè)置NO_DERIVED_CONDITION_PUSHDOWN hint
greatsql> set optimizer_switch='derived_condition_pushdown=on'; Query OK, 0 rows affected (0.00 sec) greatsql> select * from (select * from t_student union select * from t_student) temp where name='湯姆'; Empty set, 2 warnings (0.00 sec) greatsql> select /*+ NO_DERIVED_CONDITION_PUSHDOWN(temp) */ * from (select * from t_student union select * from t_student) temp where name='湯姆'; +----+--------+-----+ | id | name | age | +----+--------+-----+ | 2 | 湯姆 | 20 | +----+--------+-----+ 1 row in set (0.00 sec)
Enjoy GreatSQL ??
關(guān)于 GreatSQL
GreatSQL是適用于金融級應(yīng)用的國內(nèi)自主開源數(shù)據(jù)庫,具備高性能、高可靠、高易用性、高安全等多個核心特性,可以作為MySQL或Percona Server的可選替換,用于線上生產(chǎn)環(huán)境,且完全免費(fèi)并兼容MySQL或Percona Server。
相關(guān)鏈接: GreatSQL社區(qū) GiteeGitHubBilibili
GreatSQL社區(qū):
社區(qū)博客有獎?wù)鞲逶斍椋?a rel="external nofollow" target="_blank">https://greatsql.cn/thread-100-1-1.html
到此這篇關(guān)于MySQL 8.0.26版本升級32版本查詢數(shù)據(jù)為空的跟蹤的文章就介紹到這了,更多相關(guān)mysql查詢數(shù)據(jù)為空內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- mysql從5.7平滑升級到8.0.27的實現(xiàn)
- MySQL本地版本升級超詳細(xì)教程(從5.5.20升到8.0.21)
- MySQL5.7升級MySQL8.0的完整卸載與安裝及連接Navicat的步驟
- MySQL如何從5.5升級到8.0(使用命令行升級)
- MySQL和MySQL驅(qū)動mysql-connector-java升級到8.0.X版本問題
- 升級到mysql-connector-java8.0.27的注意事項
- MySQL8.0升級的踩坑歷險記
- Docker版的MySQL5.7升級到MySQL8.0.13,數(shù)據(jù)遷移
- win2008下mysql8.0.11升級mysql8.0.17版本詳細(xì)步驟
- MySQL8.0就地升級到MySQL8.4.0的方法
相關(guān)文章
mysql err錯誤提示You need to use --log-
今天在檢查mysql服務(wù)器錯誤日志的時候發(fā)現(xiàn)You need to use --log-bin to make --binlog-format work,通過如下方法解決了特分享一下2023-06-06mysql 8.0 錯誤The server requested authentication method unkno
在本篇文章里小編給大家整理的是關(guān)于mysql 8.0 錯誤The server requested authentication method unknown to the client解決方法,有此需要的朋友們可以學(xué)習(xí)下。2019-08-08my.cnf參數(shù)配置實現(xiàn)InnoDB引擎性能優(yōu)化
目前來說:InnoDB是為Mysql處理巨大數(shù)據(jù)量時的最大性能設(shè)計。它的CPU效率可能是任何其它基于磁盤的關(guān)系數(shù)據(jù)庫引擎所不能匹敵的。在數(shù)據(jù)量大的網(wǎng)站或是應(yīng)用中Innodb是倍受青睞的。另一方面,在數(shù)據(jù)庫的復(fù)制操作中Innodb也是能保證master和slave數(shù)據(jù)一致有一定的作用。2017-05-05