Bug #25443 ExecuteScalar() hangs when more than one bad result
Submitted: 5 Jan 2007 22:05 Modified: 9 Jan 2007 16:08
Reporter: Karl Seguin
Status: Closed
Category:Connector/Net Severity:S2 (Serious)
Version:5.0.3 OS:
Assigned to: Target Version:
Tags: net connector

[5 Jan 2007 22:05] Karl Seguin
Description:
Calling ExecuteScalar with 2+ commands, one of them failing, hangs the process.

something like:

SELECT 1; 
SELECT * FROM DoesNotExist;

was originally found in an sproc, but works with text commands.

It specifically hangs on MySqlStream.LoadPacket(), at int b1 = inStream.ReadByte();

dr.Close() is called, which throws an exception (because of the error in the 2nd result),
which calls dr.Close() again, which hangs because there are (for some unknown reason to
me) still results.

How to repeat:
The following code reproduces the bug every time:

using (MySqlConnection connection = new MySqlConnection(_connectionString))
{
   using (MySqlCommand command = new MySqlCommand())
   {
      command.Connection = connection;
      command.CommandText = "	SELECT 1;SELECT * FROM DoesNotExist";
      command.CommandType = CommandType.Text;
      connection.Open();               
      command.ExecuteScalar();
   }
}
Console.WriteLine("This never executes");
Console.ReadLine();

replace _connectionString with a real connection string - no other steps are required.

Suggested fix:
none.
[5 Jan 2007 23:59] 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/commits/17688
[6 Jan 2007 0:14] 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/commits/17690
[6 Jan 2007 0:14] Reggie Burnett
Fixed in 5.0.4 and 1.0.9
[9 Jan 2007 16:08] MC Brown
A note has been added to the 5.0.4 and 1.0.9 changelogs.