Disable removal of subtree indices upon delete. This allows

modrdn to run,  but masks the underlying subtree index bug (which
I haven't found yet).
Apply modrdn/dn2id changes to BDB2.
This commit is contained in:
Kurt Zeilenga 1999-08-26 22:43:08 +00:00
parent 4c19272651
commit 03ea068193
7 changed files with 80 additions and 32 deletions

View file

@ -243,7 +243,7 @@ bdb2i_back_add_internal(
if ( bdb2i_id2entry_add( be, e ) != 0 ) { if ( bdb2i_id2entry_add( be, e ) != 0 ) {
Debug( LDAP_DEBUG_TRACE, "bdb2i_id2entry_add failed\n", 0, Debug( LDAP_DEBUG_TRACE, "bdb2i_id2entry_add failed\n", 0,
0, 0 ); 0, 0 );
(void) bdb2i_dn2id_delete( be, e->e_ndn ); (void) bdb2i_dn2id_delete( be, e->e_ndn, e->e_id );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, NULL, NULL, NULL ); NULL, NULL, NULL, NULL );

View file

@ -126,7 +126,7 @@ bdb2i_back_delete_internal(
} }
/* delete from dn2id mapping */ /* delete from dn2id mapping */
if ( bdb2i_dn2id_delete( be, e->e_ndn ) != 0 ) { if ( bdb2i_dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) {
Debug(LDAP_DEBUG_ARGS, Debug(LDAP_DEBUG_ARGS,
"<=- bdb2i_back_delete: operations error %s\n", "<=- bdb2i_back_delete: operations error %s\n",
dn, 0, 0); dn, 0, 0);

View file

@ -178,14 +178,16 @@ bdb2i_dn2idl(
int int
bdb2i_dn2id_delete( bdb2i_dn2id_delete(
BackendDB *be, BackendDB *be,
const char *dn const char *dn,
ID id
) )
{ {
struct dbcache *db; struct dbcache *db;
Datum key; Datum key;
int rc; int rc;
Debug( LDAP_DEBUG_TRACE, "=> bdb2i_dn2id_delete( \"%s\" )\n", dn, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "=> bdb2i_dn2id_delete( \"%s\", %ld )\n",
dn, id, 0 );
if ( (db = bdb2i_cache_open( be, "dn2id", BDB2_SUFFIX, LDBM_WRCREAT )) if ( (db = bdb2i_cache_open( be, "dn2id", BDB2_SUFFIX, LDBM_WRCREAT ))
== NULL ) { == NULL ) {
@ -195,6 +197,42 @@ bdb2i_dn2id_delete(
return( -1 ); return( -1 );
} }
{
char *pdn = dn_parent( NULL, dn );
if( pdn != NULL ) {
ldbm_datum_init( key );
key.dsize = strlen( pdn ) + 2;
key.dptr = ch_malloc( key.dsize );
sprintf( key.dptr, "%c%s", DN_ONE_PREFIX, pdn );
(void) bdb2i_idl_delete_key( be, db, key, id );
free( key.dptr );
free( pdn );
}
}
#if 0
{
char **subtree = dn_subtree( NULL, dn );
if( subtree != NULL ) {
int i;
for( i=0; subtree[i] != NULL; i++ ) {
ldbm_datum_init( key );
key.dsize = strlen( subtree[i] ) + 2;
key.dptr = ch_malloc( key.dsize );
sprintf( key.dptr, "%c%s", DN_SUBTREE_PREFIX, subtree[i] );
(void) bdb2i_idl_delete_key( be, db, key, id );
free( key.dptr );
}
charray_free( subtree );
}
}
#endif
ldbm_datum_init( key ); ldbm_datum_init( key );
key.dsize = strlen( dn ) + 2; key.dsize = strlen( dn ) + 2;

View file

@ -225,12 +225,6 @@ bdb2i_back_modrdn_internal(
Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: new ndn=%s\n", Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: new ndn=%s\n",
new_ndn, 0, 0 ); new_ndn, 0, 0 );
if ( (bdb2i_dn2id ( be, new_ndn ) ) != NOID ) {
send_ldap_result( conn, op, LDAP_ALREADY_EXISTS,
NULL, NULL, NULL, NULL );
goto return_results;
}
/* check for abandon */ /* check for abandon */
ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
if ( op->o_abandon ) { if ( op->o_abandon ) {
@ -239,23 +233,8 @@ bdb2i_back_modrdn_internal(
} }
ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
/* delete old one */ if ( (bdb2i_dn2id ( be, new_ndn ) ) != NOID ) {
if ( bdb2i_dn2id_delete( be, e->e_ndn ) != 0 ) { send_ldap_result( conn, op, LDAP_ALREADY_EXISTS,
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, NULL, NULL, NULL );
goto return_results;
}
(void) bdb2i_cache_delete_entry( &li->li_cache, e );
free( e->e_dn );
free( e->e_ndn );
e->e_dn = new_dn;
e->e_ndn = new_ndn;
/* add new one */
if ( bdb2i_dn2id_add( be, e->e_ndn, e->e_id ) != 0 ) {
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, NULL, NULL, NULL ); NULL, NULL, NULL, NULL );
goto return_results; goto return_results;
} }
@ -401,6 +380,37 @@ bdb2i_back_modrdn_internal(
} }
#endif #endif
/* check for abandon */
ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
if ( op->o_abandon ) {
ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
goto return_results;
}
ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
/* delete old one */
if ( bdb2i_dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) {
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, NULL, NULL, NULL );
goto return_results;
}
(void) bdb2i_cache_delete_entry( &li->li_cache, e );
free( e->e_dn );
free( e->e_ndn );
e->e_dn = new_dn;
e->e_ndn = new_ndn;
new_dn = NULL;
new_ndn = NULL;
/* add new one */
if ( bdb2i_dn2id_add( be, e->e_ndn, e->e_id ) != 0 ) {
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, NULL, NULL, NULL );
goto return_results;
}
/* modify memory copy of entry */ /* modify memory copy of entry */
if ( bdb2i_back_modify_internal( be, conn, op, dn, &mod[0], e ) if ( bdb2i_back_modify_internal( be, conn, op, dn, &mod[0], e )
!= 0 ) { != 0 ) {
@ -420,19 +430,17 @@ bdb2i_back_modrdn_internal(
entry_free( e ); entry_free( e );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, NULL, NULL, NULL ); NULL, NULL, NULL, NULL );
goto return_results_after; goto return_results;
} }
send_ldap_result( conn, op, LDAP_SUCCESS, send_ldap_result( conn, op, LDAP_SUCCESS,
NULL, NULL, NULL, NULL ); NULL, NULL, NULL, NULL );
rc = 0; rc = 0;
goto return_results_after;
return_results: return_results:
if( new_dn != NULL ) free( new_dn ); if( new_dn != NULL ) free( new_dn );
if( new_ndn != NULL ) free( new_ndn ); if( new_ndn != NULL ) free( new_ndn );
return_results_after:
/* NOTE: /* NOTE:
* new_dn and new_ndn are not deallocated because they are used by * new_dn and new_ndn are not deallocated because they are used by
* the cache entry. * the cache entry.

View file

@ -76,7 +76,7 @@ int bdb2i_cache_delete LDAP_P(( struct dbcache *db, Datum key ));
int bdb2i_dn2id_add LDAP_P(( BackendDB *be, const char *dn, ID id )); int bdb2i_dn2id_add LDAP_P(( BackendDB *be, const char *dn, ID id ));
ID bdb2i_dn2id LDAP_P(( BackendDB *be, const char *dn )); ID bdb2i_dn2id LDAP_P(( BackendDB *be, const char *dn ));
int bdb2i_dn2id_delete LDAP_P(( BackendDB *be, const char *dn )); int bdb2i_dn2id_delete LDAP_P(( BackendDB *be, const char *dn, ID id ));
ID_BLOCK * ID_BLOCK *
bdb2i_dn2idl LDAP_P(( bdb2i_dn2idl LDAP_P((

View file

@ -184,7 +184,7 @@ ID bdb2_tool_entry_put(
rc = bdb2i_cache_store( id2entry, key, data, LDBM_REPLACE ); rc = bdb2i_cache_store( id2entry, key, data, LDBM_REPLACE );
if( rc != 0 ) { if( rc != 0 ) {
(void) bdb2i_dn2id_delete( be, e->e_ndn ); (void) bdb2i_dn2id_delete( be, e->e_ndn, e->e_id );
return NOID; return NOID;
} }

View file

@ -226,6 +226,7 @@ dn2id_delete(
} }
} }
#if 0
{ {
char **subtree = dn_subtree( NULL, dn ); char **subtree = dn_subtree( NULL, dn );
@ -246,6 +247,7 @@ dn2id_delete(
charray_free( subtree ); charray_free( subtree );
} }
} }
#endif
ldbm_datum_init( key ); ldbm_datum_init( key );