Bug #9992 mysql_next_result hangs on error
Submitted: 19 Apr 2005 8:11 Modified: 31 May 2005 2:27
Reporter: MySQL-Front Team Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.4-beta OS:Windows (Windows XP)
Assigned to: Sergei Glukhov CPU Architecture:Any

[19 Apr 2005 8:11] MySQL-Front Team
Description:
While executing the following queries mysql_next_result hangs:

SHOW TABLES;
SHOW DATABASE;
SELECT 1;

I think this problem based on the invalid second query (there is a missing "s" after DATABASE).

I'm using the multi query support for this problem. So I've sent all queries at once to the database.

Database version: 5.0.4-beta.

How to repeat:
SHOW TABLES;
SHOW DATABASE;
SELECT 1;
[19 Apr 2005 13:01] MySQL-Front Team
After a downgrade of the server to 5.0.3-beta it works fine.

So this bug based not on the libMySQL.dll - it based on the server!
[19 Apr 2005 16:25] MySQL Verification Team
The wrong syntax of the 2nd query does the application to hang:

#include <stdio.h>
#include <string.h>
#include <my_global.h>
#include <m_ctype.h>
#include <m_string.h>
#include <mysql.h>

void main()
{
 
  MYSQL *MySQL;
  MYSQL_RES	* res ;
  
    
   if ( (MySQL = mysql_init((MYSQL*) 0)) && 
        mysql_real_connect( MySQL,"localhost","root",
                           "",	"mysql",	0, NULL, CLIENT_MULTI_STATEMENTS ))
      printf("Connected with the Server: %s\n", mysql_get_server_info(MySQL));
  else
  {
    printf("Failed to connect with the server\n");
    mysql_close( MySQL );
    return;
  }
  mysql_query(MySQL,"SHOW TABLES;SHOW DATABASE;SELECT 1;");
  
  do
  {
  
    if (!(res= mysql_store_result(MySQL)))
    {
      printf("Got fatal error processing query\n");
      mysql_close( MySQL );
      return;
    }
    mysql_free_result( res ) ;
  
  } while (!mysql_next_result(MySQL));
  
  mysql_close( MySQL );
 
}
[20 Apr 2005 9:35] MySQL-Front Team
We tried to debug this problem...

The server is supposed to send the result as such:
- result set
- flags showing more results (SERVER_MORE_RESULTS_EXISTS)
- result set
- flags showing more results (SERVER_MORE_RESULTS_EXISTS)
....
- result set
- flags showing NO more results.

In the case of 5.0.4 it seems the server does not send the flag showing no more results (the multi-query stops the execution on first error).

The 3 queries case, the server should send the no more results flag after the second query, but it doesn't.

Because of this the client hang waiting for next result...

I hope this helps you fixing this bug a.s.a.p. since each client program with the multi query support has to deactivate the multi query support by the version information of the server while this bug is present.
[27 May 2005 13:04] Sergei Glukhov
Fixed in 5.0.7
[27 May 2005 17:57] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/25302
[27 May 2005 17:58] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/25304
[31 May 2005 2:27] Paul DuBois
Noted in 5.0.7 changelog.
[19 Jun 2005 13:32] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/26156