From: Howard Chu Date: Sat, 21 Jul 2012 13:21:56 +0000 (-0700) Subject: Use new Append support X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=38a3317096a93eb741423c6ab583c41ff131c669;p=openldap Use new Append support --- diff --git a/servers/slapd/back-mdb/back-mdb.h b/servers/slapd/back-mdb/back-mdb.h index e4b6d7e2a8..5152142177 100644 --- a/servers/slapd/back-mdb/back-mdb.h +++ b/servers/slapd/back-mdb/back-mdb.h @@ -69,6 +69,7 @@ struct mdb_info { int mi_dbenv_mode; size_t mi_mapsize; + ID mi_nextid; slap_mask_t mi_defaultmask; int mi_nattrs; diff --git a/servers/slapd/back-mdb/dn2id.c b/servers/slapd/back-mdb/dn2id.c index 3cb64c33aa..977f2d2d02 100644 --- a/servers/slapd/back-mdb/dn2id.c +++ b/servers/slapd/back-mdb/dn2id.c @@ -137,7 +137,7 @@ mdb_dn2id_add( memcpy( ptr, &pid, sizeof( ID )); d->nrdnlen[0] ^= 0x80; - if (slapMode & SLAP_TOOL_MODE) + if ((slapMode & SLAP_TOOL_MODE) || (e->e_id == mdb->mi_nextid)) flag |= MDB_APPEND; rc = mdb_cursor_put( mcd, &key, &data, flag ); } diff --git a/servers/slapd/back-mdb/id2entry.c b/servers/slapd/back-mdb/id2entry.c index 863ccf6c1f..29ff9c80ed 100644 --- a/servers/slapd/back-mdb/id2entry.c +++ b/servers/slapd/back-mdb/id2entry.c @@ -60,6 +60,9 @@ static int mdb_id2entry_put( flag |= MDB_RESERVE; + if (e->e_id < mdb->mi_nextid) + flag &= ~MDB_APPEND; + again: data.mv_size = ec.len; if ( mc ) @@ -74,7 +77,7 @@ again: if (rc) { /* Was there a hole from slapadd? */ if ( (flag & MDB_NOOVERWRITE) && data.mv_size == 0 ) { - flag ^= ADD_FLAGS; + flag &= ~ADD_FLAGS; goto again; } Debug( LDAP_DEBUG_ANY, diff --git a/servers/slapd/back-mdb/idl.c b/servers/slapd/back-mdb/idl.c index 227c9802f9..78ad09956b 100644 --- a/servers/slapd/back-mdb/idl.c +++ b/servers/slapd/back-mdb/idl.c @@ -391,10 +391,12 @@ mdb_idl_fetch_key( int mdb_idl_insert_keys( + BackendDB *be, MDB_cursor *cursor, struct berval *keys, ID id ) { + struct mdb_info *mdb = be->be_private; MDB_val key, data; ID lo, hi, *i; char *err; @@ -490,8 +492,8 @@ mdb_idl_insert_keys( } } else { /* There's room, just store it */ - if ( slapMode & SLAP_TOOL_QUICK ) - flag |= MDB_APPEND; + if (id == mdb->mi_nextid) + flag |= MDB_APPENDDUP; goto put1; } } else { @@ -518,7 +520,7 @@ mdb_idl_insert_keys( } } } else if ( rc == MDB_NOTFOUND ) { - flag &= ~MDB_APPEND; + flag &= ~MDB_APPENDDUP; put1: data.mv_data = &id; data.mv_size = sizeof(ID); rc = mdb_cursor_put( cursor, &key, &data, flag ); @@ -542,6 +544,7 @@ fail: int mdb_idl_delete_keys( + BackendDB *be, MDB_cursor *cursor, struct berval *keys, ID id ) diff --git a/servers/slapd/back-mdb/index.c b/servers/slapd/back-mdb/index.c index 6acdfc09ee..8306dbd691 100644 --- a/servers/slapd/back-mdb/index.c +++ b/servers/slapd/back-mdb/index.c @@ -200,7 +200,7 @@ static int indexer( keyfunc = mdb_idl_delete_keys; if( IS_SLAP_INDEX( mask, SLAP_INDEX_PRESENT ) ) { - rc = keyfunc( mc, presence_key, id ); + rc = keyfunc( op->o_bd, mc, presence_key, id ); if( rc ) { err = "presence"; goto done; @@ -216,7 +216,7 @@ static int indexer( atname, vals, &keys, op->o_tmpmemctx ); if( rc == LDAP_SUCCESS && keys != NULL ) { - rc = keyfunc( mc, keys, id ); + rc = keyfunc( op->o_bd, mc, keys, id ); ber_bvarray_free_x( keys, op->o_tmpmemctx ); if ( rc ) { err = "equality"; @@ -235,7 +235,7 @@ static int indexer( atname, vals, &keys, op->o_tmpmemctx ); if( rc == LDAP_SUCCESS && keys != NULL ) { - rc = keyfunc( mc, keys, id ); + rc = keyfunc( op->o_bd, mc, keys, id ); ber_bvarray_free_x( keys, op->o_tmpmemctx ); if ( rc ) { err = "approx"; @@ -255,7 +255,7 @@ static int indexer( atname, vals, &keys, op->o_tmpmemctx ); if( rc == LDAP_SUCCESS && keys != NULL ) { - rc = keyfunc( mc, keys, id ); + rc = keyfunc( op->o_bd, mc, keys, id ); ber_bvarray_free_x( keys, op->o_tmpmemctx ); if( rc ) { err = "substr"; diff --git a/servers/slapd/back-mdb/nextid.c b/servers/slapd/back-mdb/nextid.c index d4ce5e34a3..8d39764664 100644 --- a/servers/slapd/back-mdb/nextid.c +++ b/servers/slapd/back-mdb/nextid.c @@ -23,6 +23,7 @@ int mdb_next_id( BackendDB *be, MDB_cursor *mc, ID *out ) { + struct mdb_info *mdb = (struct mdb_info *) be->be_private; int rc; ID id = 0; MDB_val key; @@ -45,6 +46,7 @@ int mdb_next_id( BackendDB *be, MDB_cursor *mc, ID *out ) mdb_strerror(rc), rc, 0 ); goto done; } + mdb->mi_nextid = *out; done: return rc; diff --git a/servers/slapd/back-mdb/proto-mdb.h b/servers/slapd/back-mdb/proto-mdb.h index 27c27388b2..799e817170 100644 --- a/servers/slapd/back-mdb/proto-mdb.h +++ b/servers/slapd/back-mdb/proto-mdb.h @@ -202,6 +202,7 @@ int mdb_idl_fetch_key( int mdb_idl_insert( ID *ids, ID id ); typedef int (mdb_idl_keyfunc)( + BackendDB *be, MDB_cursor *mc, struct berval *key, ID id );