data.data = d;
/* Delete our ID from the parent's list */
- rc = cursor->c_get( cursor, &key, &data, DB_GET_BOTH_RANGE | DB_RMW );
+ rc = cursor->c_get( cursor, &key, &data, DB_GET_BOTH_RANGE );
if ( rc == 0 ) {
if ( !strcmp( d->nrdn, BEI(e)->bei_nrdn.bv_val ))
rc = cursor->c_del( cursor, 0 );
*/
if ( rc == 0 ) {
BDB_ID2DISK( e->e_id, &nid );
- rc = cursor->c_get( cursor, &key, &data, DB_SET | DB_RMW );
+ rc = cursor->c_get( cursor, &key, &data, DB_SET );
if ( rc == 0 )
rc = cursor->c_del( cursor, 0 );
}
data.ulen = sizeof(buf);
data.flags = DB_DBT_USERMEM;
- if ( tid ) flags |= DB_RMW;
-
/* If we're not reusing an existing cursor, get a new one */
if( opflag != DB_NEXT ) {
rc = db->cursor( db, tid, &cursor, bdb->bi_db_opflags );
/* Fetch the first data item for this key, to see if it
* exists and if it's a range.
*/
- rc = cursor->c_get( cursor, key, &data, DB_SET | DB_RMW );
+ rc = cursor->c_get( cursor, key, &data, DB_SET );
err = "c_get";
if ( rc == 0 ) {
if ( nlo != 0 ) {
/* Update hi/lo if needed, then delete all the items
* between lo and hi
*/
- data.data = &nid;
- if ( id > hi ) {
- rc = cursor->c_del( cursor, 0 );
- if ( rc != 0 ) {
- err = "c_del hi";
- goto fail;
- }
- rc = cursor->c_put( cursor, key, &data, DB_KEYLAST );
- if ( rc != 0 ) {
- err = "c_put hi";
- goto fail;
- }
+ if ( id < lo ) {
+ lo = id;
+ nlo = nid;
+ } else if ( id > hi ) {
+ hi = id;
+ nhi = nid;
}
+ data.data = &nid;
/* Don't fetch anything, just position cursor */
data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
data.dlen = data.ulen = 0;
- rc = cursor->c_get( cursor, key, &data, DB_SET | DB_RMW );
+ rc = cursor->c_get( cursor, key, &data, DB_SET );
if ( rc != 0 ) {
err = "c_get 2";
goto fail;
}
- if ( id < lo ) {
- rc = cursor->c_del( cursor, 0 );
- if ( rc != 0 ) {
- err = "c_del lo";
- goto fail;
- }
- rc = cursor->c_put( cursor, key, &data, DB_KEYFIRST );
- if ( rc != 0 ) {
- err = "c_put lo";
- goto fail;
- }
+ rc = cursor->c_del( cursor, 0 );
+ if ( rc != 0 ) {
+ err = "c_del range1";
+ goto fail;
}
- /* Delete all the records between lo and hi */
- for ( i=2; i<count; i++ ) {
- rc = cursor->c_get( cursor, &key2, &data, DB_NEXT_DUP | DB_RMW );
+ /* Delete all the records */
+ for ( i=1; i<count; i++ ) {
+ rc = cursor->c_get( cursor, &key2, &data, DB_NEXT_DUP );
if ( rc != 0 ) {
err = "c_get next_dup";
goto fail;
err = "c_put range";
goto fail;
}
+ nid = nlo;
+ rc = cursor->c_put( cursor, key, &data, DB_KEYLAST );
+ if ( rc != 0 ) {
+ err = "c_put lo";
+ goto fail;
+ }
+ nid = nhi;
+ rc = cursor->c_put( cursor, key, &data, DB_KEYLAST );
+ if ( rc != 0 ) {
+ err = "c_put hi";
+ goto fail;
+ }
} else {
/* There's room, just store it */
goto put1;
/* Fetch the first data item for this key, to see if it
* exists and if it's a range.
*/
- rc = cursor->c_get( cursor, key, &data, DB_SET | DB_RMW );
+ rc = cursor->c_get( cursor, key, &data, DB_SET );
err = "c_get";
if ( rc == 0 ) {
if ( tmp != 0 ) {
if (tmp != nid) {
/* position to correct item */
tmp = nid;
- rc = cursor->c_get( cursor, key, &data,
- DB_GET_BOTH | DB_RMW );
+ rc = cursor->c_get( cursor, key, &data, DB_GET_BOTH );
if ( rc != 0 ) {
err = "c_get id";
goto fail;
return rc;
}
- flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE | DB_INIT_LOCK;
+ flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE;
if ( !( slapMode & SLAP_TOOL_QUICK ))
- flags |= DB_INIT_LOG | DB_INIT_TXN;
+ flags |= DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN;
#if 0
/* Never do automatic recovery, must perform it manually.
return rc;
}
- XLOCK_ID(bdb->bi_dbenv, &bdb->bi_cache.c_locker);
+ if ( !( slapMode & SLAP_TOOL_QUICK )) {
+ XLOCK_ID(bdb->bi_dbenv, &bdb->bi_cache.c_locker);
+ }
/* If we're in server mode and time-based checkpointing is enabled,
* submit a task to perform periodic checkpoints.
ldap_pvt_thread_rdwr_wunlock ( &bdb->bi_idl_tree_rwlock );
}
- XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker);
+ if ( !( slapMode & SLAP_TOOL_QUICK )) {
+ XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker);
+ }
return 0;
}
/* close db environment */
if( bdb->bi_dbenv ) {
/* force a checkpoint */
- rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
- if( rc != 0 ) {
- Debug( LDAP_DEBUG_ANY,
- "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n",
- db_strerror(rc), rc, 0 );
+ if ( !( slapMode & SLAP_TOOL_QUICK )) {
+ rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
+ if( rc != 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n",
+ db_strerror(rc), rc, 0 );
+ }
}
rc = bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
return -1;
}
+ if (! (slapMode & SLAP_TOOL_QUICK)) {
rc = TXN_BEGIN( bi->bi_dbenv, NULL, &tid, bi->bi_db_opflags );
if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
db_strerror(rc), rc, 0 );
goto done;
}
+ }
/*
* just (re)add them for now
op.o_tmpmemctx = NULL;
op.o_tmpmfuncs = &ch_mfuncs;
-#if 0 /* ndef BDB_HIER */
- /* add dn2id indices */
- rc = bdb_dn2id_add( &op, tid, NULL, e );
- if( rc != 0 && rc != DB_KEYEXIST ) {
- Debug( LDAP_DEBUG_ANY,
- "=> " LDAP_XSTRING(bdb_tool_entry_reindex)
- ": dn2id_add failed: %s (%d)\n",
- db_strerror(rc), rc, 0 );
- goto done;
- }
-#endif
-
rc = bdb_index_entry_add( &op, tid, e );
done:
if( rc == 0 ) {
+ if (! (slapMode & SLAP_TOOL_QUICK)) {
rc = TXN_COMMIT( tid, 0 );
if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
db_strerror(rc), rc, 0 );
e->e_id = NOID;
}
+ }
} else {
+ if (! (slapMode & SLAP_TOOL_QUICK)) {
TXN_ABORT( tid );
Debug( LDAP_DEBUG_ANY,
"=> " LDAP_XSTRING(bdb_tool_entry_reindex)
": txn_aborted! %s (%d)\n",
db_strerror(rc), rc, 0 );
+ }
e->e_id = NOID;
}
bdb_entry_release( &op, e, 0 );
"=> " LDAP_XSTRING(bdb_tool_entry_modify) "( %ld, \"%s\" )\n",
(long) e->e_id, e->e_dn, 0 );
+ if (! (slapMode & SLAP_TOOL_QUICK)) {
rc = TXN_BEGIN( bdb->bi_dbenv, NULL, &tid,
bdb->bi_db_opflags );
if( rc != 0 ) {
text->bv_val, 0, 0 );
return NOID;
}
+ }
op.o_hdr = &ohdr;
op.o_bd = be;
done:
if( rc == 0 ) {
+ if (! (slapMode & SLAP_TOOL_QUICK)) {
rc = TXN_COMMIT( tid, 0 );
if( rc != 0 ) {
snprintf( text->bv_val, text->bv_len,
"%s\n", text->bv_val, 0, 0 );
e->e_id = NOID;
}
+ }
} else {
+ if (! (slapMode & SLAP_TOOL_QUICK)) {
TXN_ABORT( tid );
snprintf( text->bv_val, text->bv_len,
"txn_aborted! %s (%d)",
Debug( LDAP_DEBUG_ANY,
"=> " LDAP_XSTRING(bdb_tool_entry_modify) ": %s\n",
text->bv_val, 0, 0 );
+ }
e->e_id = NOID;
}