Bug #58652 | ExecuteReader throws NullReferenceException when using CommandBehavior.Close | ||
---|---|---|---|
Submitted: | 2 Dec 2010 10:32 | Modified: | 7 Jan 2011 15:39 |
Reporter: | Jaco Erasmus | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / NET | Severity: | S2 (Serious) |
Version: | 6.3.5 | OS: | Windows |
Assigned to: | Reggie Burnett | CPU Architecture: | Any |
Tags: | CommandBehavior, ExecuteReader, MySqlCommand, NullReferenceException |
[2 Dec 2010 10:32]
Jaco Erasmus
[3 Dec 2010 17:05]
Tonci Grgin
Hi Jaco and thanks for your report. Verified just as described with following test case: string s = "Server=opensol;Database=mysql;Uid=**;pwd=**;logging=true"; using (MySqlConnection conn = new MySqlConnection(s)) { conn.Open(); // Select invalid column string sql = "SELECT User, Host, Pswrd FROM user"; using (MySqlCommand cmd = new MySqlCommand(sql, conn)) { using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { Assert.AreEqual(0, reader.RecordsAffected); } } } Problem is in command.cs, right about line 469 where this case is not handled and later on original exception gets overwritten with new one.
[14 Dec 2010 15:28]
Reggie Burnett
Fixed in 6.0.8, 6.1.6, 6.2.5, 6.3.6+
[7 Jan 2011 15:39]
Tony Bedford
An entry has been added to the 6.0.8, 6.1.6, 6.2.5, 6.3.6 changelogs: MySqlCommand.ExecuteReader(CommandBehavior) threw a NullReferenceException when being called with CommandBehavior.CloseConnection, if the SQL statement contained a syntax error, or contained invalid data such as an invalid column name.