]> git.sur5r.net Git - openldap/commitdiff
Fix mdb_page_split - nested split
authorHoward Chu <hyc@symas.com>
Tue, 14 May 2013 23:57:50 +0000 (16:57 -0700)
committerHoward Chu <hyc@symas.com>
Tue, 14 May 2013 23:57:50 +0000 (16:57 -0700)
If updating a page's separator triggers a split in its parent,
we may have missed adjusting the parent's cursor position.

libraries/liblmdb/mdb.c

index dfa87964bc1aa02bef9de8bb9ea6e691f1f18099..c09cb0d91820729fcb93ecd14a1da2171ecc428c 100644 (file)
@@ -6933,6 +6933,17 @@ newsep:
                }
        } else {
                mc->mc_ki[ptop]++;
+               /* Make sure mc_ki is still valid.
+                */
+               if (mn.mc_pg[ptop] != mc->mc_pg[ptop] &&
+                   mc->mc_ki[ptop] >= NUMKEYS(mc->mc_pg[ptop])) {
+                       for (i=0; i<ptop; i++) {
+                               mc->mc_pg[i] = mn.mc_pg[i];
+                               mc->mc_ki[i] = mn.mc_ki[i];
+                       }
+                       mc->mc_pg[ptop] = mn.mc_pg[ptop];
+                       mc->mc_ki[ptop] = mn.mc_ki[ptop] - 1;
+               }
        }
 
        /* return tmp page to freelist */