Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
4.5.3
-
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).