Bug #57092 Row-By-Row-Update: only first row updated
Submitted: 29 Sep 2010 9:57 Modified: 13 Oct 2010 10:07
Reporter: Uwe Beierlein Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.3.4.0 OS:Windows
Assigned to: Vladislav Vaintroub CPU Architecture:Any
Tags: AcceptChanges

[29 Sep 2010 9:57] Uwe Beierlein
Description:
When doing a row-by-row update, only the first row is updated
all other rows are ignored.

The root cause of that problem is, that all changes of the whole
table get accepted during an update of the first row in
dataadapter.cs (Line 199 in version 6.3.4), method Update(DataRow[].

How to repeat:
foreach (TestRow row_test in m_dt_test)
{
  m_del_Progress(1);
  try
  {
    m_ds_MySQL.m_ta_ediu.Update(row_ediu);
  }
  catch(Exception e)
  {
    ...
  }
}

Suggested fix:
Just accept the changes of the updated row, if required.
[5 Oct 2010 19:38] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/120034

839 Vladislav Vaintroub	2010-10-05
      Bug #57092 Row-By-Row-Update: only first row updated.
      
      The problem here is that after fix for Bug#54863, AcceptChanges 
      were called for the full Table,not for the individual row, so in a 
      row-by-row Update() modifications after the first one are lost.
      
      Fixed by calling AcceptChanges for each individual row. 
      
      It is a question whether we still need to the workaround for original
       bug#54863 and do AcceptChanges(), because it looks like the underlying
      bug in .NET was fixed  in a recent update, and Bug#54863 is no more 
      reproducible  even if we remove  AcceptChanges()  from  
      MySqlDataAdapter.Update() entirely.
      
      That is, DbDataAdapter.Update() does AcceptChanges() itself  for every row
      just like it is documented. (tried in .NET 2.0, 3.0, 3.5 and 4.0)
[7 Oct 2010 14:33] Uwe Beierlein
Hello,

it looks like the variable 

"Dictionary<DataTable, bool> modifiedTables = new Dictionary<DataTable, bool>();"

is unused/obsolete now. Please remove it. I've tested the solution
in my environment and it looks good. Please go ahead and merge/push 
it to the relevant source trees.

THANK YOU!
[7 Oct 2010 20:59] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/120300

839 Vladislav Vaintroub	2010-10-07
      Bug #57092 Row-By-Row-Update: only first row updated.
      
      The problem here is that after fix for Bug#54863, AcceptChanges 
      were called for the full Table,not for the individual row, so in a 
      row-by-row Update() modifications after the first one are lost.
      
      Fixed by calling AcceptChanges for each individual row. 
      
      It is a question whether we still need to the workaround for original
       bug#54863 and do AcceptChanges(), because it looks like the underlying
      bug in .NET was fixed  in a recent update, and Bug#54863 is no more 
      reproducible  even if we remove  AcceptChanges()  from  
      MySqlDataAdapter.Update() entirely.
      
      That is, DbDataAdapter.Update() does AcceptChanges() itself  for every row
      just like it is documented. (tried in .NET 2.0, 3.0, 3.5 and 4.0)
[7 Oct 2010 21:02] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/120301

839 Vladislav Vaintroub	2010-10-07
      Bug #57092 Row-By-Row-Update: only first row updated.
      
      The problem here is that after fix for Bug#54863, AcceptChanges 
      were called for the full Table,not for the individual row, so in a 
      row-by-row Update() modifications after the first one are lost.
      
      Fixed by calling AcceptChanges for each individual row. 
      
      It is a question whether we still need to the workaround for original
       bug#54863 and do AcceptChanges(), because it looks like the underlying
      bug in .NET was fixed  in a recent update, and Bug#54863 is no more 
      reproducible  even if we remove  AcceptChanges()  from  
      MySqlDataAdapter.Update() entirely.
      
      That is, DbDataAdapter.Update() does AcceptChanges() itself  for every row
      just like it is documented. (tried in .NET 2.0, 3.0, 3.5 and 4.0)
[7 Oct 2010 22:06] Vladislav Vaintroub
queued in 6.0, 6.1, 6.2, 6.3, trunk

Uwe, thanks for spotting unused variable, I removed it now.
[13 Oct 2010 10:07] Tony Bedford
An entry has been added to the 6.0.8, 6.1.6, 6.2.5, and 6.3.5 changelogs:

When performing a row-by-row update, only the first row was updated and all other rows were ignored.