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

Handle errors and data truncation in QMYSQLResult::fetchNext()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 4.6.1
    • 4.5.3
    • SQL Support
    • None
    • 1ce247ec7c2b4bda79cedf5dda2e6b1f636903b1

    Description

      The QMYSQLResult::fetchNext() function does not report errors and data truncation that occur when iterating over results from prepared statements (when using mysql_stmt_fetch() - http://dev.mysql.com/doc/refman/5.0/en/mysql-stmt-fetch.html ).

      The attached patch, qt-4.5-handle_errors_and_data_truncation_in_fetchNext.patch , simply adds a code block that checks for errors and data truncation and sets lastError appropriately, as does the existing code block in QMYSQLResult::fetch().

      The attached test application, test_qt_data_truncation.cpp , creates a temporary table using TINYINT(1) and sets values such that one in the middle will result in MYSQL_DATA_TRUNCATED when QSqlQuery::next() is called to access that row after a SELECT. Note that data truncation is only reported by MySQL/treated as an error when the query is executed using prepared statements. For Qt 4.5 and above, the Qt MySQL driver always attempts to use prepared statements, even if not requested with the QSqlQuery::prepare() function. For Qt 4.4.x and below, the non-prepared-statement (whose results are accessed with mysql_fetch_row() - http://dev.mysql.com/doc/refman/5.0/en/mysql-fetch-row.html ) will complete successfully without error, as mysql_fetch_row() does not report data truncation. Adjust the database host, database name, username, and password in the test application appropriately.

      All versions of Qt 4 that I tested (4.4.0, 4.5.0, 4.5.3) are affected (and I assume all versions of Qt4 that actually use prepared statements are affected). Qt3 is not affected (as the Qt3 MySQL driver does not actually use prepared statements).

      Attachments

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

        Activity

          People

            jasmcdon Jason McDonald (Closed Nokia Identity. Please assign to "macadder" instead) (Inactive)
            sphery Michael T. Dean
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes