MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:February 19 2010 3:43pm
Subject:bzr commit into connector-net-6.0 branch (reggie.burnett:795)
Bug#50123 Bug#50444
View as plain text  
#At file:///D:/bzr-connector-net/6.0/ based on revid:reggie.burnett@stripped

  795 Reggie Burnett	2010-02-19
      - fixed bug where a commands batchable command text was not getting reset when the 
        command text was reset (bug #50444)
      - fixed bug where using a currently non-batchable command in a batch would throw an exception
        (bug #50123)

    modified:
      CHANGES
      MySql.Data/Provider/Source/command.cs
      MySql.Data/Provider/Source/dataadapter.cs
      MySql.Data/Tests/Source/StoredProcedureWithAccess.cs
=== modified file 'CHANGES'
=== modified file 'CHANGES'
--- a/CHANGES	2010-02-17 21:00:48 +0000
+++ b/CHANGES	2010-02-19 15:43:40 +0000
@@ -15,6 +15,10 @@
 - fixed issue with script execution & multi-char delimiters (bug #46429)
 - fixed bug in table editor where clicking back on the last row added can sometimes
   cause a ArgumentOutOfRange exception
+- fixed bug where a commands batchable command text was not getting reset when the 
+  command text was reset (bug #50444)
+- fixed bug where using a currently non-batchable command in a batch would throw an exception
+  (bug #50123)
 
 Version 6.0.5
 - ensure that MySqlPacket always has a valid encoding. This prevents null reference exceptions in ReadString()

=== modified file 'MySql.Data/Provider/Source/command.cs'
--- a/MySql.Data/Provider/Source/command.cs	2010-02-15 20:35:58 +0000
+++ b/MySql.Data/Provider/Source/command.cs	2010-02-19 15:43:40 +0000
@@ -116,6 +116,7 @@
 			{
 				cmdText = value;
 				statement = null;
+                batchableCommandText = null;
 				if (cmdText != null && cmdText.EndsWith("DEFAULT VALUES"))
 				{
 					cmdText = cmdText.Substring(0, cmdText.Length - 14);
@@ -811,8 +812,6 @@
                         token = tokenizer.NextToken();
                     }
                 }
-                if (batchableCommandText == null)
-                    batchableCommandText = CommandText;
             }
 
             return batchableCommandText;

=== modified file 'MySql.Data/Provider/Source/dataadapter.cs'
--- a/MySql.Data/Provider/Source/dataadapter.cs	2009-08-28 15:22:37 +0000
+++ b/MySql.Data/Provider/Source/dataadapter.cs	2010-02-19 15:43:40 +0000
@@ -163,7 +163,8 @@
                 for (int index2 = index; index2 < commandBatch.Count; index2++,index++)
                 {
                     MySqlCommand cmd2 = (MySqlCommand)commandBatch[index2];
-                    if (cmd2.CommandText != cmd.CommandText) break;
+                    if (cmd2.BatchableCommandText == null || 
+                        cmd2.CommandText != cmd.CommandText) break;
                     cmd.AddToBatch(cmd2);
                 }
                 recordsAffected += cmd.ExecuteNonQuery();

=== modified file 'MySql.Data/Tests/Source/StoredProcedureWithAccess.cs'
--- a/MySql.Data/Tests/Source/StoredProcedureWithAccess.cs	2010-01-13 17:14:55 +0000
+++ b/MySql.Data/Tests/Source/StoredProcedureWithAccess.cs	2010-02-19 15:43:40 +0000
@@ -329,5 +329,67 @@
             cmd.Parameters.Add(returnParam);
             cmd.ExecuteNonQuery();
         }
+
+        /// <summary>
+        /// Bug #50123	Batch updates bug when UpdateBatchSize > 1
+        /// Bug #50444	Parameters.Clear() not working
+        /// </summary>
+        [Test]
+        public void UpdateBatchSizeMoreThanOne()
+        {
+            execSQL("DROP TABLE IF EXISTS test");
+            execSQL(@"CREATE TABLE test(fldID INT NOT NULL, 
+                fldValue VARCHAR(50) NOT NULL, PRIMARY KEY(fldID))");
+
+            MySqlDataAdapter adapter = new MySqlDataAdapter("SELECT * FROM test", conn);
+            DataTable data = new DataTable();
+            adapter.Fill(data);
+
+            MySqlCommand ins = new MySqlCommand(
+              "INSERT INTO test(fldID, fldValue) VALUES (?p1, ?p2)", conn);
+            ins.Parameters.Add("p1", MySqlDbType.Int32).SourceColumn = "fldID";
+            ins.Parameters.Add("p2", MySqlDbType.String).SourceColumn = "fldValue";
+
+            ins.UpdatedRowSource = UpdateRowSource.None;
+            adapter.InsertCommand = ins;
+            adapter.UpdateBatchSize = 10;
+
+            int numToInsert = 20;
+            for (int i = 0; i < numToInsert; i++)
+            {
+                DataRow row = data.NewRow();
+                row["fldID"] = i + 1;
+                row["fldValue"] = "ID = " + (i + 1);
+                data.Rows.Add(row);
+            }
+            Assert.AreEqual(numToInsert, adapter.Update(data));
+
+            //UPDATE VIA SP
+            MySqlCommand comm = new MySqlCommand("DROP PROCEDURE IF EXISTS pbug50123", conn);
+            comm.ExecuteNonQuery();
+            comm.CommandText = "CREATE PROCEDURE pbug50123(" +
+                "IN pfldID INT, IN pfldValue VARCHAR(50)) " +
+                "BEGIN INSERT INTO test(fldID, fldValue) " +
+                "VALUES(pfldID, pfldValue); END";
+            comm.ExecuteNonQuery();
+
+            // Set the Insert Command
+            ins.Parameters.Clear();
+            ins.CommandText = "pbug50123";
+            ins.CommandType = CommandType.StoredProcedure;
+            ins.Parameters.Add("pfldID", MySqlDbType.Int32).SourceColumn = "fldID";
+            ins.Parameters.Add("pfldValue", MySqlDbType.String).SourceColumn = "fldValue";
+            ins.UpdatedRowSource = UpdateRowSource.None;
+
+            for (int i = 21; i < 41; i++)
+            {
+                DataRow row = data.NewRow();
+                row["fldID"] = i + 1;
+                row["fldValue"] = "ID = " + (i + 1);
+                data.Rows.Add(row);
+            }
+            // Do the update
+            Assert.AreEqual(numToInsert, adapter.Update(data));
+        }
     }
 }


Attachment: [text/bzr-bundle] bzr/reggie.burnett@sun.com-20100219154340-5qtpgowzkao3ozyn.bundle
Thread
bzr commit into connector-net-6.0 branch (reggie.burnett:795)Bug#50123 Bug#50444Reggie Burnett19 Feb