Commit ef3f84bf authored by Howard Chu's avatar Howard Chu Committed by Quanah Gibson-Mount
Browse files

Use new Append support

parent a8c1c007
......@@ -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;
......
......@@ -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 );
}
......
......@@ -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,
......
......@@ -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 )
......
......@@ -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";
......
......@@ -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;
......
......@@ -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 );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment