MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:rburnett Date:October 20 2008 8:48pm
Subject:Connector/NET commit: r1440 - in branches/5.2: . MySql.Data/Provider/Source MySql.Data/Tests/Source
View as plain text  
Modified:
   branches/5.2/CHANGES
   branches/5.2/MySql.Data/Provider/Source/command.cs
   branches/5.2/MySql.Data/Tests/Source/TimeoutAndCancel.cs
Log:
- fixed problem that caused in use connection strings to be modified when a pooled connection timed out and was cancelled.  (bug #40091)  

The problem was that we were creating our connection object before setting the pooling property to false.  This caused a connection to be made in an existing connection string cache which caused all the connection strings in that cache to change when we set our pooling property.  The fix was to create a connection string builder object, set the pooling property, and then create the connection object.


Modified: branches/5.2/CHANGES
===================================================================
--- branches/5.2/CHANGES	2008-10-20 19:28:41 UTC (rev 1439)
+++ branches/5.2/CHANGES	2008-10-20 20:48:01 UTC (rev 1440)
@@ -24,6 +24,8 @@
 - fixed bug where specifying 'functions return string=yes' would cause strings to be returned
   using the 'binary' charset which would not properly render some characters.  Now the 
   connection character set is used. (bug #40076)  
+- fixed problem that caused in use connection strings to be modified when a pooled connection
+  timed out and was cancelled.  (bug #40091)
   
   
 Version 5.2.3 - 8/14/08

Modified: branches/5.2/MySql.Data/Provider/Source/command.cs
===================================================================
--- branches/5.2/MySql.Data/Provider/Source/command.cs	2008-10-20 19:28:41 UTC (rev 1439)
+++ branches/5.2/MySql.Data/Provider/Source/command.cs	2008-10-20 20:48:01 UTC (rev 1440)
@@ -254,9 +254,11 @@
 			if (!connection.driver.Version.isAtLeast(5, 0, 0))
 				throw new NotSupportedException(Resources.CancelNotSupported);
 
-			using(MySqlConnection c = new MySqlConnection(connection.Settings.GetConnectionString(true)))
+            MySqlConnectionStringBuilder cb = new MySqlConnectionStringBuilder(
+                connection.Settings.GetConnectionString(true));
+            cb.Pooling = false;
+			using(MySqlConnection c = new MySqlConnection(cb.ConnectionString))
 			{
-                c.Settings.Pooling = false;
                 c.Open();
                 MySqlCommand cmd = new MySqlCommand(String.Format("KILL QUERY {0}",
                      connection.ServerThread), c);

Modified: branches/5.2/MySql.Data/Tests/Source/TimeoutAndCancel.cs
===================================================================
--- branches/5.2/MySql.Data/Tests/Source/TimeoutAndCancel.cs	2008-10-20 19:28:41 UTC (rev 1439)
+++ branches/5.2/MySql.Data/Tests/Source/TimeoutAndCancel.cs	2008-10-20 20:48:01 UTC (rev 1440)
@@ -232,5 +232,35 @@
             }
             Assert.IsTrue(rows < 10000);
         }        
+
+        /// <summary>
+        /// Bug #40091	mysql driver 5.2.3.0 connection pooling issue
+        /// </summary>
+        [Test]
+        public void ConnectionStringModifiedAfterCancel()
+        {
+            bool isPooling = pooling;
+            pooling = true;
+            string connStr = GetConnectionString(true);
+            pooling = isPooling;
+            connStr = connStr.Replace("persist security info=true", "persist security info=false");
+
+            using (MySqlConnection c = new MySqlConnection(connStr))
+            {
+                c.Open();
+                string connStr1 = c.ConnectionString;
+
+                MySqlCommand cmd = new MySqlCommand("SELECT SLEEP(10)", c);
+                cmd.CommandTimeout = 5;
+
+                using (MySqlDataReader reader = cmd.ExecuteReader())
+                {
+                    string connStr2 = c.ConnectionString.ToLowerInvariant();
+                    Assert.AreEqual(-1, connStr2.IndexOf("pooling=true"));
+                    Assert.AreEqual(-1, connStr2.IndexOf("pooling=false"));
+                    reader.Read();
+                }
+            }
+        }
     }
 }

Thread
Connector/NET commit: r1440 - in branches/5.2: . MySql.Data/Provider/Source MySql.Data/Tests/Sourcerburnett20 Oct