Bug 132114 - mysql 5.0.24: Commands out of sync
Summary: mysql 5.0.24: Commands out of sync
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Slackware Linux
: NOR normal
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-09 08:39 UTC by richlv
Modified: 2006-08-18 14:42 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
console output (207.27 KB, application/bzip2)
2006-08-09 08:44 UTC, richlv
Details

Note You need to log in before you can comment on or make changes to this bug.
Description richlv 2006-08-09 08:39:40 UTC
Version:           svn 570614 (using KDE KDE 3.5.4)
Installed from:    Slackware Packages
OS:                Linux

trying to run amarok with mysql 5.0.24 results in error for each sql query :
[CollectionDB] MYSQL QUERY FAILED: Commands out of sync; you can't run this command now

this happens both with an old db & a completely clean db.
the same revision works just fine with mysql 5.0.22
could be a problem/change in mysql, of course :)

full console output of an amarok session (starts up, starts collection rescan, i notice console output & gracefully clos it ;) ) is attached.
Comment 1 richlv 2006-08-09 08:44:13 UTC
Created attachment 17301 [details]
console output

was too large, had to compress it :)
Comment 2 richlv 2006-08-09 08:46:04 UTC
Comment on attachment 17301 [details]
console output

err. i hope this is the correct mimetype
Comment 3 David Li 2006-08-10 23:11:11 UTC
I can confirm this
Comment 4 Damir Perisa 2006-08-12 18:15:28 UTC
archlinux users confirm this too:

http://bugs.archlinux.org/task/5205
Comment 5 Jeff Mitchell 2006-08-12 19:54:11 UTC
From the MySQL docs it seems this error condition has been present since 5.0.  Since only people running 5.0.24 seem to have this problem, and downgrading fixes it, I'm less inclined to believe it's an error in the code than a regression in MySQL.  However, from my message about this bug to the mailing list:

Looking at the CollectionDB code for query (MySqlConnection::query), if 
mysql_use_result is successful, mysql_free_result will always be called.  I 
would guess that it does not have to be called if mysql_use_result is 
unsuccessful, but if I'm wrong about that it could be the source of your 
issue if you are having failed queries (in which case the problem is really 
figuring out why you had a failed query in the first place).

There's a relevant entry here:
http://mysql.com/doc/refman/5.0/en/commands-out-of-sync.html
that would suggest that our code should be fine, other than the possible condition I mentioned above.
Comment 6 Jeff Mitchell 2006-08-16 18:35:18 UTC
if someone is running SVN, please try this:

in collectiondb.cpp, look for MySqlConnection::query

in that function, look for the following

       else
        {
            if ( mysql_field_count( m_db ) != 0 )
            {
                debug() << "MYSQL QUERY FAILED: " << mysql_error( m_db ) << "\n" << "FAILED QUERY: " << statement << "\n";
                values = QStringList();
            }
        }

and change it to:

       else
        {
            if ( mysql_field_count( m_db ) != 0 )
            {
                debug() << "MYSQL QUERY FAILED: " << mysql_error( m_db ) << "\n" << "FAILED QUERY: " << statement << "\n";
                values = QStringList();
            }
            mysql_free_result( result );
        }

Let me know if it works.
Comment 7 richlv 2006-08-18 11:17:47 UTC
sorry for the long delay, i had no access to the mysql5 machine.
it seems that this change indeed helps - i have revision 574108 with the change using 5.0.24 without "out of sync" errors.
Comment 8 Jeff Mitchell 2006-08-18 14:42:23 UTC
SVN commit 574217 by mitchell:

MySQL apparently changed their semantics for 5.0.23+ and require mysql_free_result to be called even if a mysql_use_result is not performed.
This fixes the problem in the bug, and still works fine for me with MySQL 4.

BUG:132114



 M  +1 -0      ChangeLog  
 M  +1 -1      src/collectiondb.cpp  


--- trunk/extragear/multimedia/amarok/ChangeLog #574216:574217
@@ -83,6 +83,7 @@
       since the last time it was enabled.
 
   BUGFIXES:
+    * Handle changed semantics of MySQL 5.0.23+ (BR 132114)
     * Do not try to detach() KURLs, as this would not work for non-ascii urls.
       (BR 132355)
     * Adding songs while at end of playlist could crash in dynamic mode.
--- trunk/extragear/multimedia/amarok/src/collectiondb.cpp #574216:574217
@@ -6006,7 +6006,6 @@
                   values << QString::fromUtf8( (const char*)row[i] );
                 }
             }
-            mysql_free_result( result );
         }
         else
         {
@@ -6016,6 +6015,7 @@
                 values = QStringList();
             }
         }
+        mysql_free_result( result );
     }
     else
     {