Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-3753

Fix prepared statement test in QMYSQLResult::reset()

    XMLWordPrintable

Details

    Description

      The "test" in QMYSQLResult::reset() for whether prepared statements are available and usable ( src/sql/drivers/mysql/qsql_mysql.cpp +645 ):

      if(d->d->preparedQuerysEnabled && prepare(query))

      may result in a lastError being set when prepare(query) is called--specifically, in the event query is a MySQL statement which cannot be executed through prepared statements ( http://dev.mysql.com/doc/refman/5.0/en/c-api-prepared-statements.html ). For applications that do not rely on the result of QSqlQuery::exec() but check QSqlQuery::lastError(), instead, this causes them to think an error occurred even though the statement (eventually) executed properly.

      I expected to see the lastError should be reset after the driver attempts to use a prepared query--especially when the application did not request the use of prepared statements.

      I am attaching a patch that resets lastError as well as a test application that shows the bug.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            bilking Bill King
            janichol Andy Nichols
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes