From 7d4fc503a110c6eb9f34222911bffb4f41585ba6 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Wed, 16 Mar 2016 08:54:26 +0100 Subject: [PATCH] Fixed #169. --- resources/text/CHANGELOG | 1 + src/miscellaneous/databasefactory.cpp | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index 073d95dd1..22465fb5f 100755 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -13,6 +13,7 @@ Added: Fixed: +▪ Better detection of MySQL server status. (bug #169) ▪ Ordering of messages is now done on SQL server (stands for both MySQL and SQLite). (bug #172) ▪ Now title of the RSS/ATOM message is taken into account when deciding message "uniqueness". (bug #171) ▪ MySQL scripts improved. (bug #170) diff --git a/src/miscellaneous/databasefactory.cpp b/src/miscellaneous/databasefactory.cpp index 905b8be0e..a20e180c4 100755 --- a/src/miscellaneous/databasefactory.cpp +++ b/src/miscellaneous/databasefactory.cpp @@ -106,9 +106,19 @@ DatabaseFactory::MySQLError DatabaseFactory::mysqlTestConnection(const QString & database.setDatabaseName(w_database); if (database.open() && !database.lastError().isValid()) { - // Connection succeeded, clean up the mess and return OK status. - database.close(); - return MySQLOk; + QSqlQuery query(QSL("SELECT version();"), database); + + if (!query.lastError().isValid() && query.next()) { + qDebug("Checked MySQL database, version is '%s'.", qPrintable(query.value(0).toString())); + + // Connection succeeded, clean up the mess and return OK status. + database.close(); + return MySQLOk; + } + else { + database.close(); + return MySQLUnknownError; + } } else if (database.lastError().isValid()) { // Connection failed, do cleanup and return specific error code.