List:Commits« Previous MessageNext Message »
From:Vladislav Vaintroub Date:October 7 2010 9:26pm
Subject:bzr commit into connector-net-6.2 branch (vvaintroub:900)
View as plain text  
#At file:///H:/connector_net/6.2/ based on revid:reggie.burnett@stripped

  900 Vladislav Vaintroub	2010-10-07 [merge]
      merge

    modified:
      CHANGES
      MySql.Data/Provider/Source/command.cs
      MySql.Data/Provider/Source/dataadapter.cs
      MySql.Data/Tests/Source/CommandTests.cs
      MySql.Data/Tests/Source/TimeoutAndCancel.cs
=== modified file 'CHANGES'
--- a/CHANGES	2010-09-17 16:24:05 +0000
+++ b/CHANGES	2010-10-07 21:26:37 +0000
@@ -1,4 +1,8 @@
 - Added MySqlHelper.ExecuteReader that takes an external connection and array of paramters (bug #56755)
+- Handle MySqlCommand.CommandTimeout = 0 properly (Bug #57265)
+- Do not call AcceptChanged on tables in MySqlDataAdapter.Update(),
+  but on individual rows (Bug #57092)
+
 
 Version 6.2.4
 - Fix authorization popup after modifying stored procedure in VS (Bug #44715)

=== modified file 'MySql.Data/Provider/Source/command.cs'
--- a/MySql.Data/Provider/Source/command.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data/Provider/Source/command.cs	2010-10-07 21:26:37 +0000
@@ -62,7 +62,7 @@ namespace MySql.Data.MySqlClient
         List<MySqlCommand> batch;
         private string batchableCommandText;
         CommandTimer commandTimer;
-
+        private bool useDefaultTimeout;
 
 		/// <include file='docs/mysqlcommand.xml' path='docs/ctor1/*'/>
 		public MySqlCommand()
@@ -72,6 +72,7 @@ namespace MySql.Data.MySqlClient
 			parameters = new MySqlParameterCollection(this);
 			updatedRowSource = UpdateRowSource.Both;
 			cmdText = String.Empty;
+			useDefaultTimeout = true;
 		}
 
 		/// <include file='docs/mysqlcommand.xml' path='docs/ctor2/*'/>
@@ -139,7 +140,7 @@ namespace MySql.Data.MySqlClient
 #endif
 		public override int CommandTimeout
 		{
-			get { return commandTimeout == 0 ? 30 : commandTimeout; }
+			get { return useDefaultTimeout ? 30 : commandTimeout; }
 			set 
 			{
 				if (commandTimeout < 0)
@@ -158,6 +159,7 @@ namespace MySql.Data.MySqlClient
 					+ timeout + " seconds)");
 				}
 				commandTimeout = timeout;
+				useDefaultTimeout = false;
 			}
 		}
 
@@ -202,8 +204,12 @@ namespace MySql.Data.MySqlClient
 
                 // if the user has not already set the command timeout, then
                 // take the default from the connection
-                if (connection != null && commandTimeout == 0)
+                if (connection != null && useDefaultTimeout)
+                {
                     commandTimeout = (int)connection.Settings.DefaultCommandTimeout;
+                    useDefaultTimeout = false;
+                }
+
 			}
 		}
 
@@ -485,6 +491,7 @@ namespace MySql.Data.MySqlClient
                     throw new MySqlException(ex.Message, true, ex);
                 }
 
+
                 // if we caught an exception because of a cancel, then just return null
                 if (ex.IsQueryAborted)
                     return null;

=== modified file 'MySql.Data/Provider/Source/dataadapter.cs'
--- a/MySql.Data/Provider/Source/dataadapter.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data/Provider/Source/dataadapter.cs	2010-10-07 21:26:37 +0000
@@ -167,46 +167,40 @@ namespace MySql.Data.MySqlClient
 
         protected override int Update(DataRow[] dataRows, DataTableMapping tableMapping)
         {
+
             List<MySqlConnection> connectionsOpened = new List<MySqlConnection>();
 
             try
             {
-                Dictionary<DataTable, bool> modifiedTables = new Dictionary<DataTable, bool>();
-
-                // Scan rows, lookiing for modified tables, we'll use them later 
-                // for AcceptChanges().
-                //
-                // Also open connections for insert/update/update commands, if 
+                // Open connections for insert/update/update commands, if 
                 // connections are closed.
                 foreach(DataRow row in dataRows)
                 {
                     OpenConnectionIfClosed(row.RowState, connectionsOpened);
+                }
+
+                int ret = base.Update(dataRows, tableMapping);
+
+                // Following was a workaround for Bug#54863
+                // It  a good question whether we still needed it, it seems like
+                // .NET bug (DbDataAdapter not issuing AcceptChanges() for 
+                // modified rows) has already been fixed in .NET
+                foreach (DataRow row in dataRows)
+                {
                     if (row.RowState != DataRowState.Unchanged &&
                         row.RowState != DataRowState.Detached)
                     {
-                        modifiedTables[row.Table] = true;
+                        row.AcceptChanges();
                     }
                 }
 
-                int ret = base.Update(dataRows, tableMapping);
-
-                // DbDataAdapter does automatically calls AcceptChanges on table.
-                // (even if  documentation states otherwise).
-                // Do AcceptsChanges() here, for SQL Server compatible behavior
-                // (see also Bug#5463)
-                
-                foreach (DataTable table in modifiedTables.Keys)
-                    table.AcceptChanges();
-
                 return ret;
-
             }
             finally 
             {
                 foreach(MySqlConnection c in connectionsOpened)
                     c.Close();
             }
-
         }
 
 

=== modified file 'MySql.Data/Tests/Source/CommandTests.cs'
--- a/MySql.Data/Tests/Source/CommandTests.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data/Tests/Source/CommandTests.cs	2010-10-07 21:26:37 +0000
@@ -345,6 +345,12 @@ namespace MySql.Data.MySqlClient.Tests
             cmd.CommandTimeout = 66;
             cmd.Connection = c;
             Assert.AreEqual(66, cmd.CommandTimeout);
+            cmd.CommandTimeout = 0;
+            Assert.AreEqual(0, cmd.CommandTimeout);
+
+            c = new MySqlConnection("server=localhost;default command timeout=0");
+            cmd = new MySqlCommand("", c);
+            Assert.AreEqual(0, cmd.CommandTimeout);
         }
 
         /// <summary>

=== modified file 'MySql.Data/Tests/Source/TimeoutAndCancel.cs'
--- a/MySql.Data/Tests/Source/TimeoutAndCancel.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data/Tests/Source/TimeoutAndCancel.cs	2010-10-07 21:26:37 +0000
@@ -157,6 +157,16 @@ namespace MySql.Data.MySqlClient.Tests
             cmd.ExecuteNonQuery();
         }
 
+         [Test]
+        public void TimeoutNotExpiring2()
+        {
+            if (Version < new Version(5, 0)) return;
+
+            MySqlCommand cmd = new MySqlCommand("SELECT SLEEP(1)", conn);
+            cmd.CommandTimeout = 0; // infinite timeout
+            cmd.ExecuteNonQuery();
+        }
+
         [Test]
         public void TimeoutDuringBatch()
         {


Attachment: [text/bzr-bundle] bzr/vvaintroub@mysql.com-20101007212637-8sapdrjc7ni2pd0z.bundle
Thread
bzr commit into connector-net-6.2 branch (vvaintroub:900) Vladislav Vaintroub7 Oct