Merge remote-tracking branch 'origin/mdb.RE/0.9'

This commit is contained in:
Quanah Gibson-Mount 2015-05-04 11:36:27 -05:00
commit a6ea07dd63

View File

@ -5752,15 +5752,21 @@ set1:
return rc; return rc;
} }
} else if (op == MDB_GET_BOTH || op == MDB_GET_BOTH_RANGE) { } else if (op == MDB_GET_BOTH || op == MDB_GET_BOTH_RANGE) {
MDB_val d2; MDB_val olddata;
if ((rc = mdb_node_read(mc->mc_txn, leaf, &d2)) != MDB_SUCCESS) MDB_cmp_func *dcmp;
if ((rc = mdb_node_read(mc->mc_txn, leaf, &olddata)) != MDB_SUCCESS)
return rc; 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 (rc) {
if (op == MDB_GET_BOTH || rc > 0) if (op == MDB_GET_BOTH || rc > 0)
return MDB_NOTFOUND; return MDB_NOTFOUND;
rc = 0; rc = 0;
*data = d2; *data = olddata;
} }
} else { } else {
@ -6270,16 +6276,17 @@ more:
/* Was a single item before, must convert now */ /* Was a single item before, must convert now */
if (!F_ISSET(leaf->mn_flags, F_DUPDATA)) { if (!F_ISSET(leaf->mn_flags, F_DUPDATA)) {
MDB_cmp_func *dcmp;
/* Just overwrite the current item */ /* Just overwrite the current item */
if (flags == MDB_CURRENT) if (flags == MDB_CURRENT)
goto current; goto current;
dcmp = mc->mc_dbx->md_dcmp;
#if UINT_MAX < SIZE_MAX #if UINT_MAX < SIZE_MAX
if (mc->mc_dbx->md_dcmp == mdb_cmp_int && olddata.mv_size == sizeof(size_t)) if (dcmp == mdb_cmp_int && olddata.mv_size == sizeof(size_t))
mc->mc_dbx->md_dcmp = mdb_cmp_clong; dcmp = mdb_cmp_clong;
#endif #endif
/* does data match? */ /* does data match? */
if (!mc->mc_dbx->md_dcmp(data, &olddata)) { if (!dcmp(data, &olddata)) {
if (flags & MDB_NODUPDATA) if (flags & MDB_NODUPDATA)
return MDB_KEYEXIST; return MDB_KEYEXIST;
/* overwrite it */ /* overwrite it */
@ -7076,15 +7083,13 @@ mdb_xcursor_init1(MDB_cursor *mc, MDB_node *node)
mx->mx_db.md_flags |= MDB_INTEGERKEY; mx->mx_db.md_flags |= MDB_INTEGERKEY;
} }
} }
#if UINT_MAX < SIZE_MAX
if (mc->mc_dbx->md_dcmp == mdb_cmp_int && mx->mx_db.md_pad == sizeof(size_t)) {
mc->mc_dbx->md_dcmp = mdb_cmp_clong;
mx->mx_dbx.md_cmp = mdb_cmp_clong;
}
#endif
DPRINTF(("Sub-db -%u root page %"Z"u", mx->mx_cursor.mc_dbi, DPRINTF(("Sub-db -%u root page %"Z"u", mx->mx_cursor.mc_dbi,
mx->mx_db.md_root)); mx->mx_db.md_root));
mx->mx_dbflag = DB_VALID|DB_DIRTY; /* DB_DIRTY guides mdb_cursor_touch */ mx->mx_dbflag = DB_VALID|DB_DIRTY; /* DB_DIRTY guides mdb_cursor_touch */
#if UINT_MAX < SIZE_MAX
if (mx->mx_dbx.md_cmp == mdb_cmp_int && mx->mx_db.md_pad == sizeof(size_t))
mx->mx_dbx.md_cmp = mdb_cmp_clong;
#endif
} }
/** Initialize a cursor for a given transaction and database. */ /** Initialize a cursor for a given transaction and database. */