Commit 10d1e2bd authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Check minimum MySQL server version

Akonadi requires at least MySQL 5.1 (because of using information_schema.REFERENTIAL_CONSTRAINTS
column that was introduced in 5.1), so make sure we are running against at least that version.

BUG: 323977
FIXED-IN: 1.10.3
parent fd7165a1
......@@ -34,6 +34,9 @@
using namespace Akonadi;
#define MYSQL_MIN_MAJOR 5
#define MYSQL_MIN_MINOR 1
DbConfigMysql::DbConfigMysql()
: mDatabaseProcess( 0 )
{
......@@ -322,6 +325,33 @@ void DbConfigMysql::startInternalServer()
QProcess::execute( mMysqlCheckPath, arguments );
}
// Verify MySQL version
{
QSqlQuery query( db );
if ( !query.exec( QString::fromLatin1( "SELECT VERSION()") ) || !query.first() ) {
akError() << "Failed to verify database server version";
akError() << "Query error:" << query.lastError().text();
akFatal() << "Database error:" << db.lastError().text();
}
const QString version = query.value( 0 ).toString();
const QStringList versions = version.split( QLatin1Char( '.' ), QString::SkipEmptyParts );
if ( versions.count() < 3 ) {
akFatal() << "Invalid database server version: " << version;
}
if ( versions[0].toInt() < MYSQL_MIN_MAJOR || ( versions[0].toInt() == MYSQL_MIN_MAJOR && versions[1].toInt() < MYSQL_MIN_MINOR ) ) {
akError() << "Unsupported MySQL version:";
akError() << "Current version:" << QString::fromLatin1( "%1.%2" ).arg( versions[0], versions[1] );
akError() << "Minimum required version:" << QString::fromLatin1( "%1.%2" ).arg( MYSQL_MIN_MAJOR ).arg( MYSQL_MIN_MINOR );
akFatal() << "Please update your MySQL database server";
} else {
akDebug() << "MySQL version OK"
<< "(required" << QString::fromLatin1( "%1.%2" ).arg( MYSQL_MIN_MAJOR ).arg( MYSQL_MIN_MINOR )
<< ", available" << QString::fromLatin1( "%1.%2" ).arg( versions[0], versions[1] ) << ")";
}
}
{
QSqlQuery query( db );
if ( !query.exec( QString::fromLatin1( "USE %1" ).arg( mDatabaseName ) ) ) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment