From: Howard Chu Date: Thu, 11 Aug 2011 18:35:39 +0000 (-0700) Subject: Add MDB_INTEGERKEY db flag X-Git-Tag: OPENLDAP_REL_ENG_2_4_27~148^2~118 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ce9456d95cadf5783ce3f3ad26eb407aa0f14197;p=openldap Add MDB_INTEGERKEY db flag --- diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c index a1b5b8e7e9..00a5054b3e 100644 --- a/libraries/libmdb/mdb.c +++ b/libraries/libmdb/mdb.c @@ -440,7 +440,11 @@ mdb_cmp(MDB_txn *txn, MDB_dbi dbi, const MDB_val *a, const MDB_val *b) 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); @@ -990,10 +994,7 @@ mdbenv_init_meta(MDB_env *env, MDB_meta *meta) 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; @@ -3121,8 +3122,8 @@ int mdb_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *dbi) /* 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; } diff --git a/libraries/libmdb/mdb.h b/libraries/libmdb/mdb.h index 1c111b500f..bfd29f068e 100644 --- a/libraries/libmdb/mdb.h +++ b/libraries/libmdb/mdb.h @@ -79,6 +79,7 @@ typedef enum MDB_cursor_op { /* cursor operations */ /* 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 */