summaryrefslogtreecommitdiffstats
path: root/src/plugins/sqldrivers/mysql
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/sqldrivers/mysql')
-rw-r--r--src/plugins/sqldrivers/mysql/qsql_mysql.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
index b13e10e3a5..30a0a04f44 100644
--- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
@@ -1414,8 +1414,13 @@ bool QMYSQLDriver::open(const QString& db,
}
#if (MYSQL_VERSION_ID >= 40113 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID >= 50007
- // force the communication to be utf8
- mysql_set_character_set(d->mysql, "utf8");
+ 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");
+ } else {
+ // force the communication to be utf8
+ mysql_set_character_set(d->mysql, "utf8");
+ }
#endif
#ifndef QT_NO_TEXTCODEC
d->tc = codec(d->mysql);