wdezell
20th July 2009, 21:38
I've got a Qt/MySQL app I have to make a few changes to. The app ran fine a few weeks ago under Kubuntu 8.04 (Qt 4.3.4 & MySQL 5.0.x) and runs fine on a CentOS 5.1 box (Qt 4.3.3 and MySQL 5.0.x). However, I just took advantage of a slow period to update my development box to Fedora 11 (Qt 4.5.1 via rpm from the Fusion repos and MySQL 5.1.35) and find now that my unchanged code is broken.
I have many stanzas similar to the following for executing a constructed query:
QString SQL;
QTextStream ( &SQL ) << "USE " << dbName ( ); // yields something like "USE foo"
query.exec ( SQL );
switch ( query.lastError ( ).number ( ) )
{
case 1049: // db does not exist
...
}
Under Qt 4.5.1 I am getting MySQL Error 1295 and the following message for code that ran fine under Qt 4.3.x and MySQL 5.0.x:
"This command is not supported in the prepared statement protocol yet QMYSQL3: Unable to prepare statement"
A little searching turns up links suggesting the behavior is the result of a bug in the 4.5-series QtMySQL drivers and their design to try and execute all queries first as a PREPARED query, then fall back if it's unsupported. (ref http://www.gossamer-threads.com/lists/mythtv/users/375066 for example). Is it possible that QSqlQuery::lastError() is not being internally reset after the fallback?
Can anyone suggest how I might correct this behavior without modifying all of my code or setting up a downgraded development system? Is this a Qt problem as my reading suggests or should I be looking into MySQL 5.1.x for answers?
Advice appreciated,
Bill
I have many stanzas similar to the following for executing a constructed query:
QString SQL;
QTextStream ( &SQL ) << "USE " << dbName ( ); // yields something like "USE foo"
query.exec ( SQL );
switch ( query.lastError ( ).number ( ) )
{
case 1049: // db does not exist
...
}
Under Qt 4.5.1 I am getting MySQL Error 1295 and the following message for code that ran fine under Qt 4.3.x and MySQL 5.0.x:
"This command is not supported in the prepared statement protocol yet QMYSQL3: Unable to prepare statement"
A little searching turns up links suggesting the behavior is the result of a bug in the 4.5-series QtMySQL drivers and their design to try and execute all queries first as a PREPARED query, then fall back if it's unsupported. (ref http://www.gossamer-threads.com/lists/mythtv/users/375066 for example). Is it possible that QSqlQuery::lastError() is not being internally reset after the fallback?
Can anyone suggest how I might correct this behavior without modifying all of my code or setting up a downgraded development system? Is this a Qt problem as my reading suggests or should I be looking into MySQL 5.1.x for answers?
Advice appreciated,
Bill