MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:rburnett Date:January 5 2007 11:14pm
Subject:Connector/NET commit: r539 - in branches/1.0: . TestSuite mysqlclient
View as plain text  
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);
 			}
 		}
+
+        /// <summary>
+        /// Bug #25443 ExecuteScalar() hangs when more than one bad result 
+        /// </summary>
+        [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 @@
 		/// <include file='docs/mysqlcommand.xml' path='docs/ExecuteNonQuery/*'/>
 		public int ExecuteNonQuery()
 		{
+            lastResult = null;
 			CheckState();
 
 			if (cmdText == null ||
@@ -387,7 +388,8 @@
 		/// <include file='docs/mysqlcommand.xml' path='docs/ExecuteReader1/*'/>
 		public MySqlDataReader ExecuteReader(CommandBehavior behavior)
 		{
-			CheckState();
+            lastResult = null;
+            CheckState();
 
 			if (cmdText == null ||
 				 cmdText.Trim().Length == 0)
@@ -422,7 +424,8 @@
 		/// <include file='docs/mysqlcommand.xml' path='docs/ExecuteScalar/*'/>
 		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);

Thread
Connector/NET commit: r539 - in branches/1.0: . TestSuite mysqlclientrburnett6 Jan