Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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" );
    if(!db.open())
    {
    addMessage(QString("Error connect to DB ") + dbTemplate.lastError().text());
                    addMessage(QSqlDatabase::drivers().join(","));
                    return false;
    }
    if( !db.driver()->hasFeature( QSqlDriver::Transactions ) )
    {
                    addMessage(QString("Error - driver not allow transactions ") );
                    db.transaction();
                    db.exec("update sys_variables set sv_value_str = 'rollback failed' where sv_name = 'rollback_test'");
                    db.rollback();
                    return false;
    }
    

  • Lifetime Qt Champion

    If the server supports transactions is checked with this flag: https://dev.mysql.com/doc/dev/mysql-server/latest/group__group__cs__capabilities__flags.html#ga536a91524dc8d56bcac63aadc8811f1d

    See https://code.woboq.org/qt5/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp.html#1252 - 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
    qmake
    cd mysql
    qmake
    cd ..
    mingw32-make
    mingw32-make install


Log in to reply