ID lo, hi, *i;
char *err;
int rc, k;
+ unsigned int flag = MDB_NODUPDATA;
{
char buf[16];
assert( id != NOID );
+ if ( slapMode & SLAP_TOOL_QUICK )
+ flag |= MDB_APPEND;
+
for ( k=0; keys[k].bv_val; k++ ) {
/* Fetch the first data item for this key, to see if it
* exists and if it's a range.
} else if ( rc == MDB_NOTFOUND ) {
put1: data.mv_data = &id;
data.mv_size = sizeof(ID);
- rc = mdb_cursor_put( cursor, &key, &data, MDB_NODUPDATA );
+ rc = mdb_cursor_put( cursor, &key, &data, flag );
/* Don't worry if it's already there */
if ( rc == MDB_KEYEXIST )
rc = 0;
#include "back-mdb.h"
#include "idl.h"
+#ifdef MDB_TOOL_IDL_CACHING
static int mdb_tool_idl_flush( BackendDB *be, MDB_txn *txn );
#define IDBLOCK 1024
static mdb_tool_idl_cache_entry *mdb_tool_idl_free_list;
static Avlnode *mdb_tool_roots[MDB_INDICES];
+#define MDB_TOOL_IDL_FLUSH(be, txn) mdb_tool_idl_flush(be, txn)
+#else
+#define MDB_TOOL_IDL_FLUSH(be, txn)
+#endif /* MDB_TOOL_IDL_CACHING */
+
static MDB_txn *txn = NULL, *txi = NULL;
static MDB_cursor *cursor = NULL, *idcursor = NULL;
static MDB_val key, data;
mdb_cursor_close( cursor );
cursor = NULL;
}
- mdb_tool_idl_flush( be, txn );
+ MDB_TOOL_IDL_FLUSH( be, txn );
if( txn ) {
if ( mdb_txn_commit( txn ))
return -1;
if( rc == 0 ) {
mdb_writes++;
if ( mdb_writes >= mdb_writes_per_commit ) {
- mdb_tool_idl_flush( be, txn );
+ MDB_TOOL_IDL_FLUSH( be, txn );
rc = mdb_txn_commit( txn );
mdb_writes = 0;
txn = NULL;
if( rc == 0 ) {
mdb_writes++;
if ( mdb_writes >= mdb_writes_per_commit ) {
- mdb_tool_idl_flush( be, txi );
+ MDB_TOOL_IDL_FLUSH( be, txi );
rc = mdb_txn_commit( txi );
if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
}
#endif
+#ifdef MDB_TOOL_IDL_CACHING
static int
mdb_tool_idl_cmp( const void *v1, const void *v2 )
{
{
struct mdb_info *mdb = (struct mdb_info *) be->be_private;
int rc = 0;
- unsigned int i;
-
- for ( i=MDB_NDB; i < mdb->mi_nattrs+MDB_NDB; i++ ) {
- if ( !mdb_tool_roots[i] ) continue;
- rc = mdb_tool_idl_flush_db( txn, i, mdb_tool_roots[i] );
- tavl_free(mdb_tool_roots[i], NULL);
- mdb_tool_roots[i] = NULL;
+ unsigned int i, dbi;
+
+ for ( i=0; i < mdb->mi_nattrs; i++ ) {
+ dbi = mdb->mi_attrs[i]->ai_dbi;
+ if ( !mdb_tool_roots[dbi] ) continue;
+ rc = mdb_tool_idl_flush_db( txn, dbi, mdb_tool_roots[dbi] );
+ tavl_free(mdb_tool_roots[dbi], NULL);
+ mdb_tool_roots[dbi] = NULL;
if ( rc )
break;
}
ic->tail->next = ice;
}
ic->tail = ice;
+ if ( lcount )
+ ice->ids[lcount-1] = 0;
if ( !ic->count )
ic->first = id;
}
return 0;
}
+#endif /* MDB_TOOL_IDL_CACHING */