FS#48778 - [qt5-base] QMYSQL driver is not available

Attached to Project: Arch Linux
Opened by Jonathan Courtois (johnlamericain) - Thursday, 31 March 2016, 21:50 GMT
Last edited by Antonio Rojas (arojas) - Tuesday, 14 June 2016, 16:14 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Antonio Rojas (arojas)
Felix Yan (felixonmars)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
Since I updated to qt5-base in 5.6.0, my application compiled with that version stop working because the QMYSQL driver can't be found/loaded properly. It's possibly that a mysqldriver was updated with pacman at the same time of 5.6.0 though (there was a mariadb update).

This was working correctly with qt5-base 5.5.1 so I wonder if something went wrong during the build?

Additional info:
* qt5-base 5.6.0-2
* I can't see anything wrong with the .so:

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)

Steps to reproduce:
QSqlDatabase::isDriverAvailable("QMYSQL") <- return false
This task depends upon

Closed by  Antonio Rojas (arojas)
Tuesday, 14 June 2016, 16:14 GMT
Reason for closing:  Fixed
Additional comments about closing:  qt5-base 5.6.1-2
Comment by Jonathan Courtois (johnlamericain) - Thursday, 31 March 2016, 21:54 GMT
lrwxrwxrwx 1 root root 20 Mar 24 11:27 libmysqlclient.so -> libmysqlclient.so.18
lrwxrwxrwx 1 root root 24 Mar 24 11:27 libmysqlclient.so.18 -> libmysqlclient.so.18.0.0
-rwxr-xr-x 1 root root 3507712 Mar 24 11:27 libmysqlclient.so.18.0.0
lrwxrwxrwx 1 root root 17 Mar 24 11:27 libmysqlclient_r.so -> libmysqlclient.so
lrwxrwxrwx 1 root root 17 Mar 24 11:27 libmysqlclient_r.so.18 -> libmysqlclient.so
lrwxrwxrwx 1 root root 17 Mar 24 11:27 libmysqlclient_r.so.18.0.0 -> libmysqlclient.so
lrwxrwxrwx 1 root root 15 Mar 24 11:27 libmysqld.so -> libmysqld.so.18
-rwxr-xr-x 1 root root 15904536 Mar 24 11:27 libmysqld.so.18
Comment by Jonathan Courtois (johnlamericain) - Thursday, 31 March 2016, 21:58 GMT
The last libmysqlclient.so I have come with libmariadbclient 10.1.13-1 (https://www.archlinux.org/packages/extra/i686/libmariadbclient/)
Comment by Jonathan Courtois (johnlamericain) - Sunday, 03 April 2016, 21:28 GMT
FYI, when I downgrade to qt5-base 5.5.1-10, it works again on the same environement. So there is probably a problem in the way the packaging of qt5-base 5.6.0-2 was done.
Comment by Jonathan Courtois (johnlamericain) - Sunday, 10 April 2016, 11:00 GMT
I updated to qt5-base 5.6.0-3 but I still have the same problem. It looks like it default my QMYSQL to QMYSQL3. Then I have errors like: "QSqlQuery::value: not positioned on a valid record"
Any advice of where I should look at?
Comment by Jonathan Courtois (johnlamericain) - Sunday, 17 April 2016, 10:49 GMT
Is it possible to have a reply to this bug, to see if you are looking into it or if I should search by myself?

Thanks
Comment by Antonio Rojas (arojas) - Sunday, 17 April 2016, 10:53 GMT
I've been using akonadi with the mysql driver with no issues. Could you provide a minimal example application that reproduces the issue?
Comment by Jonathan Courtois (johnlamericain) - Sunday, 17 April 2016, 21:35 GMT
Hi Antonio,

Thanks for your reply, I gave another look at it tonight. Basically code working with Qt 5.5.1 doesn't work with Qt 5.6.0.

It's hard to give you some code, but if I don't get anywhere I will try to reproduce this in a small example.

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.

Also notice the QMYSQL3 on the last query error!!!

Any idea? I will keep looking on my side.

Thanks for help.
Comment by Jonathan Courtois (johnlamericain) - Sunday, 17 April 2016, 21:37 GMT
I just found this: https://forum.qt.io/topic/46892/project-is-using-qmysql3-instead-of-qmysql

Could it be that qt5-base 5.6.0 use MySQL driver instead of MariaDB driver like in the past?
Comment by Jonathan Courtois (johnlamericain) - Wednesday, 27 April 2016, 22:23 GMT
@Antonios, do you think it could be due to this refactoring: https://github.com/qtproject/qtbase/commit/0452c25aedb7d2778e5b26fad924ed61b72bbe33 ?

I updated to qt5-base 5.6.0-4 but I still can't get MySQL driver working with complex queries as it seems to use QMYSQL3...
Comment by Antonio Rojas (arojas) - Wednesday, 27 April 2016, 22:30 GMT
That commit doesn't affect 5.6 at all (not even 5.7).
Comment by Jonathan Courtois (johnlamericain) - Wednesday, 27 April 2016, 22:32 GMT
I'm just getting out of idea here..
Comment by Antonio Rojas (arojas) - Wednesday, 27 April 2016, 22:38 GMT
Please try with the Qt binaries from https://www.qt.io/download-open-source/ to check if it's a packaging or upstream issue.
Comment by Jonathan Courtois (johnlamericain) - Saturday, 11 June 2016, 10:55 GMT
This appears to be a Qt bug and not a plugin/packaging bug:

https://bugreports.qt.io/browse/QTBUG-53237
https://bugreports.qt.io/browse/QTBUG-53969

The error reported "QMYSQL3: Unable to fetch data" is confusing as I was using QMYSQL plugin.

Thanks for your help, this can be closed.
Comment by Jonathan Courtois (johnlamericain) - Sunday, 12 June 2016, 12:41 GMT
I have a question, when you package qt5-base, do you recompile it and link it libmysqlclient version 1.8?

Apparently there could be a binary intolerance of libmysqlclient 1.8 and 1.6. Qt used version 1.6 to compile but Archlinux has version 1.8 installed.

Thanks for your answer
Comment by Antonio Rojas (arojas) - Sunday, 12 June 2016, 12:43 GMT
What do you mean by "libmysqlclient version 1.8"? libmysqlclient is provided by the libmadiadbclient package, which is currently at version 10.1.14
Comment by Jonathan Courtois (johnlamericain) - Sunday, 12 June 2016, 12:48 GMT
Thanks for your answer Antonio,

Yes you are right about libmadiadbclient: https://www.archlinux.org/packages/extra/x86_64/libmariadbclient/:

I'm talking about this plugins in the content of that lib:
usr/lib/libmysqlclient.so
usr/lib/libmysqlclient.so.18
usr/lib/libmysqlclient.so.18.0.0
usr/lib/libmysqlclient_r.so
usr/lib/libmysqlclient_r.so.18
usr/lib/libmysqlclient_r.so.18.0.0

When I do:
ldd /usr/lib/qt/plugins/sqldrivers/libqsqlmysql.so
...
libmysqlclient.so.18 => /usr/lib/libmysqlclient.so.18 (0x00007f24d5eb8000)
...

That's what it was suggested to me in Qt Forum: https://forum.qt.io/topic/66160/unable-to-use-qmysql-driver-on-archlinux-after-migrating-to-qt-5-6-0/16

Thanks
Comment by Antonio Rojas (arojas) - Sunday, 12 June 2016, 12:53 GMT
I still don't get what the issue is. The soversion of libmysqlclient has been 18 at least since the mariadb 10.1 update. And qt has been built multiple times since then, so it definitely was built against libmysqlclient.so.18 (packages are always rebuilt when a linked library bumps the soversion)
Comment by Jonathan Courtois (johnlamericain) - Sunday, 12 June 2016, 12:59 GMT
I'm not sure I understand the issue either, I'm trying to see both possibility, a bug in Qt code or an incompatibility between mysqlplugin.

But if you said that Qt is recompiled and linked with libmysqlclient.so.18 on Arch, then it's probably not the problem.

Thank you for this precious information.

Loading...