Unsolved Unable to use QMYSQL driver on ArchLinux after migrating to Qt 5.6.0
-
Hi everyone,
I updated the packages of Archlinux (qt5-base) from Qt 5.5.1 to Qt 5.6.0 and since then I can't use SQL request with UNION, it looks like my server doesn't load properly QMYSQL but instead use QMYSQL3.
A similar issue was reported years ago: Project is using QMYSQL3 instead of QMYSQL?
The function QSqlDatabase::drivers() return when starting the server:
("QIBASE", "QSQLITE", "QMYSQL", "QMYSQL3", "QODBC", "QODBC3", "QPSQL", "QPSQL7", "QTDS", "QTDS7")I create a my database this way:
m_mainDatabase = new QSqlDatabase(QSqlDatabase::addDatabase("QMYSQL", m_mainDBName)); dsInitLog(QString("Driver name for main database: %1").arg(m_mainDatabase->driverName()));
This return: "Driver name for main database: QMYSQL"
But then when I do when of the select that try to access query.next(), it fails (when previous select worked strangely):
Here is my code and my logs, maybe you could see something wrong. This works fine with Qt 5.5.1 on ArchLinux
// Code
dsLog(getLastExecutedQuery(query)); if (query.size() == 1) { dsLog(QString("query select: %1").arg(query.isSelect())); int resultNext = query.next(); dsLog(QString("query next: %1").arg(resultNext)); dsLog(QString("query valid: %1").arg(query.isValid())); dsLog(QString("Last query error: %1").arg(query.lastError().text())); DSConnection::UserInfo currentUserInfo; currentUserInfo.idPackage = query.value(0).toULongLong(); currentUserInfo.beginOfServices = query.value(1).toDate(); [...] }
// Logs
virtual DSBaseMessage* DSServerStartupMessage::exec(DSSocket&) "SELECT `id_package`, `begin_of_services`, `new_month`, `end_of_services`, `space_max`, `bandwidth_used`, `bandwidth_max`, `enable_authentication`, `id_disk` FROM `USERS_INFOS` WHERE `id_user` = 1" virtual DSBaseMessage* DSServerStartupMessage::exec(DSSocket&) "query select: 1" virtual DSBaseMessage* DSServerStartupMessage::exec(DSSocket&) "query next: 0" virtual DSBaseMessage* DSServerStartupMessage::exec(DSSocket&) "query valid: 0" virtual DSBaseMessage* DSServerStartupMessage::exec(DSSocket&) "Last query error: QMYSQL3: Unable to fetch data" QSqlQuery::value: not positioned on a valid record QSqlQuery::value: not positioned on a valid record
This query return a result on phpMyAdmin.
Any help appreciated, thanks a lot.
-
Hi,
You should run ldd on the MySQL plugin to see if you don't have a library mismatch there.
-
@SGaist I did but no obvious error there:
ldd /usr/lib/qt/plugins/sqldrivers/libqsqlmysql.so linux-vdso.so.1 (0x00007fffb9fff000) libmysqlclient.so.18 => /usr/lib/libmysqlclient.so.18 (0x00007f24d5eb8000) libQt5Sql.so.5 => /usr/lib/libQt5Sql.so.5 (0x00007f24d5c71000) libQt5Core.so.5 => /usr/lib/libQt5Core.so.5 (0x00007f24d55a7000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f24d5224000) libc.so.6 => /usr/lib/libc.so.6 (0x00007f24d4e83000) libz.so.1 => /usr/lib/libz.so.1 (0x00007f24d4c6d000) libssl.so.1.0.0 => /usr/lib/libssl.so.1.0.0 (0x00007f24d49fb000) libcrypto.so.1.0.0 => /usr/lib/libcrypto.so.1.0.0 (0x00007f24d4584000) libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f24d4380000) libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f24d4162000) libm.so.6 => /usr/lib/libm.so.6 (0x00007f24d3e5d000) libicui18n.so.56 => /usr/lib/libicui18n.so.56 (0x00007f24d39e1000) libicuuc.so.56 => /usr/lib/libicuuc.so.56 (0x00007f24d3649000) libpcre16.so.0 => /usr/lib/libpcre16.so.0 (0x00007f24d33e3000) libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x00007f24d30d5000) librt.so.1 => /usr/lib/librt.so.1 (0x00007f24d2ecc000) libsystemd.so.0 => /usr/lib/libsystemd.so.0 (0x00007f24d2e46000) libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f24d2c30000) /usr/lib64/ld-linux-x86-64.so.2 (0x00007f24d6640000) libicudata.so.56 => /usr/lib/libicudata.so.56 (0x00007f24d124c000) libpcre.so.1 => /usr/lib/libpcre.so.1 (0x00007f24d0fdc000) libcap.so.2 => /usr/lib/libcap.so.2 (0x00007f24d0dd7000) libresolv.so.2 => /usr/lib/libresolv.so.2 (0x00007f24d0bc0000) liblzma.so.5 => /usr/lib/liblzma.so.5 (0x00007f24d099a000) liblz4.so.1 => /usr/lib/liblz4.so.1 (0x00007f24d0787000) libgcrypt.so.20 => /usr/lib/libgcrypt.so.20 (0x00007f24d04a5000) libgpg-error.so.0 => /usr/lib/libgpg-error.so.0 (0x00007f24d0291000)
-
Which version of MySQL are you running ?
-
@SGaist Is it this you are referring to: libmariadbclient 10.1.13-1 (https://www.archlinux.org/packages/extra/i686/libmariadbclient/)
-
Did that part also change when you updated your Qt version ?
-
@SGaist Yes it did the first time from 10.1.12 to 10.1.13.
But strangely when I rollback only qt5 packages to Qt 5.5.1, then it works again.
-
Can you check the output you get from your application when running it with
QT_DEBUG_PLUGINS=1
defined ? -
@SGaist Here is the result:
[dev@preprod binserver]$ export QT_DEBUG_PLUGINS=1 [dev@preprod binserver]$ ./DSServer QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/qt/plugins/sqldrivers" ... QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt/plugins/sqldrivers/libqsqlibase.so" Found metadata in lib /usr/lib/qt/plugins/sqldrivers/libqsqlibase.so, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QIBASE" ] }, "className": "QIBaseDriverPlugin", "debug": false, "version": 329216 } Got keys from plugin meta data ("QIBASE") QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt/plugins/sqldrivers/libqsqlite.so" Found metadata in lib /usr/lib/qt/plugins/sqldrivers/libqsqlite.so, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QSQLITE" ] }, "className": "QSQLiteDriverPlugin", "debug": false, "version": 329216 } Got keys from plugin meta data ("QSQLITE") QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt/plugins/sqldrivers/libqsqlmysql.so" Found metadata in lib /usr/lib/qt/plugins/sqldrivers/libqsqlmysql.so, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QMYSQL3", "QMYSQL" ] }, "className": "QMYSQLDriverPlugin", "debug": false, "version": 329216 } Got keys from plugin meta data ("QMYSQL3", "QMYSQL") QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt/plugins/sqldrivers/libqsqlodbc.so" Found metadata in lib /usr/lib/qt/plugins/sqldrivers/libqsqlodbc.so, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QODBC3", "QODBC" ] }, "className": "QODBCDriverPlugin", "debug": false, "version": 329216 } Got keys from plugin meta data ("QODBC3", "QODBC") QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt/plugins/sqldrivers/libqsqlpsql.so" Found metadata in lib /usr/lib/qt/plugins/sqldrivers/libqsqlpsql.so, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QPSQL7", "QPSQL" ] }, "className": "QPSQLDriverPlugin", "debug": false, "version": 329216 } Got keys from plugin meta data ("QPSQL7", "QPSQL") QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt/plugins/sqldrivers/libqsqltds.so" Found metadata in lib /usr/lib/qt/plugins/sqldrivers/libqsqltds.so, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QTDS7", "QTDS" ] }, "className": "QTDSDriverPlugin", "debug": false, "version": 329216 } Got keys from plugin meta data ("QTDS7", "QTDS") QFactoryLoader::QFactoryLoader() checking directory path "/home/dev/binserver/sqldrivers" ... loaded library "/usr/lib/qt/plugins/sqldrivers/libqsqlmysql.so" Found metadata in lib /home/dev/binserver/plugins/libdscommunityserver.so, metadata= { "IID": "com.dsbrowser.DSPluginLoaderInterface", "MetaData": { }, "className": "DSPluginCommunityServer", "debug": false, "version": 329216 }
-
@SGaist Does that seems correct?
-
At first sight nothing wrong there.
Can you do some test building your own version of the MySQL plugin ?
The plugin hasn't had many commits recently so it might be easy to determine if something broke there between 5.5.1 and 5.6.0
-
@SGaist Well I never done it so I don't know where to start?
-
@SGaist I also posted on Archlinux without much reply, but the maintainer said it works for him on another project: https://bugs.archlinux.org/task/48778
-
You have to clone the qtbase module and from there you can either use
git bisect
or since there's only handful of commits, checkout the commit before any that changed the plugin code. -
After further investigation today, this appears to be a bug in Qt, QSqlQuery doesn't work with UNSIGNED values: https://bugreports.qt.io/browse/QTBUG-53237
-
This error occurs due to binary intolerance of libmysqlclient version 1.8 and 1.6. Qt used version 1.6 to compile but you have version 1.6 installed.
Solution: make MySql plugin manually. -
@Hamed.Masafi I'm on Archlinux which is a Rolling release, so indeed the version of libmysqlclient update quickly, but I would assume that the people that package qt5-base are compiling Qt with the current version available: https://www.archlinux.org/packages/extra/x86_64/qt5-base/ & https://www.archlinux.org/packages/extra/x86_64/libmariadbclient/