static int
_mdb_cmp(MDB_txn *txn, MDB_dbi dbi, const MDB_val *key1, const MDB_val *key2)
{
- if (F_ISSET(txn->mt_dbs[dbi].md_flags, MDB_REVERSEKEY))
+ if (txn->mt_dbs[dbi].md_flags & (MDB_REVERSEKEY
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ |MDB_INTEGERKEY
+#endif
+ ))
return memnrcmp(key1->mv_data, key1->mv_size, key2->mv_data, key2->mv_size);
else
return memncmp((char *)key1->mv_data, key1->mv_size, key2->mv_data, key2->mv_size);
meta->mm_psize = psize;
meta->mm_last_pg = 1;
meta->mm_flags = env->me_flags & 0xffff;
-#if __BYTE_ORDER == __LITTLE_ENDIAN
- /* freeDB keys are pgno_t's, must compare in int order */
- meta->mm_flags |= MDB_REVERSEKEY;
-#endif
+ meta->mm_flags |= MDB_INTEGERKEY;
meta->mm_dbs[0].md_root = P_INVALID;
meta->mm_dbs[1].md_root = P_INVALID;
/* main DB? */
if (!name) {
*dbi = MAIN_DBI;
- if (flags & (MDB_DUPSORT|MDB_REVERSEKEY))
- txn->mt_dbs[MAIN_DBI].md_flags |= (flags & (MDB_DUPSORT|MDB_REVERSEKEY));
+ if (flags & (MDB_DUPSORT|MDB_REVERSEKEY|MDB_INTEGERKEY))
+ txn->mt_dbs[MAIN_DBI].md_flags |= (flags & (MDB_DUPSORT|MDB_REVERSEKEY|MDB_INTEGERKEY));
return MDB_SUCCESS;
}
/* DB flags */
#define MDB_REVERSEKEY 0x02 /* use reverse string keys */
#define MDB_DUPSORT 0x04 /* use sorted duplicates */
+#define MDB_INTEGERKEY 0x08 /* numeric keys in native byte order */
/* environment flags */
#define MDB_FIXEDMAP 0x01 /* mmap at a fixed address */