db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1600779 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ReferencedKeyRIChecker.java
Date Thu, 05 Jun 2014 22:00:26 GMT
Author: dag
Date: Thu Jun  5 22:00:26 2014
New Revision: 1600779

URL: http://svn.apache.org/r1600779
Log:
DERBY-6576 A immediate Fk constraint blows up iff its referenced PK is deferred and we modify
a duplicate key column

A follow-up patch, derby-6576-repeatable-read. In the case where we do
not throw an exception because the deferred unique/pk constraint
referenced by an fk is upheld by another row, we need to make sure
that condition holds until we commit. This patch changes the check (in
ReferencedKeyRIChecker#isDuplicated) to scan using repeatable read
isolation level instead of read committed. This will set a read lock
on any (well, the first we find) duplicate row till transaction end
and thus ensure things are good till we commit.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ReferencedKeyRIChecker.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ReferencedKeyRIChecker.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ReferencedKeyRIChecker.java?rev=1600779&r1=1600778&r2=1600779&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ReferencedKeyRIChecker.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ReferencedKeyRIChecker.java
Thu Jun  5 22:00:26 2014
@@ -340,20 +340,25 @@ public class ReferencedKeyRIChecker exte
                     0,                      // read only
                     TransactionController.MODE_RECORD,
                                             // record locking
-                    TransactionController.ISOLATION_READ_COMMITTED_NOHOLDLOCK,
+
+                    // Use repeatable read here, since we rely on the row being
+                    // present till we commit if we accept this row as being
+                    // the one the upholds the constraint when we delete ours.
+                    TransactionController.ISOLATION_REPEATABLE_READ,
+
                     (FormatableBitSet)null, // retrieve all fields
-                    key,                 // startKeyValue
+                    key,                    // startKeyValue
                     ScanController.GE,      // startSearchOp
                     null,                   // qualified
-                    key,                 // stopKeyValue
+                    key,                    // stopKeyValue
                     ScanController.GT);     // stopSearchOp
         } else {
             refKeyIndexScan.reopenScan(
-                      key,             // startKeyValue
-                      ScanController.GE,  // startSearchOp
-                      null,               // qualifier
-                      key,             // stopKeyValue
-                      ScanController.GT); // stopSearchOp
+                      key,                  // startKeyValue
+                      ScanController.GE,    // startSearchOp
+                      null,                 // qualifier
+                      key,                  // stopKeyValue
+                      ScanController.GT);   // stopSearchOp
         }
 
 



Mime
View raw message