- bdb deallocates cursor after some tool operations but expects it to be
  around every time it is called
- mdb tries to allocate a second transaction while it already holds one,
  deadlocking
- op->o_hdr must exist for most uses of op, but o_tmpmfuncs need not
- what about indexing after a tool modify? Does it happen automatically?
                e->e_id = NOID;
        }
 
+       if ( cursor == NULL )
+       {
+               int rc = bdb->bi_id2entry->bdi_db->cursor(
+                       bdb->bi_id2entry->bdi_db, bdb->bi_cache.c_txn, &cursor,
+                       bdb->bi_db_opflags );
+               if ( rc != 0 )
+                       e->e_id = NOID;
+       }
+
        return e->e_id;
 }
 
                e->e_id = NOID;
        }
 
+       if ( cursor == NULL )
+       {
+               int rc = bdb->bi_id2entry->bdi_db->cursor(
+                       bdb->bi_id2entry->bdi_db, bdb->bi_cache.c_txn, &cursor,
+                       bdb->bi_db_opflags );
+               if ( rc != 0 )
+                       e->e_id = NOID;
+       }
+
        return e->e_id;
 }
 
 
        if ( !e )
                return 0;
        if ( e->e_private ) {
-               if ( op->o_hdr ) {
+               if ( op->o_hdr && op->o_tmpmfuncs ) {
                        op->o_tmpfree( e->e_nname.bv_val, op->o_tmpmemctx );
                        op->o_tmpfree( e->e_name.bv_val, op->o_tmpmemctx );
                        op->o_tmpfree( e, op->o_tmpmemctx );