查询报1300 - Invalid utf8mb4 character string: 'F0A18CB6'错误

执行select语句报1300 - Invalid utf8mb4 character string: 'F0A18CB6’错误,但是设置set @@session.tidb_isolation_read_engines = "tiflash"之后执行正常。

执行的sql看下,另外对应表的字符集设置看下,tiflash正常显示是啥样的?

SELECT
count(*) cnt
FROM
db_ysb_dictionary.ts_drugstore_branch b
INNER JOIN ti_ysb_dictionary.ts_provider_drugstore a ON a.storetitle = b.full_name
INNER JOIN db_ysb_dictionary.ts_drugstore_provider c ON b.id = c.drugstore_branch_id
AND c.provider_id = a.provider_id
AND c.first_order_time > UNIX_TIMESTAMP() - 86400 * 3

没有设置tiflash的执行计划

设置了tiflash的执行计划

感觉tikv里面有的数据出问题了,不符合uf8mb4规则

几个表的字符集都是“DEFAULT CHARSET=utf8 COLLATE=utf8_bin”这样定义的


tidb日志有这个报错

你的表都是utf8的字符集,但是报了utf8mb4这个字符集的错误。。。这两个数据库db_ysb_dictionary和ti_ysb_dictionary的默认字符集是什么?

都是utf8mb4
image

https://github.com/pingcap/tidb/issues/31721

像是5.4的bug。

确实很像

库的字符集是utf8mb4的话,表的字符集在查询的时候是要转换的,应该是触发tidb的utf8mb4字符集的bug了,你可以在测试环境创建个utf8的库,然后把这里表导过去,再查下看看

那岂不是只能升级了。

可以升级试试。TiFlash 使用了不同的字符集或编码方式来处理数据,可能够绕过该错误。

应该是触发了bug,我之前也遇到过

#!/bin/bash

# Function to check the character encoding settings
check_character_encoding() {
    echo "Checking character encoding settings..."
    echo "Database Character Encoding:"
    mysql -u <username> -p<password> -e "SHOW VARIABLES LIKE 'character_set%';"
    echo "Client Application Character Encoding:"
    locale charmap
}

# Function to check the table and column settings
check_table_column_settings() {
    echo "Checking table and column settings..."
    echo "Table and Column Character Set and Collation:"
    mysql -u <username> -p<password> -e "SELECT TABLE_NAME, COLUMN_NAME, CHARACTER_SET_NAME, COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '<database_name>';"
}

# Function to check the database configuration
check_database_configuration() {
    echo "Checking database configuration..."
    echo "Database Configuration:"
    mysql -u <username> -p<password> -e "SHOW VARIABLES LIKE '%char%';"
}

# Main function
main() {
    check_character_encoding
    check_table_column_settings
    check_database_configuration
}

# Run the main function
main

此话题已在最后回复的 60 天后被自动关闭。不再允许新回复。