[Mono-bugs] [Bug 78010][Nor] New - DataSet.EnforceConstraints throws incorrect constraint violation

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Apr 4 13:53:21 EDT 2006

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by prensing at cimetrics.com.


--- shadow/78010	2006-04-04 13:53:21.000000000 -0400
+++ shadow/78010.tmp.19821	2006-04-04 13:53:21.000000000 -0400
@@ -0,0 +1,58 @@
+Bug#: 78010
+Product: Mono: Class Libraries
+Version: 1.1
+OS Details: Fedora Core 4
+Status: NEW   
+Priority: Normal
+Component: Sys.Data
+AssignedTo: tsenganal at novell.com                            
+ReportedBy: prensing at cimetrics.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+Summary: DataSet.EnforceConstraints throws incorrect constraint violation
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+If you set:
+   DataSet.EnforceConstraints = false;
+before loading a multiple table dataset, you can get an incorrect
+ConstraintViolation exception when you turn constraints back on.
+The problem is in DataSet.InternalEnforceConstraints(). It loops through
+each table, rebuilds the Index if needed and then checks the constraint.
+The problem is that the index on other tables (needed by the constraint)
+has not been rebuilt yet.
+The code should loop through all the tables once and rebuild the indices.
+Then, go through the tables again to check constraints.
+You do not see this problem if the tables happen to be ordered correctly in
+the DataSet. If the parent table is first in the list, it works. If the
+child is first, it fails.
+Steps to reproduce the problem:
+1. Build a 2 table dataset, adding the child table first. Include a foreign
+key constraint.
+2. Set DataSet.EnforceConstraints = false;
+3. Load the dataset.
+4. Set DataSet.EnforceConstraints = true;
+Actual Results:
+The code throws an exception:
+System.Data.ConstraintException: Failed to enable constraints. One or more
+rows contain values violating non-null, unique, or foreign-key constraints.
+This is not correct, since the needed row is actually in the parent table.
+Expected Results:
+No exception.
+How often does this happen? 
+Always, if the DataSet is ordered from child to parent.
+Additional Information:

More information about the mono-bugs mailing list