1 /* modrdn.c - bdb backend modrdn routine */
4 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 #include <ac/string.h>
23 struct berval *newrdn,
24 struct berval *nnewrdn,
26 struct berval *newSuperior,
27 struct berval *nnewSuperior )
29 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
30 AttributeDescription *children = slap_schema.si_ad_children;
31 struct berval p_dn, p_ndn;
32 struct berval new_dn = {0, NULL}, new_ndn = {0, NULL};
39 char textbuf[SLAP_TEXT_BUFLEN];
40 size_t textlen = sizeof textbuf;
42 struct bdb_op_info opinfo;
46 LDAPRDN *new_rdn = NULL;
47 LDAPRDN *old_rdn = NULL;
49 Entry *np = NULL; /* newSuperior Entry */
50 struct berval *np_dn = NULL; /* newSuperior dn */
51 struct berval *np_ndn = NULL; /* newSuperior ndn */
52 struct berval *new_parent_dn = NULL; /* np_dn, p_dn, or NULL */
54 /* Used to interface with bdb_modify_internal() */
55 Modifications *mod = NULL; /* Used to delete old rdn */
57 int manageDSAit = get_manageDSAit( op );
63 LDAP_LOG (( "modrdn", LDAP_LEVEL_ENTRY, "==>bdb_modrdn(%s,%s,%s)\n",
64 dn->bv_val,newrdn->bv_val,
65 newSuperior ? newSuperior->bv_val : "NULL" ));
67 Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn(%s,%s,%s)\n",
68 dn->bv_val, newrdn->bv_val,
69 newSuperior ? newSuperior->bv_val : "NULL" );
73 if( newSuperior != NULL ) {
74 rc = LDAP_UNWILLING_TO_PERFORM;
75 text = "newSuperior not implemented (yet)";
81 retry: /* transaction retry */
83 bdb_cache_delete_entry(&bdb->bi_cache, e);
84 bdb_cache_return_entry_w(bdb->bi_dbenv, &bdb->bi_cache, e, &lock);
87 bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, p, &lock);
90 bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, np, &lock);
93 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: retrying...\n"));
95 Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn: retrying...\n", 0, 0, 0 );
97 rc = TXN_ABORT( ltid );
102 text = "internal error";
105 ldap_pvt_thread_yield();
108 /* begin transaction */
109 rc = TXN_BEGIN( bdb->bi_dbenv, NULL, <id,
110 bdb->bi_db_opflags );
114 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "==>bdb_modrdn: txn_begin failed: %s (%d)\n", db_strerror(rc), rc ));
116 Debug( LDAP_DEBUG_TRACE,
117 "bdb_delete: txn_begin failed: %s (%d)\n",
118 db_strerror(rc), rc, 0 );
121 text = "internal error";
125 locker = TXN_ID ( ltid );
128 opinfo.boi_txn = ltid;
130 op->o_private = &opinfo;
133 rc = bdb_dn2entry_w( be, ltid, ndn, &e, &matched, 0, locker, &lock );
139 case DB_LOCK_DEADLOCK:
140 case DB_LOCK_NOTGRANTED:
143 text = "ldap server busy";
147 text = "internal error";
152 char* matched_dn = NULL;
155 if( matched != NULL ) {
156 matched_dn = ch_strdup( matched->e_dn );
157 refs = is_entry_referral( matched )
158 ? get_entry_referrals( be, conn, op, matched )
160 bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache, matched, &lock );
164 refs = referral_rewrite( default_referral,
165 NULL, dn, LDAP_SCOPE_DEFAULT );
168 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
169 matched_dn, NULL, refs, NULL );
171 ber_bvarray_free( refs );
177 if (!manageDSAit && is_entry_referral( e ) ) {
178 /* parent is a referral, don't allow add */
179 /* parent is an alias, don't allow add */
180 BerVarray refs = get_entry_referrals( be,
184 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: entry %s is referral \n", e->e_dn ));
186 Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry %s is referral\n",
190 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
191 e->e_dn, NULL, refs, NULL );
193 ber_bvarray_free( refs );
197 if ( be_issuffix( be, &e->e_nname ) ) {
198 p_ndn = slap_empty_bv;
200 dnParent( &e->e_nname, &p_ndn );
203 if ( p_ndn.bv_len != 0 ) {
204 /* Make sure parent entry exist and we can write its
207 rc = bdb_dn2entry_r( be, ltid, &p_ndn, &p, NULL, 0, locker, &lock );
213 case DB_LOCK_DEADLOCK:
214 case DB_LOCK_NOTGRANTED:
217 text = "ldap server busy";
221 text = "internal error";
227 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "==>bdb_modrdn: parent does not exist\n" ));
229 Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: parent does not exist\n",
236 /* check parent for "children" acl */
237 if ( ! access_allowed( be, conn, op, p,
238 children, NULL, ACL_WRITE, NULL ) )
241 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "==>bdb_modrdn: no access to parent\n" ));
243 Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0,
246 send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
247 NULL, NULL, NULL, NULL );
252 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: wr to children %s is OK\n", p_ndn.bv_val ));
254 Debug( LDAP_DEBUG_TRACE,
255 "bdb_modrdn: wr to children of entry %s OK\n",
256 p_ndn.bv_val, 0, 0 );
259 if ( p_ndn.bv_val == slap_empty_bv.bv_val ) {
260 p_dn = slap_empty_bv;
262 dnParent( &e->e_name, &p_dn );
266 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: parent dn=%s\n", p_dn.bv_val ));
268 Debug( LDAP_DEBUG_TRACE,
269 "bdb_modrdn: parent dn=%s\n",
274 /* no parent, modrdn entry directly under root */
275 isroot = be_isroot( be, &op->o_ndn );
277 if ( be_issuffix( be, (struct berval *)&slap_empty_bv )
278 || be_isupdate( be, &op->o_ndn ) ) {
280 p = (Entry *)&slap_entry_root;
282 /* check parent for "children" acl */
283 rc = access_allowed( be, conn, op, p,
284 children, NULL, ACL_WRITE, NULL );
291 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "==>bdb_modrdn: no access to parent\n" ));
293 Debug( LDAP_DEBUG_TRACE,
294 "no access to parent\n",
297 send_ldap_result( conn, op,
298 LDAP_INSUFFICIENT_ACCESS,
299 NULL, NULL, NULL, NULL );
304 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: wr to children of entry \"\" OK\n", p_dn.bv_val ));
306 Debug( LDAP_DEBUG_TRACE,
307 "bdb_modrdn: wr to children of entry \"\" OK\n",
315 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: parent dn=\"\" \n" ));
317 Debug( LDAP_DEBUG_TRACE,
318 "bdb_modrdn: parent dn=\"\"\n",
324 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "==>bdb_modrdn: no parent, not root &\"\" is not suffix\n" ));
326 Debug( LDAP_DEBUG_TRACE,
327 "bdb_modrdn: no parent, not root "
328 "& \"\" is not suffix\n",
331 rc = LDAP_INSUFFICIENT_ACCESS;
337 new_parent_dn = &p_dn; /* New Parent unless newSuperior given */
339 if ( newSuperior != NULL ) {
341 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: new parent \"%s\" requested...\n", newSuperior->bv_val ));
343 Debug( LDAP_DEBUG_TRACE,
344 "bdb_modrdn: new parent \"%s\" requested...\n",
345 newSuperior->bv_val, 0, 0 );
348 if ( newSuperior->bv_len ) {
350 np_ndn = nnewSuperior;
352 /* newSuperior == oldParent?, if so ==> ERROR */
353 /* newSuperior == entry being moved?, if so ==> ERROR */
354 /* Get Entry with dn=newSuperior. Does newSuperior exist? */
356 rc = bdb_dn2entry_r( be, ltid, nnewSuperior, &np, NULL, 0, locker, &lock );
362 case DB_LOCK_DEADLOCK:
363 case DB_LOCK_NOTGRANTED:
366 text = "ldap server busy";
370 text = "internal error";
376 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: newSup(ndn=%s) not here!\n", np_ndn->bv_val ));
378 Debug( LDAP_DEBUG_TRACE,
379 "bdb_modrdn: newSup(ndn=%s) not here!\n",
380 np_ndn->bv_val, 0, 0);
387 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: wr to new parent OK np=%p, id=%ld\n", np, (long) np->e_id ));
389 Debug( LDAP_DEBUG_TRACE,
390 "bdb_modrdn: wr to new parent OK np=%p, id=%ld\n",
391 np, (long) np->e_id, 0 );
394 /* check newSuperior for "children" acl */
395 if ( !access_allowed( be, conn, op, np, children, NULL, ACL_WRITE, NULL ) ) {
397 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: no wr to newSup children\n" ));
399 Debug( LDAP_DEBUG_TRACE,
400 "bdb_modrdn: no wr to newSup children\n",
403 rc = LDAP_INSUFFICIENT_ACCESS;
408 if ( is_entry_alias( np ) ) {
409 /* parent is an alias, don't allow add */
411 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: entry is alias\n" ));
413 Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry is alias\n",
417 rc = LDAP_ALIAS_PROBLEM;
422 if ( is_entry_referral( np ) ) {
423 /* parent is a referral, don't allow add */
425 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "==>bdb_modrdn: entry is referral\n" ));
427 Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry is referral\n",
431 rc = LDAP_OPERATIONS_ERROR;
436 if ( isroot == -1 ) {
437 isroot = be_isroot( be, &op->o_ndn );
442 /* no parent, modrdn entry directly under root */
444 if ( be_issuffix( be, (struct berval *)&slap_empty_bv )
445 || be_isupdate( be, &op->o_ndn ) ) {
446 np = (Entry *)&slap_entry_root;
448 /* check parent for "children" acl */
449 rc = access_allowed( be, conn, op, np,
450 children, NULL, ACL_WRITE, NULL );
457 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "==>bdb_modrdn: no access to superior\n" ));
459 Debug( LDAP_DEBUG_TRACE,
460 "no access to new superior\n",
463 send_ldap_result( conn, op,
464 LDAP_INSUFFICIENT_ACCESS,
465 NULL, NULL, NULL, NULL );
470 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "bdb_modrdn: wr to children entry \"\" OK\n" ));
472 Debug( LDAP_DEBUG_TRACE,
473 "bdb_modrdn: wr to children of entry \"\" OK\n",
479 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: new superior=\"\", not root & \"\" is not suffix\n" ));
481 Debug( LDAP_DEBUG_TRACE,
482 "bdb_modrdn: new superior=\"\", not root "
483 "& \"\" is not suffix\n",
486 rc = LDAP_INSUFFICIENT_ACCESS;
492 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "bdb_modrdn: new superior=\"\"\n" ));
494 Debug( LDAP_DEBUG_TRACE,
495 "bdb_modrdn: new superior=\"\"\n",
501 LDAP_LOG (( "modrdn", LDAP_LEVEL_DETAIL1, "bdb_modrdn: wr to new parent's children OK\n" ));
503 Debug( LDAP_DEBUG_TRACE,
504 "bdb_modrdn: wr to new parent's children OK\n",
508 new_parent_dn = np_dn;
511 /* Build target dn and make sure target entry doesn't exist already. */
512 build_new_dn( &new_dn, new_parent_dn, newrdn );
514 dnNormalize2( NULL, &new_dn, &new_ndn );
517 LDAP_LOG (( "modrdn", LDAP_LEVEL_RESULTS, "bdb_modrdn: new ndn=%s\n", new_ndn.bv_val ));
519 Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: new ndn=%s\n",
520 new_ndn.bv_val, 0, 0 );
523 rc = bdb_dn2id ( be, ltid, &new_ndn, &id );
525 case DB_LOCK_DEADLOCK:
526 case DB_LOCK_NOTGRANTED:
531 rc = LDAP_ALREADY_EXISTS;
535 text = "internal error";
540 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: new ndn=%s does not exist\n", new_ndn.bv_val ));
542 Debug( LDAP_DEBUG_TRACE,
543 "bdb_modrdn: new ndn=%s does not exist\n",
544 new_ndn.bv_val, 0, 0 );
547 /* Get attribute type and attribute value of our new rdn, we will
548 * need to add that to our new entry
550 if ( ldap_bv2rdn( newrdn, &new_rdn, (char **)&text,
551 LDAP_DN_FORMAT_LDAP ) )
554 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: can't figure out type(s)/values(s) of newrdn\n" ));
556 Debug( LDAP_DEBUG_TRACE,
557 "bdb_modrdn: can't figure out type(s)/values(s) "
558 "of newrdn\n", 0, 0, 0 );
560 rc = LDAP_OPERATIONS_ERROR;
561 text = "unknown type(s) used in RDN";
566 LDAP_LOG (( "modrdn", LDAP_LEVEL_RESULTS, "bdb_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n", new_rdn[0][0]->la_attr.bv_val, new_rdn[0][0]->la_value.bv_val ));
568 Debug( LDAP_DEBUG_TRACE,
569 "bdb_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n",
570 new_rdn[0][0]->la_attr.bv_val, new_rdn[0][0]->la_value.bv_val, 0 );
573 if ( ldap_bv2rdn( dn, &old_rdn, (char **)&text,
574 LDAP_DN_FORMAT_LDAP ) )
577 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: can't figure out type(s)/values(s) of old_rdn\n" ));
579 Debug( LDAP_DEBUG_TRACE,
580 "bdb_back_modrdn: can't figure out the old_rdn "
581 "type(s)/value(s)\n", 0, 0, 0 );
584 text = "cannot parse RDN from old DN";
589 if ( newSuperior == NULL
590 && charray_strcasecmp( ( const char ** )old_rdn_types,
591 ( const char ** )new_rdn_types ) != 0 ) {
592 /* Not a big deal but we may say something */
594 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: old_rdn_type(s)=%s, new_rdn_type(s)=%s do not match\n", old_rdn_types[ 0 ], new_rdn_types[ 0 ] ));
596 Debug( LDAP_DEBUG_TRACE,
597 "bdb_modrdn: old_rdn_type(s)=%s, new_rdn_type(s)=%s "
599 old_rdn_types[ 0 ], new_rdn_types[ 0 ], 0 );
604 /* Add new attribute values to the entry */
605 for ( a_cnt = 0; new_rdn[0][ a_cnt ]; a_cnt++ ) {
607 AttributeDescription *desc = NULL;
608 Modifications *mod_tmp;
610 rc = slap_bv2ad( &new_rdn[0][ a_cnt ]->la_attr, &desc, &text );
612 if ( rc != LDAP_SUCCESS ) {
614 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: %s: %s (new)\n", text, new_rdn[0][a_cnt]->la_attr.bv_val ));
616 Debug( LDAP_DEBUG_TRACE,
617 "bdb_modrdn: %s: %s (new)\n",
618 text, new_rdn[0][ a_cnt ]->la_attr.bv_val, 0 );
623 /* ACL check of newly added attrs */
624 if ( !access_allowed( be, conn, op, e, desc,
625 &new_rdn[0][ a_cnt ]->la_value, ACL_WRITE, NULL ) ) {
627 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: access to attr \"%s\" (new) not allowed\n", new_rdn[0][a_cnt]->la_attr.bv_val ));
629 Debug( LDAP_DEBUG_TRACE,
630 "bdb_modrdn: access to attr \"%s\" "
631 "(new) not allowed\n",
632 new_rdn[0][ a_cnt ]->la_attr.bv_val, 0, 0 );
634 rc = LDAP_INSUFFICIENT_ACCESS;
638 /* Apply modification */
639 mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
640 + 2 * sizeof( struct berval ) );
641 mod_tmp->sml_desc = desc;
642 mod_tmp->sml_bvalues = ( BerVarray )( mod_tmp + 1 );
643 mod_tmp->sml_bvalues[ 0 ] = new_rdn[0][ a_cnt ]->la_value;
644 mod_tmp->sml_bvalues[ 1 ].bv_val = NULL;
645 mod_tmp->sml_op = SLAP_MOD_SOFTADD;
646 mod_tmp->sml_next = mod;
650 /* Remove old rdn value if required */
651 if ( deleteoldrdn ) {
652 /* Get value of old rdn */
653 if ( old_rdn == NULL) {
655 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: can't figure out old RDN values(s) from old RDN\n" ));
657 Debug( LDAP_DEBUG_TRACE,
658 "bdb_modrdn: can't figure out old RDN value(s) "
659 "from old RDN\n", 0, 0, 0 );
662 text = "could not parse value(s) from old RDN";
666 for ( d_cnt = 0; old_rdn[0][ d_cnt ]; d_cnt++ ) {
668 AttributeDescription *desc = NULL;
669 Modifications *mod_tmp;
671 rc = slap_bv2ad( &old_rdn[0][ d_cnt ]->la_attr,
674 if ( rc != LDAP_SUCCESS ) {
676 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: %s: %s (old)\n", text, old_rdn[0][d_cnt]->la_attr.bv_val ));
678 Debug( LDAP_DEBUG_TRACE,
679 "bdb_modrdn: %s: %s (old)\n",
680 text, old_rdn[0][ d_cnt ]->la_attr.bv_val, 0 );
685 /* ACL check of newly added attrs */
686 if ( !access_allowed( be, conn, op, e, desc,
687 &old_rdn[0][d_cnt]->la_value, ACL_WRITE, NULL ) ) {
689 LDAP_LOG (( "modrdn", LDAP_LEVEL_ERR, "bdb_modrdn: access to attr \"%s\" (old) not allowed\n", old_rdn[0][d_cnt]->la_attr.bv_val ));
691 Debug( LDAP_DEBUG_TRACE,
692 "bdb_modrdn: access to attr \"%s\" "
693 "(old) not allowed\n",
694 old_rdn[0][ d_cnt ]->la_attr.bv_val, 0, 0 );
696 rc = LDAP_INSUFFICIENT_ACCESS;
700 /* Apply modification */
701 mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
702 + 2 * sizeof ( struct berval ) );
703 mod_tmp->sml_desc = desc;
704 mod_tmp->sml_bvalues = ( BerVarray )(mod_tmp+1);
705 mod_tmp->sml_bvalues[ 0 ] = old_rdn[0][ d_cnt ]->la_value;
706 mod_tmp->sml_bvalues[ 1 ].bv_val = NULL;
707 mod_tmp->sml_op = LDAP_MOD_DELETE;
708 mod_tmp->sml_next = mod;
714 rc = bdb_dn2id_delete( be, ltid, p_ndn.bv_val, e );
717 case DB_LOCK_DEADLOCK:
718 case DB_LOCK_NOTGRANTED:
722 text = "DN index delete fail";
726 (void) bdb_cache_delete_entry(&bdb->bi_cache, e);
728 /* Binary format uses a single contiguous block, cannot
729 * free individual fields. Leave new_dn/new_ndn set so
730 * they can be individually freed later.
733 e->e_nname = new_ndn;
735 new_dn.bv_val = NULL;
736 new_ndn.bv_val = NULL;
739 rc = bdb_dn2id_add( be, ltid, np_ndn, e );
742 case DB_LOCK_DEADLOCK:
743 case DB_LOCK_NOTGRANTED:
747 text = "DN index add failed";
752 rc = bdb_modify_internal( be, conn, op, ltid, &mod[0], e,
753 &text, textbuf, textlen );
755 if( rc != LDAP_SUCCESS ) {
757 case DB_LOCK_DEADLOCK:
758 case DB_LOCK_NOTGRANTED:
765 rc = bdb_id2entry_update( be, ltid, e );
768 case DB_LOCK_DEADLOCK:
769 case DB_LOCK_NOTGRANTED:
773 text = "entry update failed";
778 if(( rc=TXN_ABORT( ltid )) != 0 ) {
779 text = "txn_abort (no-op) failed";
785 char gid[DB_XIDDATASIZE];
787 snprintf( gid, sizeof( gid ), "%s-%08lx-%08lx",
788 bdb_uuid.bv_val, (long) op->o_connid, (long) op->o_opid );
790 if(( rc=TXN_PREPARE( ltid, gid )) != 0 ) {
791 text = "txn_prepare failed";
793 if( bdb_cache_update_entry(&bdb->bi_cache, e) == -1 ) {
794 if(( rc=TXN_ABORT( ltid )) != 0 ) {
795 text ="cache update & txn_abort failed";
798 text = "cache update failed";
802 if(( rc=TXN_COMMIT( ltid, 0 )) != 0 ) {
803 text = "txn_commit failed";
812 op->o_private = NULL;
814 if( rc == LDAP_SUCCESS ) {
816 LDAP_LOG (( "modrdn", LDAP_LEVEL_RESULTS, "bdb_modrdn: rdn modified%s id=%08lx dn=\"%s\"\n", op->o_noop ? " (no-op)" : "", e->e_id, e->e_dn ));
818 Debug(LDAP_DEBUG_TRACE,
819 "bdb_modrdn: rdn modified%s id=%08lx dn=\"%s\"\n",
820 op->o_noop ? " (no-op)" : "", e->e_id, e->e_dn );
823 bdb_cache_entry_commit( e );
827 LDAP_LOG (( "modrdn", LDAP_LEVEL_RESULTS, "bdb_modrdn: %s : %s (%d)\n", text, db_strerror(rc), rc ));
829 Debug( LDAP_DEBUG_TRACE, "bdb_add: %s : %s (%d)\n",
830 text, db_strerror(rc), rc );
836 send_ldap_result( conn, op, rc,
837 NULL, text, NULL, NULL );
839 if( rc == LDAP_SUCCESS && bdb->bi_txn_cp ) {
840 ldap_pvt_thread_yield();
841 TXN_CHECKPOINT( bdb->bi_dbenv,
842 bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 );
846 if( new_dn.bv_val != NULL ) free( new_dn.bv_val );
847 if( new_ndn.bv_val != NULL ) free( new_ndn.bv_val );
849 /* LDAP v2 supporting correct attribute handling. */
850 if( new_rdn != NULL ) ldap_rdnfree( new_rdn );
851 if( old_rdn != NULL ) ldap_rdnfree( old_rdn );
854 for (; mod; mod=tmp ) {
860 /* LDAP v3 Support */
862 /* free new parent and reader lock */
863 bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, np, &lock);
867 /* free parent and reader lock */
868 bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, p, &lock);
873 bdb_cache_return_entry_w( bdb->bi_dbenv, &bdb->bi_cache, e, &lock );
878 op->o_private = NULL;