]> git.sur5r.net Git - openldap/commitdiff
another round replacing dn_parent ...
authorPierangelo Masarati <ando@openldap.org>
Thu, 17 Jan 2002 19:58:19 +0000 (19:58 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 17 Jan 2002 19:58:19 +0000 (19:58 +0000)
servers/slapd/back-bdb/tools.c

index a131ab0b45fe189504113762f112d01194940e9e..ef9219e22d8a8c9404176c50a26fd6ce9580e761 100644 (file)
@@ -155,11 +155,20 @@ ID bdb_tool_entry_put(
        }
 
        /* add dn2id indices */
-       pdn.bv_val = dn_parent( be, e->e_ndn );
-       if (pdn.bv_val && *pdn.bv_val)
-               pdn.bv_len = e->e_nname.bv_len - (pdn.bv_val - e->e_ndn);
-       else
+       if ( be_issuffix( be, e->e_nname.bv_val ) ) {
                pdn.bv_len = 0;
+               pdn.bv_val = "";
+       } else {
+               rc = dnParent( e->e_nname.bv_val, &pdn.bv_val );
+               if ( rc != LDAP_SUCCESS ) {
+                       Debug( LDAP_DEBUG_ANY, "=> bdb_tool_entry_put: "
+                               "dnParent(\"%s\") failed\n",
+                               e->e_nname.bv_val, 0, 0 );
+                       
+                       goto done;
+               }
+               pdn.bv_len = e->e_nname.bv_len - (pdn.bv_val - e->e_nname.bv_val);
+       }
        rc = bdb_dn2id_add( be, tid, &pdn, e );
        if( rc != 0 ) {
                snprintf( text->bv_val, text->bv_len, 
@@ -263,11 +272,19 @@ int bdb_tool_entry_reindex(
                (long) id, e->e_dn, 0 );
 
        /* add dn2id indices */
-       pdn.bv_val = dn_parent( be, e->e_ndn );
-       if (pdn.bv_val && *pdn.bv_val)
-               pdn.bv_len = e->e_nname.bv_len - (pdn.bv_val - e->e_ndn);
-       else
+       if ( be_issuffix( be, e->e_nname.bv_val ) ) {
                pdn.bv_len = 0;
+               pdn.bv_val = "";
+       } else {
+               rc = dnParent( e->e_nname.bv_val, &pdn.bv_val );
+               if ( rc != LDAP_SUCCESS ) {
+                       Debug( LDAP_DEBUG_ANY, "=> bdb_tool_entry_reindex: "
+                                       "dnParent(\"%s\") failed\n",
+                                       e->e_nname.bv_val, 0, 0 );
+                       goto done;
+               }
+               pdn.bv_len = e->e_nname.bv_len - (pdn.bv_val - e->e_nname.bv_val);
+       }
        rc = bdb_dn2id_add( be, tid, &pdn, e );
        if( rc != 0 && rc != DB_KEYEXIST ) {
                Debug( LDAP_DEBUG_ANY,