]> git.sur5r.net Git - openldap/commitdiff
Disable removal of subtree indices upon delete. This allows
authorKurt Zeilenga <kurt@openldap.org>
Thu, 26 Aug 1999 22:43:08 +0000 (22:43 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 26 Aug 1999 22:43:08 +0000 (22:43 +0000)
modrdn to run,  but masks the underlying subtree index bug (which
I haven't found yet).
Apply modrdn/dn2id changes to BDB2.

servers/slapd/back-bdb2/add.c
servers/slapd/back-bdb2/delete.c
servers/slapd/back-bdb2/dn2id.c
servers/slapd/back-bdb2/modrdn.c
servers/slapd/back-bdb2/proto-back-bdb2.h
servers/slapd/back-bdb2/tools.c
servers/slapd/back-ldbm/dn2id.c

index 7324cc2e137b25ce3428b848d72093d9f5f7bde7..3bca6e99c5636f733cf048e682c093cee09eddda 100644 (file)
@@ -243,7 +243,7 @@ bdb2i_back_add_internal(
        if ( bdb2i_id2entry_add( be, e ) != 0 ) {
                Debug( LDAP_DEBUG_TRACE, "bdb2i_id2entry_add failed\n", 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,
                        NULL, NULL, NULL, NULL );
 
index d80d2dceb2bf1482ccd7624b873d22289e20a690..898c36b6176bf8582f4f53c50ad800c06321f873 100644 (file)
@@ -126,7 +126,7 @@ bdb2i_back_delete_internal(
        }
 
        /* 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,
                        "<=- bdb2i_back_delete: operations error %s\n",
                        dn, 0, 0);
index 0d49a099dd912e63e21f3c31a597d00ce5f5c7e2..c4cb4e845896c0a83480a880e89072e81005defa 100644 (file)
@@ -178,14 +178,16 @@ bdb2i_dn2idl(
 int
 bdb2i_dn2id_delete(
     BackendDB  *be,
-    const char *dn
+    const char *dn,
+       ID id
 )
 {
        struct dbcache  *db;
        Datum           key;
        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 ))
            == NULL ) {
@@ -195,6 +197,42 @@ bdb2i_dn2id_delete(
                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 );
 
        key.dsize = strlen( dn ) + 2;
index 4460c06cdda30904d1fabd39cbe66bd4c812103c..e6e003b793282bc29ffe4174148b43e2a4ac110e 100644 (file)
@@ -225,12 +225,6 @@ bdb2i_back_modrdn_internal(
        Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: new ndn=%s\n",
               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 */
        ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
        if ( op->o_abandon ) {
@@ -239,23 +233,8 @@ bdb2i_back_modrdn_internal(
        }
        ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
 
-       /* delete old one */
-       if ( bdb2i_dn2id_delete( be, e->e_ndn ) != 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;
-
-
-       /* add new one */
-       if ( bdb2i_dn2id_add( be,  e->e_ndn, e->e_id ) != 0 ) {
-               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+       if ( (bdb2i_dn2id ( be, new_ndn ) ) != NOID ) {
+               send_ldap_result( conn, op, LDAP_ALREADY_EXISTS,
                        NULL, NULL, NULL, NULL );
                goto return_results;
        }
@@ -401,6 +380,37 @@ bdb2i_back_modrdn_internal(
        }
 #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 */
        if ( bdb2i_back_modify_internal( be, conn, op, dn, &mod[0], e )
             != 0 ) {
@@ -420,19 +430,17 @@ bdb2i_back_modrdn_internal(
                entry_free( e );
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
                        NULL, NULL, NULL, NULL );
-               goto return_results_after;
+               goto return_results;
        }
 
        send_ldap_result( conn, op, LDAP_SUCCESS,
                NULL, NULL, NULL, NULL );
        rc = 0;
-       goto return_results_after;      
 
 return_results:
        if( new_dn != NULL ) free( new_dn );
        if( new_ndn != NULL ) free( new_ndn );
 
-return_results_after:
        /* NOTE:
         * new_dn and new_ndn are not deallocated because they are used by
         * the cache entry.
index d2c18a64545a79b658de6b9c49870f7a6e7889fb..4b7d6e8674455bb7d72cc313077a7e4babb3662b 100644 (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 ));
 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 *
 bdb2i_dn2idl LDAP_P((
index 66b018a03a079ff20df3b23cafff1bdaff0b0290..ba9c939ee4cb3ac6351dddbd3ea2a4d30d48e085 100644 (file)
@@ -184,7 +184,7 @@ ID bdb2_tool_entry_put(
        rc = bdb2i_cache_store( id2entry, key, data, LDBM_REPLACE );
 
        if( rc != 0 ) {
-               (void) bdb2i_dn2id_delete( be, e->e_ndn );
+               (void) bdb2i_dn2id_delete( be, e->e_ndn, e->e_id );
                return NOID;
        }
 
index ca3a2803dc1a878ddbc9fbc21fc16b01263f1ce3..9a1d4f2ccc163567c7797fc0c94b2504acaf9720 100644 (file)
@@ -226,6 +226,7 @@ dn2id_delete(
                }
        }
 
+#if 0
        {
                char **subtree = dn_subtree( NULL, dn );
 
@@ -246,6 +247,7 @@ dn2id_delete(
                        charray_free( subtree );
                }
        }
+#endif
 
        ldbm_datum_init( key );