From: Date: January 6 2007 12:14am Subject: Connector/NET commit: r539 - in branches/1.0: . TestSuite mysqlclient List-Archive: http://lists.mysql.com/commits/17690 X-Bug: 25443 Message-Id: <200701052314.l05NED8d008542@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified: branches/1.0/CHANGES branches/1.0/TestSuite/CommandTests.cs branches/1.0/mysqlclient/command.cs Log: Bug #25443 ExecuteScalar() hangs when more than one bad result This bug was caused by MySqlCommand.lastResult not being set to null when a previous command throws an exception. We fix this by clearing lastResult at the start of all the execute methods. Modified: branches/1.0/CHANGES =================================================================== --- branches/1.0/CHANGES 2007-01-05 22:58:59 UTC (rev 538) +++ branches/1.0/CHANGES 2007-01-05 23:14:12 UTC (rev 539) @@ -17,7 +17,8 @@ information schema.] Bug #25013 Return Value parameter not found Bug #22400 Nested transactions - + Bug #25443 ExecuteScalar() hangs when more than one bad result + Other changes ------------- Turned MySqlPoolManager into a static class and added a static ctor to Modified: branches/1.0/TestSuite/CommandTests.cs =================================================================== --- branches/1.0/TestSuite/CommandTests.cs 2007-01-05 22:58:59 UTC (rev 538) +++ branches/1.0/TestSuite/CommandTests.cs 2007-01-05 23:14:12 UTC (rev 539) @@ -382,6 +382,39 @@ Assert.Fail(ex.Message); } } + + /// + /// Bug #25443 ExecuteScalar() hangs when more than one bad result + /// + [Test] + public void ExecuteWithOneBadQuery() + { + MySqlCommand command = new MySqlCommand("SELECT 1; SELECT * FROM foo", conn); + try + { + command.ExecuteScalar(); + } + catch (MySqlException) + { + } + catch (Exception ex) + { + Assert.Fail(ex.Message); + } + + // now try using ExecuteNonQuery + try + { + command.ExecuteNonQuery(); + } + catch (MySqlException) + { + } + catch (Exception ex) + { + Assert.Fail(ex.Message); + } + } } Modified: branches/1.0/mysqlclient/command.cs =================================================================== --- branches/1.0/mysqlclient/command.cs 2007-01-05 22:58:59 UTC (rev 538) +++ branches/1.0/mysqlclient/command.cs 2007-01-05 23:14:12 UTC (rev 539) @@ -341,6 +341,7 @@ /// public int ExecuteNonQuery() { + lastResult = null; CheckState(); if (cmdText == null || @@ -387,7 +388,8 @@ /// public MySqlDataReader ExecuteReader(CommandBehavior behavior) { - CheckState(); + lastResult = null; + CheckState(); if (cmdText == null || cmdText.Trim().Length == 0) @@ -422,7 +424,8 @@ /// public object ExecuteScalar() { - // ExecuteReader will check out state + lastResult = null; + // ExecuteReader will check out state if (cmdText == null || cmdText.Trim().Length == 0) throw new InvalidOperationException(Resources.CommandTextNotInitialized);