mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
Add MDB_INTEGERKEY db flag
This commit is contained in:
parent
d499c244cd
commit
ce9456d95c
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user