MDB_cursor *mvc;
Attribute *a;
rc = mdb_cursor_open( txn, mdb->mi_dbis[MDB_ID2VAL], &mvc );
- if( rc )
- return rc;
- for ( a = ec.multi; a; a=a->a_next ) {
- if (!(a->a_flags & SLAP_ATTR_BIG_MULTI))
- continue;
- rc = mdb_mval_put( op, mvc, e->e_id, a );
- if( rc != LDAP_SUCCESS )
- break;
+ if( !rc ) {
+ for ( a = ec.multi; a; a=a->a_next ) {
+ if (!(a->a_flags & SLAP_ATTR_BIG_MULTI))
+ continue;
+ rc = mdb_mval_put( op, mvc, e->e_id, a );
+ if( rc )
+ break;
+ }
+ mdb_cursor_close( mvc );
+ }
+ if ( rc ) {
+ Debug( LDAP_DEBUG_ANY,
+ "mdb_id2entry_put: mdb_mval_put failed: %s(%d) \"%s\"\n",
+ mdb_strerror(rc), rc,
+ e->e_nname.bv_val );
+ return LDAP_OTHER;
}
- mdb_cursor_close( mvc );
- if ( rc )
- return rc;
}
}
if (rc) {
if ( anew->a_flags & SLAP_ATTR_BIG_MULTI ) {
if (!mvc) {
err = mdb_cursor_open( tid, mdb->mi_dbis[MDB_ID2VAL], &mvc );
- if (err)
+ if (err) {
+mval_fail: strncpy( textbuf, mdb_strerror( err ), textlen );
+ err = LDAP_OTHER;
break;
+ }
}
/* if prev was set, just add new values */
if (a_flags & SLAP_ATTR_BIG_MULTI ) {
if (anew->a_nvals == anew->a_vals)
anew->a_nvals = NULL;
}
+ if ( err )
+ goto mval_fail;
}
}
break;
if (!mvc) {
err = mdb_cursor_open( tid, mdb->mi_dbis[MDB_ID2VAL], &mvc );
if (err)
- break;
+ goto mval_fail;
}
if ( mod->sm_numvals ) {
anew = attr_find( e->e_attrs, mod->sm_desc );
anew->a_numvals = 0;
}
err = mdb_mval_del( op, mvc, e->e_id, anew );
+ if ( err )
+ goto mval_fail;
}
}
break;
if (!mvc) {
err = mdb_cursor_open( tid, mdb->mi_dbis[MDB_ID2VAL], &mvc );
if (err)
- break;
+ goto mval_fail;
}
/* delete all values */
anew = &a_dummy;
anew->a_numvals = 0;
err = mdb_mval_del( op, mvc, e->e_id, anew );
if (err)
- break;
+ goto mval_fail;
}
anew = attr_find( e->e_attrs, mod->sm_desc );
- if (mod->sm_numvals >= mdb->mi_multi_lo) {
+ if (mod->sm_numvals > mdb->mi_multi_hi) {
anew->a_flags |= SLAP_ATTR_BIG_MULTI;
if (!mvc) {
err = mdb_cursor_open( tid, mdb->mi_dbis[MDB_ID2VAL], &mvc );
if (err)
- break;
+ goto mval_fail;
}
err = mdb_mval_put(op, mvc, e->e_id, anew);
+ if (err)
+ goto mval_fail;
} else if (anew) {
/* revert back to normal attr */
anew->a_flags &= ~SLAP_ATTR_BIG_MULTI;