]> git.sur5r.net Git - openldap/commitdiff
Merge remote branch 'mdb/mdb.master'
authorHoward Chu <hyc@openldap.org>
Mon, 5 Sep 2011 22:19:41 +0000 (15:19 -0700)
committerHoward Chu <hyc@openldap.org>
Mon, 5 Sep 2011 22:19:41 +0000 (15:19 -0700)
1  2 
libraries/libmdb/mdb.c

index 27f2387de22c822450876c127b952c062c9c49f8,bf09af860ce13ad8f367234a4e9f66c77aea6c66..73d3eaa290bb6865e3be9895f2c2a9dcdfab8c58
@@@ -2560,19 -2566,30 +2566,43 @@@ set1
                                        MDB_SET_KEY(leaf, &nodekey);
                                }
                                rc = cursor->mc_txn->mt_dbxs[cursor->mc_dbi].md_cmp(key, &nodekey);
+                               if (rc == 0) {
+                                       /* last node was the one we wanted */
+                                       top->mp_ki = NUMKEYS(top->mp_page)-1;
+                                       goto set1;
+                               }
+                               if (rc < 0) {
+                                       /* This is definitely the right page, skip search_page */
+                                       mpp.mp_page = top->mp_page;
+                                       rc = 0;
+                                       goto set2;
+                               }
++                              rc = cursor->mc_txn->mt_dbxs[cursor->mc_dbi].md_cmp(key, &nodekey);
 +                              if (rc <= 0) goto set1;
 +                      }
 +                      /* If any parents have right-sibs, search.
 +                       * Otherwise, there's nothing further.
 +                       */
 +                      for (i=0; i<cursor->mc_snum-1; i++)
 +                              if (cursor->mc_stack[i].mp_ki <
 +                                      NUMKEYS(cursor->mc_stack[i].mp_page)-1)
 +                                      break;
 +                      if (i == cursor->mc_snum - 1) {
 +                              /* There are no other pages */
 +                              goto set1;
                        }
+                       /* If any parents have right-sibs, search.
+                        * Otherwise, there's nothing further.
+                        */
+                       for (i=0; i<cursor->mc_snum-1; i++)
+                               if (cursor->mc_stack[i].mp_ki <
+                                       NUMKEYS(cursor->mc_stack[i].mp_page)-1)
+                                       break;
+                       if (i == cursor->mc_snum - 1) {
+                               /* There are no other pages */
+                               top->mp_ki = NUMKEYS(top->mp_page);
+                               return MDB_NOTFOUND;
+                       }
                }
        }