So the issue is null values in the index. I believe the loop should be
exiting after detecting a match in the index, but deciding not to throw an
error. This happens in 2 places. See the patch below. My understanding is
that if it reaches the point where the breaks happen then it must be a null
row entry of some kind (i.e. that is allowed to be non-unique in the index
according to the database mode), in which case it is ok to break and not
check any further.

The reason it effected me so much - to the point of looping over all rows
in the index - is the import process I was running is 2-pass, so it first
creates rows, and then it creates links between the rows, so a unique
foreign key column will initially be all nulls until the second pass.

regards,

Mike

Index: src/main/org/h2/mvstore/db/MVSecondaryIndex.java
===================================================================
--- src/main/org/h2/mvstore/db/MVSecondaryIndex.java    (revision 7501)
+++ src/main/org/h2/mvstore/db/MVSecondaryIndex.java    (working copy)
@@ -210,7 +210,7 @@
                 }
                 if (containsNullAndAllowMultipleNull(r2)) {
                     // this is allowed
-                    continue;
+                    break;
                 }
                 if (map.isSameTransaction(k)) {
                     continue;
@@ -225,7 +225,7 @@
     }

     private void checkUnique(SearchRow row, TransactionMap<Value, Value>
map, ValueArray unique) {
-        Iterator<Value> it = map.keyIterator(unique, true);
+        Iterator<Value> it = map.keyIterator(unique, true);
         while (it.hasNext()) {
             ValueArray k = (ValueArray) it.next();
             SearchRow r2 = convertToSearchRow(k);
@@ -236,6 +236,7 @@
                 if (!containsNullAndAllowMultipleNull(r2)) {
                     throw getDuplicateKeyException(k.toString());
                 }
+                break;
             }
         }
     }

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to