Bug #57501 MySql Connector/NET 6.3.5.0 fails to read from DataReader

Submitted: 16 Oct 2010 21:34 Modified: 2 Dec 2010 13:43
Reporter: Robert Hollencamp Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:6.3.5 OS:Any
Assigned to: Vladislav Vaintroub CPU Architecture:Any

[16 Oct 2010 21:34] Robert Hollencamp
Description:
Calling read on a DataReader obtained from MySqlHelper.ExecuteReader will always fail with a MySqlException:

Unhandled Exception: MySql.Data.MySqlClient.MySqlException: Invalid attempt to R
ead when reader is closed.
   at MySql.Data.MySqlClient.MySqlDataReader.Read()
   at MySqlTest.MainClass.Main(String[] args) in c:\Users\Robert Hollencamp\Docu
ments\Projects\MySqlTest\Main.cs:line 13

This fails on both Win32/Named Pipe and Linux/Socket. Reverting to 6.3.4 works fine.

How to repeat:
using System;
using MySql.Data.MySqlClient;

namespace MySqlTest
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			string connStr = "Protocol=pipe; Database=ajb-dev; User ID=ajb-dev; Password=[REDACTED]";
			//Server=127.0.0.1; Database=ajb; User ID=ajb-live; Password=[REDACTED];
			using (MySqlDataReader reader = MySqlHelper.ExecuteReader(connStr, "SHOW TABLES"))
			{
				while (reader.Read())
				{
					Console.WriteLine(reader.GetString(0));
				}
			}
		}
	}
}
[22 Oct 2010 19:24] Reggie Burnett
Not enough information was provided for us to be able to handle this bug. Please re-read the instructions at http://bugs.mysql.com/how-to-report.php

If you can provide more information, feel free to add it to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.
[23 Oct 2010 14:16] Holger Mueller
Not enough information? 
But I can simply reproduce this bug with the code provided by Robert. At least in my environment (Win7 x64, German, mysql 5.5.6, myisam tables) any use of the read()-function in datareader fails like this, no matter what table/data..
So, what more information could one provide? Simply switching back to 6.3.4 resolves the problem..
[2 Nov 2010 8:14] Mikhail Aleinik
This is the same issue in #57874

And I can also confirm that using MySqlHelper.ExecuteReader() with connection string causes 'Invalid attempt to Read when reader is closed' exception.

Environment: Win7 x32, VS 2008, MySql Connector/NET 6.3.5.0

This bug is really critical because MySqlHelper.ExecuteReader() method is widely used in my project.
[2 Nov 2010 14:32] Tonci Grgin
Verified as described.

Win7x64Ultimate, VS2010Premium, clean install of c/NET 6.3.5 msi (full), .NET FW 2 and 4. Pipe or no pipe reader is not opened thus exception.
[2 Nov 2010 14:33] Tonci Grgin
Bug#57874 was marked as duplicate of this report.
[4 Nov 2010 17:29] Valeriy Kravchuk
Bug #57987 was marked as a duplicate of this one.
[30 Nov 2010 18:45] 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/125552

949 Reggie Burnett	2010-11-30
      - fixed MySqlHelper.ExecuteReader bug where it was opening the connection inside a using block
        which was closing the connection before we were really done with it (bug #57501)
[30 Nov 2010 18:46] Reggie Burnett
fixed in 6.3.6+
[2 Dec 2010 13:43] Tony Bedford
An entry has been added to the 6.3.6 changelog:

Calling the Read() method on a DataReader obtained from MySqlHelper.ExecuteReader generated the following exception:

Unhandled Exception: MySql.Data.MySqlClient.MySqlException: Invalid attempt to R
ead when reader is closed.
   at MySql.Data.MySqlClient.MySqlDataReader.Read()
   at MySqlTest.MainClass.Main(String[] args)

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.043 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.