Important: Please read the Qt Code of Conduct -

plugin for MySQL builded, but db.driver()->hasFeature( QSqlDriver::Transactions ) return false

  • OS: Windows 10, Build settings MinGW32
    QT version 5.14.0
    under QT 5.13.0 and 5.13.2 all work fine. I have no problems with transactions. But on QT 5.14.0, code like this interrupt with message "Error - driver not allow transactions ". hasFeature( QSqlDriver::Transactions ) return false, and if we check db table sys_variables for row with sv_name = 'rollback_test' - in the field sv_value_str - we will found value 'rollback failed', though rollback have been called.
    Is it feature of QT 5.14, or there is the way to use transactions with MySQL plugin?

    db = QSqlDatabase::addDatabase( "MYSQL3", "db");
    db.setHostName( "host");
    db.setPort( 3306 );
    db.setDatabaseName( "mydb" );
    db.setUserName( "user" );
    db.setPassword( "password" );
    addMessage(QString("Error connect to DB ") + dbTemplate.lastError().text());
                    return false;
    if( !db.driver()->hasFeature( QSqlDriver::Transactions ) )
                    addMessage(QString("Error - driver not allow transactions ") );
                    db.exec("update sys_variables set sv_value_str = 'rollback failed' where sv_name = 'rollback_test'");
                    return false;

  • Lifetime Qt Champion

    If the server supports transactions is checked with this flag:

    See - maybe you should add a breakpoint there and see what happens.
    How did you build your mysql plugin?

  • @Christian-Ehrlicher
    Thank you for answer.
    I've build it same way as i build this plugin for qt 5.13.0 and 5.13.2
    I've used same mysql libs , but transaction is worked good for qt 5.13 and don't work for qt 5.14

    Building plugin :
    \Qt\5.1X.X\mingw73_32\mkspecs\qmodule.pri - write correct paths for MySQL libs and includes. I using client API libmysql version 6.1.11 - i can't find 32 bit libmysql 8.X
    cd \Qt\5.XX.X\Src\qtbase\src\plugins\sqldrivers\mysql
    cd mysql
    cd ..
    mingw32-make install

Log in to reply