Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.13.0 RC 3
-
None
Description
In file qsql_mysql.cpp, the function open has code:
if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) { // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters) mysql_set_character_set(d->mysql, "utf8mb4"); #if QT_CONFIG(textcodec) d->tc = QTextCodec::codecForName("UTF-8"); #endif } else { // force the communication to be utf8 mysql_set_character_set(d->mysql, "utf8"); #if QT_CONFIG(textcodec) d->tc = codec(d->mysql); #endif }
On my computer, the function call "mysql_set_character_set(d->mysql, "utf8mb4");" is failed, but d->tc is still set to '"UTF-8", which cause charaster_set error.
I have modified the source code like this and it works fine to me :
// Some comments here // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters) int ret = mysql_set_character_set(d->mysql, "utf8mb4"); if (0 != ret) { // try utf8 if utf8mb4 failed ret = mysql_set_character_set(d->mysql, "utf8"); } #if QT_CONFIG(textcodec) if (0 != ret) { d->tc = QTextCodec::codecForName("UTF-8"); } else { d->tc = codec(d->mysql); } #endif