Bug #25443 ExecuteScalar() hangs when more than one bad result
Submitted: 5 Jan 2007 21:05 Modified: 9 Jan 2007 15:08
Reporter: Karl Seguin Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:5.0.3 OS:
Assigned to:
Tags: net connector

[5 Jan 2007 21: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 22: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
[5 Jan 2007 23: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
[5 Jan 2007 23:14] Reggie Burnett
Fixed in 5.0.4 and 1.0.9
[9 Jan 2007 15:08] MC Brown
A note has been added to the 5.0.4 and 1.0.9 changelogs.