]> git.sur5r.net Git - openldap/commitdiff
ITS#8300 fix node_move
authorHoward Chu <hyc@openldap.org>
Wed, 4 Nov 2015 21:01:30 +0000 (21:01 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 4 Nov 2015 21:02:44 +0000 (21:02 +0000)
Don't adjust other cursors when we added a node on the right.

libraries/liblmdb/mdb.c

index eecb5477810bbad5ca54a1ed39d0d9d9b8ba2fe0..0054f62b5a5d07928143b67e55d23c6587ceeafc 100644 (file)
@@ -7719,16 +7719,19 @@ mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst)
                MDB_dbi dbi = csrc->mc_dbi;
                MDB_page *mp;
 
-               mp = cdst->mc_pg[csrc->mc_top];
-               for (m2 = csrc->mc_txn->mt_cursors[dbi]; m2; m2=m2->mc_next) {
-                       if (csrc->mc_flags & C_SUB)
-                               m3 = &m2->mc_xcursor->mx_cursor;
-                       else
-                               m3 = m2;
-                       if (m3 == cdst) continue;
-                       if (m3->mc_pg[csrc->mc_top] == mp && m3->mc_ki[csrc->mc_top] >=
-                               cdst->mc_ki[csrc->mc_top]) {
-                               m3->mc_ki[csrc->mc_top]++;
+               /* If we're adding on the left, bump others up */
+               if (!cdst->mc_ki[csrc->mc_top]) {
+                       mp = cdst->mc_pg[csrc->mc_top];
+                       for (m2 = csrc->mc_txn->mt_cursors[dbi]; m2; m2=m2->mc_next) {
+                               if (csrc->mc_flags & C_SUB)
+                                       m3 = &m2->mc_xcursor->mx_cursor;
+                               else
+                                       m3 = m2;
+                               if (m3 == cdst) continue;
+                               if (m3->mc_pg[csrc->mc_top] == mp && m3->mc_ki[csrc->mc_top] >=
+                                       cdst->mc_ki[csrc->mc_top]) {
+                                       m3->mc_ki[csrc->mc_top]++;
+                               }
                        }
                }