From: Howard Chu Date: Sun, 18 Sep 2011 21:47:41 +0000 (-0700) Subject: Fix prev commit X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c0fc7fdbed69e685560f7860e0895a731f72da64;p=openldap Fix prev commit Don't truncate all indices if specific indices were given. --- diff --git a/servers/slapd/back-mdb/attr.c b/servers/slapd/back-mdb/attr.c index 842456c5f1..14e67d884e 100644 --- a/servers/slapd/back-mdb/attr.c +++ b/servers/slapd/back-mdb/attr.c @@ -133,20 +133,6 @@ mdb_attr_dbs_open( cr->msg, 0, 0 ); break; } - if (slapMode & SLAP_TRUNCATE_MODE) { - rc = mdb_drop( txn, mdb->mi_attrs[i]->ai_dbi, 0 ); - if ( rc ) { - snprintf( cr->msg, sizeof(cr->msg), "database \"%s\": " - "mdb_drop(%s) failed: %s (%d).", - be->be_suffix[0].bv_val, - mdb->mi_attrs[i]->ai_desc->ad_type->sat_cname.bv_val, - mdb_strerror(rc), rc ); - Debug( LDAP_DEBUG_ANY, - LDAP_XSTRING(mdb_attr_dbs) ": %s\n", - cr->msg, 0, 0 ); - break; - } - } } /* Only commit if this is our txn */ diff --git a/servers/slapd/back-mdb/tools.c b/servers/slapd/back-mdb/tools.c index 1d2c625ad8..c1ccfd518e 100644 --- a/servers/slapd/back-mdb/tools.c +++ b/servers/slapd/back-mdb/tools.c @@ -689,6 +689,22 @@ int mdb_tool_entry_reindex( mi->mi_nattrs = i; } + if ( slapMode & SLAP_TRUNCATE_MODE ) { + int i; + for ( i=0; i < mi->mi_nattrs; i++ ) { + rc = mdb_drop( txn, mi->mi_attrs[i]->ai_dbi, 0 ); + if ( rc ) { + Debug( LDAP_DEBUG_ANY, + LDAP_XSTRING(mdb_tool_entry_reindex) + ": (Truncate) mdb_drop(%s) failed: %s (%d)\n", + mi->mi_attrs[i]->ai_desc->ad_type->sat_cname.bv_val, + mdb_strerror(rc), rc ); + return -1; + } + } + slapMode ^= SLAP_TRUNCATE_MODE; + } + e = mdb_tool_entry_get( be, id ); if( e == NULL ) {