Commit 8300eee0 authored by Howard Chu's avatar Howard Chu
Browse files

back-mdb Multival fixes

Fix multival logic on Replace
Fix return codes from modify_internal, id2entry_put
parent 08851a82
......@@ -307,18 +307,23 @@ again:
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) {
......
......@@ -183,8 +183,11 @@ do_add:
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 ) {
......@@ -199,6 +202,8 @@ do_add:
if (anew->a_nvals == anew->a_vals)
anew->a_nvals = NULL;
}
if ( err )
goto mval_fail;
}
}
break;
......@@ -237,7 +242,7 @@ do_del:
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 );
......@@ -259,6 +264,8 @@ do_del:
anew->a_numvals = 0;
}
err = mdb_mval_del( op, mvc, e->e_id, anew );
if ( err )
goto mval_fail;
}
}
break;
......@@ -279,7 +286,7 @@ do_del:
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;
......@@ -287,17 +294,19 @@ do_del:
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;
......
Supports Markdown
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