]> git.sur5r.net Git - openldap/commitdiff
Merge remote-tracking branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_4
authorQuanah Gibson-Mount <quanah@openldap.org>
Wed, 6 Aug 2014 16:59:30 +0000 (11:59 -0500)
committerQuanah Gibson-Mount <quanah@openldap.org>
Wed, 6 Aug 2014 16:59:30 +0000 (11:59 -0500)
libraries/liblmdb/lmdb.h
libraries/liblmdb/mdb.c

index a4c4bca621de7f8d5f679c1871326a846a5e265a..11b46bfa4866faca3c5eefacabc0d445ed8393e1 100644 (file)
@@ -1410,7 +1410,10 @@ int  mdb_cursor_get(MDB_cursor *cursor, MDB_val *key, MDB_val *data,
         * <ul>
         *      <li>#MDB_CURRENT - replace the item at the current cursor position.
         *              The \b key parameter must still be provided, and must match it.
-        *              So must \b data if using sorted duplicates (#MDB_DUPSORT).
+        *              If using sorted duplicates (#MDB_DUPSORT) the data item must still
+        *              sort into the same place. This is intended to be used when the
+        *              new data is the same size as the old. Otherwise it will simply
+        *              perform a delete of the old record followed by an insert.
         *      <li>#MDB_NODUPDATA - enter the new key/data pair only if it does not
         *              already appear in the database. This flag may only be specified
         *              if the database was opened with #MDB_DUPSORT. The function will
index 96f5772903ea9e338883b69185327ed49f77308b..8b560ed32e238a71bff0529907232ecc630701a9 100644 (file)
@@ -3110,6 +3110,12 @@ mdb_page_flush(MDB_txn *txn, int keep)
 #endif /* _WIN32 */
        }
 
+       /* MIPS has cache coherency issues, this is a no-op everywhere else
+        * Note: for any size >= on-chip cache size, entire on-chip cache is
+        * flushed.
+        */
+       CACHEFLUSH(env->me_map, txn->mt_next_pgno * env->me_psize, DCACHE);
+
        for (i = keep; ++i <= pagecount; ) {
                dp = dl[i].mptr;
                /* This is a page we skipped above */
@@ -3581,6 +3587,10 @@ fail:
                return rc;
        }
 done:
+       /* MIPS has cache coherency issues, this is a no-op everywhere else */
+       if (!(env->me_flags & MDB_WRITEMAP)) {
+               CACHEFLUSH(env->me_map + off, len, DCACHE);
+       }
        /* Memory ordering issues are irrelevant; since the entire writer
         * is wrapped by wmutex, all of these changes will become visible
         * after the wmutex is unlocked. Since the DB is multi-version,
@@ -3590,11 +3600,6 @@ done:
        if (env->me_txns)
                env->me_txns->mti_txnid = txn->mt_txnid;
 
-       /* MIPS has cache coherency issues, this is a no-op everywhere else */
-       if (!(env->me_flags & MDB_WRITEMAP)) {
-               CACHEFLUSH(env->me_map, txn->mt_next_pgno * env->me_psize, DCACHE);
-       }
-
        return MDB_SUCCESS;
 }
 
@@ -6057,6 +6062,24 @@ mdb_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val *data,
                                return MDB_BAD_VALSIZE;
                        ptr = LEAF2KEY(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top], ksize);
                        memcpy(ptr, key->mv_data, ksize);
+fix_parent:
+                       /* if overwriting slot 0 of leaf, need to
+                        * update branch key if there is a parent page
+                        */
+                       if (mc->mc_top && !mc->mc_ki[mc->mc_top]) {
+                               unsigned short top = mc->mc_top;
+                               mc->mc_top--;
+                               /* slot 0 is always an empty key, find real slot */
+                               while (mc->mc_top && !mc->mc_ki[mc->mc_top])
+                                       mc->mc_top--;
+                               if (mc->mc_ki[mc->mc_top])
+                                       rc2 = mdb_update_key(mc, key);
+                               else
+                                       rc2 = MDB_SUCCESS;
+                               mc->mc_top = top;
+                               if (rc2)
+                                       return rc2;
+                       }
                        return MDB_SUCCESS;
                }
 
@@ -6262,8 +6285,10 @@ current:
                                data->mv_data = olddata.mv_data;
                        else if (!(mc->mc_flags & C_SUB))
                                memcpy(olddata.mv_data, data->mv_data, data->mv_size);
-                       else
+                       else {
                                memcpy(NODEKEY(leaf), key->mv_data, key->mv_size);
+                               goto fix_parent;
+                       }
                        return MDB_SUCCESS;
                }
                mdb_node_del(mc, 0);