Details
-
Bug
-
Resolution: Invalid
-
P4: Low
-
4.5.0
-
None
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.