Bug #9992 mysql_next_result hangs on error
Submitted: 19 Apr 2005 10:11 Modified: 31 May 2005 4:27
Reporter: MySQL-Front Team
Status: Closed
Category:Server Severity:S1 (Critical)
Version:5.0.4-beta OS:Microsoft Windows (Windows XP)
Assigned to: Sergey Gluhov Target Version:

[19 Apr 2005 10: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 15: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 18:25] Miguel Solorzano
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 11: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 15:04] Sergey Gluhov
Fixed in 5.0.7
[27 May 2005 19: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 19: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 4:27] Paul DuBois
Noted in 5.0.7 changelog.
[19 Jun 2005 15: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