From: Date: August 6 2006 12:46am Subject: Connector/NET commit: r297 - in branches/1.0: TestSuite mysqlclient List-Archive: http://lists.mysql.com/commits/10078 X-Bug: 20581 Message-Id: <200608052246.k75MkIDj014934@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified: branches/1.0/TestSuite/BaseTest.cs branches/1.0/TestSuite/MySql.Data.Tests.csproj branches/1.0/TestSuite/StoredProcedure.cs branches/1.0/mysqlclient/command.cs Log: Bug #20581 Null Reference Exception when closing reader after stored procedure. BaseTest Updated Is50 to include 5.1 MySql.Data.Tests.csproj Added app.config storedProcedure Added test case for bug 20581 command.cs Fixed problem in Command.Consume where storedProcedure would be non-null but sqlBuffers would be null and lead to a null reference. Modified: branches/1.0/TestSuite/BaseTest.cs =================================================================== --- branches/1.0/TestSuite/BaseTest.cs 2006-08-05 01:24:30 UTC (rev 296) +++ branches/1.0/TestSuite/BaseTest.cs 2006-08-05 22:46:17 UTC (rev 297) @@ -90,7 +90,11 @@ protected bool Is50 { - get { return conn.ServerVersion.StartsWith("5.0"); } + get + { + string ver = conn.ServerVersion; + return ver.StartsWith("5.0") || ver.StartsWith("5.1"); + } } protected bool Is41 Modified: branches/1.0/TestSuite/MySql.Data.Tests.csproj =================================================================== --- branches/1.0/TestSuite/MySql.Data.Tests.csproj 2006-08-05 01:24:30 UTC (rev 296) +++ branches/1.0/TestSuite/MySql.Data.Tests.csproj 2006-08-05 22:46:17 UTC (rev 297) @@ -168,6 +168,9 @@ Code + + + Modified: branches/1.0/TestSuite/StoredProcedure.cs =================================================================== --- branches/1.0/TestSuite/StoredProcedure.cs 2006-08-05 01:24:30 UTC (rev 296) +++ branches/1.0/TestSuite/StoredProcedure.cs 2006-08-05 22:46:17 UTC (rev 297) @@ -827,5 +827,37 @@ execSQL("DROP PROCEDURE IF EXISTS spTest" + x); } } + + /// + /// Bug #20581 Null Reference Exception when closing reader after stored procedure. + /// + [Test] + public void Bug20581() + { + execSQL("CREATE PROCEDURE spTest(p int) BEGIN SELECT p; END"); + MySqlParameter param1; + MySqlCommand command = new MySqlCommand("spTest", conn); + command.CommandType = System.Data.CommandType.StoredProcedure; + + param1 = command.Parameters.Add("p", MySqlDbType.Int32); + param1.Value = 3; + + MySqlDataReader reader = null; + try + { + command.Prepare(); + reader = command.ExecuteReader(CommandBehavior.SingleRow); + reader.Read(); + } + catch (Exception ex) + { + Assert.Fail(ex.Message); + } + finally + { + if (reader != null) + reader.Close(); + } + } } } Modified: branches/1.0/mysqlclient/command.cs =================================================================== --- branches/1.0/mysqlclient/command.cs 2006-08-05 01:24:30 UTC (rev 296) +++ branches/1.0/mysqlclient/command.cs 2006-08-05 22:46:17 UTC (rev 297) @@ -240,7 +240,7 @@ // if we were executing a stored procedure and we are out of sql buffers to execute, // then we need to perform some additional work to get our inout and out parameters - if (storedProcedure != null && sqlBuffers.Count == 0) + if (storedProcedure != null) storedProcedure.UpdateParameters(Parameters); }