20 messages in com.mysql.lists.dotnetRE: New bugs category for Visual Stud...
FromSent OnAttachments
Reggie Burnett25 Oct 2006 12:58 
David Dindorp26 Oct 2006 02:25 
Martin MC Brown26 Oct 2006 06:09 
David Dindorp26 Oct 2006 06:42 
Reggie Burnett26 Oct 2006 07:33 
David Dindorp26 Oct 2006 07:44 
Reggie Burnett26 Oct 2006 08:04 
David Dindorp27 Oct 2006 02:40 
Barry Zubel27 Oct 2006 02:54 
Yvan Rodrigues27 Oct 2006 07:23 
David Dindorp27 Oct 2006 08:32 
Reggie Burnett27 Oct 2006 13:54 
David Dindorp28 Oct 2006 14:26 
Reggie Burnett28 Oct 2006 17:23 
David Dindorp09 Nov 2006 05:19 
Reggie Burnett15 Nov 2006 08:02 
Chris Herridge19 Feb 2007 04:36 
Johan Steyn19 Feb 2007 04:53 
Chris Herridge19 Feb 2007 05:05 
Reggie Burnett21 Feb 2007 08:24 
Subject:RE: New bugs category for Visual Studio plugin
From:David Dindorp (dd@dubex.dk)
Date:10/27/2006 02:40:55 AM
List:com.mysql.lists.dotnet

Can you provide a test case that fails using the MySQL CLI?

Yeah. Here's an example using MySQL Server 5.0.26 on Windows.

First, we create a test table that has a floating point field. We will also add an integer PK field, just for good measurement.

================================ CREATE TABLE testcase ( Id TINYINT, DecayRate DOUBLE, PRIMARY KEY(Id) ); ================================

Now add some test data that we know triggers the issue.

================================ INSERT INTO testcase VALUES (1, 0.666666666666667); INSERT INTO testcase VALUES (2, 0.6666666666666666); ================================

We are trying to simulate for example a DOTNET DataGrid browsing these data. First it needs to present data to the user, so it does a SELECT.

================================ SELECT * FROM testcase;

+----+-------------------+ | Id | DecayRate | +----+-------------------+ | 1 | 0.666666666666667 | | 2 | 0.666666666666667 | +----+-------------------+ 2 rows in set (0.00 sec) ================================

Notice in the above that MySQL Server has rounded one value.

The user now edits some random value in the 2nd row in the DataGrid.

Upon saving the edited data, the standard CommandBuilder found in DOTNET will make sure that we're not overwriting an update made by another user. It does this by using optimistic concurrency to make sure that noone else has modified the data that it's about to write.

In effect, DOTNET includes not only the primary key, but also other fields (in this case DecayRate) in it's UPDATE query.

================================ UPDATE testcase SET Id=Id WHERE Id='2' AND DecayRate='0.666666666666667';

Query OK, 0 rows affected (0.00 sec) ================================

Notice in the above that DecayRate matches what the DataGrid saw via it's initial SELECT. Also notice that 0 rows were affected.

DOTNET expected record number 2 to be updated, but it wasn't. DOTNET throws an exception, telling the application/user that someone else has modified data while the user wasn't looking:

System.Data.DBConcurrencyException: Concurrency violation: the UpdateCommand affected 0 records.

(A typical application would restart whatever job it was doing, and in effect retry the operation later. That will cause it to loop endlessly, because this is not really a concurrency exception.)

What it really is is MySQL Server storing more digits in the floating point number than it's telling the client. But when the SELECT happens, MySQL Server actually *uses* those digits in it's comparison, effectively making sure that optimistic concurrency is forever broken on MySQL.