From a88bf50b31ddd14abf799134e4cdd2507b079cb7 Mon Sep 17 00:00:00 2001 From: Juan Gomez Date: Tue, 20 Apr 1999 03:36:00 +0000 Subject: [PATCH] Updates index for rdn attribute type avoiding the 'dissapearing entry' problem reported in IT78. Index files will still be stale if the modrdn uses deleteoldrdn. --- servers/slapd/back-bdb2/modrdn.c | 4 ++++ servers/slapd/back-ldbm/modrdn.c | 23 +++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/servers/slapd/back-bdb2/modrdn.c b/servers/slapd/back-bdb2/modrdn.c index e969818c9c..d906e08866 100644 --- a/servers/slapd/back-bdb2/modrdn.c +++ b/servers/slapd/back-bdb2/modrdn.c @@ -362,6 +362,10 @@ bdb2i_back_modrdn_internal( attr_merge( e, new_rdn_type, bvals ); + /* Update new_rdn_type if it is an index */ + + bdb2i_index_add_values( be, new_rdn_type, bvals, e->e_id ); + } else { diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index 4465ebd9a2..21b48e2002 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -223,12 +223,6 @@ ldbm_back_modrdn( } ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); - /* add new one */ - if ( dn2id_add( be, new_ndn, e->e_id ) != 0 ) { - send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL ); - goto return_results; - } - /* delete old one */ if ( dn2id_delete( be, e->e_ndn ) != 0 ) { send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL ); @@ -241,6 +235,14 @@ ldbm_back_modrdn( e->e_dn = new_dn; e->e_ndn = new_ndn; + /* add new one */ + if ( dn2id_add( be, e->e_ndn, e->e_id ) != 0 ) { + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL ); + goto return_results; + } + + + /* Get attribute type and attribute value of our new rdn, we will * need to add that to our new entry */ @@ -266,7 +268,7 @@ ldbm_back_modrdn( } Debug( LDAP_DEBUG_TRACE, - "ldbm_back_modrdn: new_rdn_val=%s, new_rdn_type=%s\n", + "ldbm_back_modrdn: new_rdn_val=\"%s\", new_rdn_type=\"%s\"\n", new_rdn_val, new_rdn_type, 0 ); /* Retrieve the old rdn from the entry's dn */ @@ -307,6 +309,7 @@ ldbm_back_modrdn( bvals[0] = &bv; /* Array of bervals */ bvals[1] = NULL; + /* Remove old rdn value if required */ @@ -373,12 +376,16 @@ ldbm_back_modrdn( Debug( LDAP_DEBUG_TRACE, - "ldbm_back_modrdn: adding new rdn attr val =%s\n", + "ldbm_back_modrdn: adding new rdn attr val =\"%s\"\n", new_rdn_val, 0, 0 ); /* No need to normalize new_rdn_type, attr_merge does it */ attr_merge( e, new_rdn_type, bvals ); + + /* Update new_rdn_type if it is an index */ + + index_add_values( be, new_rdn_type, bvals, e->e_id ); } else { -- 2.39.5