remove the version number checks in favor of actual functionality

MariaDB library version 3.2 no longer returns the server version in the
10.x range but the library version itself, which is lower than 4.x. That
meant we concluded the server did not support prepared statements.

And because of the lack of prepared statements, all QDateTime
conversions failed, because of the timezone. I don't know if this was
intended or what, but it's a side issue.
Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=211369133cf40b2f
Last-Update: 2021-08-10

Gbp-Pq: Name mysql_remove_version_checks.diff
This commit is contained in:
Debian Qt/KDE Maintainers 2022-05-14 17:41:00 +08:00 committed by openKylinBot
parent 1115543648
commit 11abf4e0d0
1 changed files with 15 additions and 2 deletions

View File

@ -158,6 +158,20 @@ static inline QVariant qDateTimeFromString(QString &val)
#endif #endif
} }
// check if this client and server version of MySQL/MariaDB support prepared statements
static inline bool checkPreparedQueries(MYSQL *mysql)
{
std::unique_ptr<MYSQL_STMT, decltype(&mysql_stmt_close)> stmt(mysql_stmt_init(mysql), &mysql_stmt_close);
if (!stmt)
return false;
static const char dummyQuery[] = "SELECT ? + ?";
if (mysql_stmt_prepare(stmt.get(), dummyQuery, sizeof(dummyQuery) - 1))
return false;
return mysql_stmt_param_count(stmt.get()) == 2;
}
class QMYSQLResultPrivate; class QMYSQLResultPrivate;
class QMYSQLResult : public QSqlResult class QMYSQLResult : public QSqlResult
@ -1371,8 +1385,7 @@ bool QMYSQLDriver::open(const QString& db,
} }
#endif // MYSQL_VERSION_ID >= 50007 #endif // MYSQL_VERSION_ID >= 50007
d->preparedQuerysEnabled = mysql_get_client_version() >= 40108 d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
&& mysql_get_server_version(d->mysql) >= 40100;
#if QT_CONFIG(thread) #if QT_CONFIG(thread)
mysql_thread_init(); mysql_thread_init();