Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. plugin for MySQL builded, but db.driver()->hasFeature( QSqlDriver::Transactions ) return false
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
3 Posts 2 Posters 397 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    denys
    wrote on last edited by
    #1

    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;
    }
    
    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      D 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        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?

        D Offline
        D Offline
        denys
        wrote on last edited by
        #3

        @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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved