Results 1 to 2 of 2

Thread: Qt 4.5.1 / MySQL 5.1, QSqlQuery::lastError() 1295

  1. #1
    Join Date
    Mar 2009
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Qt 4.5.1 / MySQL 5.1, QSqlQuery::lastError() 1295

    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:

    Qt Code:
    1. QString SQL;
    2.  
    3. QTextStream ( &SQL ) << "USE " << dbName ( ); // yields something like "USE foo"
    4. query.exec ( SQL );
    5.  
    6. switch ( query.lastError ( ).number ( ) )
    7. {
    8. case 1049: // db does not exist
    9. ...
    10. }
    To copy to clipboard, switch view to plain text mode 

    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/list...v/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

  2. #2
    Join Date
    Mar 2009
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt 4.5.1 / MySQL 5.1, QSqlQuery::lastError() 1295

    Update:

    The Qt 4.5.1 MySQL driver as packaged with Fedora 11 is broken.

    I downloaded the Qt 4.4.3 source tarball and built from source (using the ./configure options below) and the same code which worked fine with Qt 4.3.3/4 but failed under Qt. 4.5.1 worked fine once more. It would appear that the changes in the Qt 4.5 QtMySQL driver (to first attempt to execute all queries as PREPARED queries) do not correctly fall back to conventional mode, or perhaps do but fail to clear the initially-encountered error code. Either way, the solution for now for me is to build using the Qt 4.4.3 source distribution.

    Qt Code:
    1. ./configure -debug -shared -no-fast -largefile -exceptions -accessibility -stl \
    2. -qt-sql-mysql -system-sqlite -qt3support -xmlpatterns \
    3. -phonon-backend -svg -webkit -assistant-webkit -system-zlib -qt-gif \
    4. -system-libtiff -system-libpng -system-libmng -system-libjpeg -openssl -optimized-qmake \
    5. -nis -pch -dbus -opengl -sm -xshape -xinerama -xcursor \
    6. -xfixes -xrandr -xrender -fontconfig -tablet -xkb -glib
    To copy to clipboard, switch view to plain text mode 


    (Note: When I have time I will grab a source distribution of Qt 4.5.1 and test against it to verify that it's not somehow a Fedora 11 packaging issue).

Similar Threads

  1. QT 4.5 QMYSQL and Mysql 4.1 servers does not work
    By elektritter in forum Qt Programming
    Replies: 1
    Last Post: 21st July 2009, 15:53
  2. Accessing xampp mysql database
    By synack in forum Newbie
    Replies: 8
    Last Post: 19th March 2009, 09:08
  3. mysql configuration with qt
    By bala in forum Installation and Deployment
    Replies: 3
    Last Post: 6th November 2007, 11:02
  4. MySQL starting problem
    By shamik in forum General Discussion
    Replies: 5
    Last Post: 25th April 2007, 07:20
  5. Qt 4.1.4 & Mysql 5 on Linux x64
    By bothapn in forum Installation and Deployment
    Replies: 7
    Last Post: 4th August 2006, 13:23

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.