]> git.sur5r.net Git - openldap/commitdiff
ITS#8117 better fix
authorHoward Chu <hyc@openldap.org>
Sun, 3 May 2015 06:52:47 +0000 (07:52 +0100)
committerHoward Chu <hyc@openldap.org>
Sun, 3 May 2015 06:57:22 +0000 (07:57 +0100)
Don't change mc_dbx because we would need to undo the change if
the txn aborts. Make the fix (for get) match existing code for put.

libraries/liblmdb/mdb.c

index f1c7508ccf21afe70693809eabce5a57ad75e4c1..ec8f8f38d334f4db946157dd7c69c3297f4b5954 100644 (file)
@@ -5871,15 +5871,21 @@ set1:
                                        return rc;
                        }
                } else if (op == MDB_GET_BOTH || op == MDB_GET_BOTH_RANGE) {
-                       MDB_val d2;
-                       if ((rc = mdb_node_read(mc->mc_txn, leaf, &d2)) != MDB_SUCCESS)
+                       MDB_val olddata;
+                       MDB_cmp_func *dcmp;
+                       if ((rc = mdb_node_read(mc->mc_txn, leaf, &olddata)) != MDB_SUCCESS)
                                return rc;
-                       rc = mc->mc_dbx->md_dcmp(data, &d2);
+                       dcmp = mc->mc_dbx->md_dcmp;
+#if UINT_MAX < SIZE_MAX
+                       if (dcmp == mdb_cmp_int && olddata.mv_size == sizeof(size_t))
+                               dcmp = mdb_cmp_clong;
+#endif
+                       rc = dcmp(data, &olddata);
                        if (rc) {
                                if (op == MDB_GET_BOTH || rc > 0)
                                        return MDB_NOTFOUND;
                                rc = 0;
-                               *data = d2;
+                               *data = olddata;
                        }
 
                } else {
@@ -6388,16 +6394,17 @@ more:
 
                        /* Was a single item before, must convert now */
                        if (!F_ISSET(leaf->mn_flags, F_DUPDATA)) {
+                               MDB_cmp_func *dcmp;
                                /* Just overwrite the current item */
                                if (flags == MDB_CURRENT)
                                        goto current;
-
+                               dcmp = mc->mc_dbx->md_dcmp;
 #if UINT_MAX < SIZE_MAX
-                               if (mc->mc_dbx->md_dcmp == mdb_cmp_int && olddata.mv_size == sizeof(size_t))
-                                       mc->mc_dbx->md_dcmp = mdb_cmp_clong;
+                               if (dcmp == mdb_cmp_int && olddata.mv_size == sizeof(size_t))
+                                       dcmp = mdb_cmp_clong;
 #endif
                                /* does data match? */
-                               if (!mc->mc_dbx->md_dcmp(data, &olddata)) {
+                               if (!dcmp(data, &olddata)) {
                                        if (flags & MDB_NODUPDATA)
                                                return MDB_KEYEXIST;
                                        /* overwrite it */