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 ( OPERATION, ENTRY, "==>bdb_modrdn(%s,%s,%s)\n",
64 dn->bv_val,newrdn->bv_val, newSuperior ? newSuperior->bv_val : "NULL" );
66 Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn(%s,%s,%s)\n",
67 dn->bv_val, newrdn->bv_val,
68 newSuperior ? newSuperior->bv_val : "NULL" );
72 if( newSuperior != NULL ) {
73 rc = LDAP_UNWILLING_TO_PERFORM;
74 text = "newSuperior not implemented (yet)";
80 retry: /* transaction retry */
82 bdb_cache_delete_entry(&bdb->bi_cache, e);
83 bdb_unlocked_cache_return_entry_w(&bdb->bi_cache, e);
86 bdb_unlocked_cache_return_entry_r(&bdb->bi_cache, p);
89 bdb_unlocked_cache_return_entry_r(&bdb->bi_cache, np);
92 LDAP_LOG ( OPERATION, DETAIL1, "==>bdb_modrdn: retrying...\n", 0, 0, 0);
94 Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn: retrying...\n", 0, 0, 0 );
96 rc = TXN_ABORT( ltid );
101 text = "internal error";
104 ldap_pvt_thread_yield();
107 /* begin transaction */
108 rc = TXN_BEGIN( bdb->bi_dbenv, NULL, <id,
109 bdb->bi_db_opflags );
113 LDAP_LOG ( OPERATION, ERR,
114 "==>bdb_modrdn: txn_begin failed: %s (%d)\n",
115 db_strerror(rc), rc, 0 );
117 Debug( LDAP_DEBUG_TRACE,
118 "bdb_delete: txn_begin failed: %s (%d)\n",
119 db_strerror(rc), rc, 0 );
122 text = "internal error";
126 locker = TXN_ID ( ltid );
129 opinfo.boi_txn = ltid;
131 op->o_private = &opinfo;
134 rc = bdb_dn2entry_w( be, ltid, ndn, &e, &matched, DB_RMW, locker, &lock );
140 case DB_LOCK_DEADLOCK:
141 case DB_LOCK_NOTGRANTED:
144 text = "ldap server busy";
148 text = "internal error";
153 char* matched_dn = NULL;
156 if( matched != NULL ) {
157 matched_dn = ch_strdup( matched->e_dn );
158 refs = is_entry_referral( matched )
159 ? get_entry_referrals( be, conn, op, matched )
161 bdb_unlocked_cache_return_entry_r( &bdb->bi_cache, matched);
165 refs = referral_rewrite( default_referral,
166 NULL, dn, LDAP_SCOPE_DEFAULT );
169 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
170 matched_dn, NULL, refs, NULL );
172 ber_bvarray_free( refs );
178 if (!manageDSAit && is_entry_referral( e ) ) {
179 /* parent is a referral, don't allow add */
180 /* parent is an alias, don't allow add */
181 BerVarray refs = get_entry_referrals( be,
185 LDAP_LOG ( OPERATION, DETAIL1,
186 "==>bdb_modrdn: entry %s is referral \n", e->e_dn, 0, 0 );
188 Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry %s is referral\n",
192 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
193 e->e_dn, NULL, refs, NULL );
195 ber_bvarray_free( refs );
199 if ( be_issuffix( be, &e->e_nname ) ) {
200 p_ndn = slap_empty_bv;
202 dnParent( &e->e_nname, &p_ndn );
205 if ( p_ndn.bv_len != 0 ) {
206 /* Make sure parent entry exist and we can write its
209 rc = bdb_dn2entry_r( be, ltid, &p_ndn, &p, NULL, 0, locker, &lock );
215 case DB_LOCK_DEADLOCK:
216 case DB_LOCK_NOTGRANTED:
219 text = "ldap server busy";
223 text = "internal error";
229 LDAP_LOG ( OPERATION, ERR,
230 "==>bdb_modrdn: parent does not exist\n", 0, 0, 0 );
232 Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: parent does not exist\n",
239 /* check parent for "children" acl */
240 if ( ! access_allowed( be, conn, op, p,
241 children, NULL, ACL_WRITE, NULL ) )
244 LDAP_LOG ( OPERATION, ERR,
245 "==>bdb_modrdn: no access to parent\n", 0, 0, 0 );
247 Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0,
250 send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
251 NULL, NULL, NULL, NULL );
256 LDAP_LOG ( OPERATION, DETAIL1,
257 "==>bdb_modrdn: wr to children %s is OK\n", p_ndn.bv_val, 0, 0 );
259 Debug( LDAP_DEBUG_TRACE,
260 "bdb_modrdn: wr to children of entry %s OK\n",
261 p_ndn.bv_val, 0, 0 );
264 if ( p_ndn.bv_val == slap_empty_bv.bv_val ) {
265 p_dn = slap_empty_bv;
267 dnParent( &e->e_name, &p_dn );
271 LDAP_LOG ( OPERATION, DETAIL1,
272 "==>bdb_modrdn: parent dn=%s\n", p_dn.bv_val, 0, 0 );
274 Debug( LDAP_DEBUG_TRACE,
275 "bdb_modrdn: parent dn=%s\n",
280 /* no parent, modrdn entry directly under root */
281 isroot = be_isroot( be, &op->o_ndn );
283 if ( be_issuffix( be, (struct berval *)&slap_empty_bv )
284 || be_isupdate( be, &op->o_ndn ) ) {
286 p = (Entry *)&slap_entry_root;
288 /* check parent for "children" acl */
289 rc = access_allowed( be, conn, op, p,
290 children, NULL, ACL_WRITE, NULL );
297 LDAP_LOG ( OPERATION, ERR,
298 "==>bdb_modrdn: no access to parent\n", 0, 0, 0 );
300 Debug( LDAP_DEBUG_TRACE,
301 "no access to parent\n",
304 send_ldap_result( conn, op,
305 LDAP_INSUFFICIENT_ACCESS,
306 NULL, NULL, NULL, NULL );
311 LDAP_LOG ( OPERATION, DETAIL1,
312 "==>bdb_modrdn: wr to children of entry \"%s\" OK\n",
315 Debug( LDAP_DEBUG_TRACE,
316 "bdb_modrdn: wr to children of entry \"\" OK\n",
324 LDAP_LOG ( OPERATION, DETAIL1,
325 "==>bdb_modrdn: parent dn=\"\" \n", 0, 0, 0 );
327 Debug( LDAP_DEBUG_TRACE,
328 "bdb_modrdn: parent dn=\"\"\n",
334 LDAP_LOG ( OPERATION, ERR,
335 "==>bdb_modrdn: no parent, not root &\"\" is not "
336 "suffix\n", 0, 0, 0 );
338 Debug( LDAP_DEBUG_TRACE,
339 "bdb_modrdn: no parent, not root "
340 "& \"\" is not suffix\n",
343 rc = LDAP_INSUFFICIENT_ACCESS;
349 new_parent_dn = &p_dn; /* New Parent unless newSuperior given */
351 if ( newSuperior != NULL ) {
353 LDAP_LOG ( OPERATION, DETAIL1,
354 "==>bdb_modrdn: new parent \"%s\" requested...\n",
355 newSuperior->bv_val, 0, 0 );
357 Debug( LDAP_DEBUG_TRACE,
358 "bdb_modrdn: new parent \"%s\" requested...\n",
359 newSuperior->bv_val, 0, 0 );
362 if ( newSuperior->bv_len ) {
364 np_ndn = nnewSuperior;
366 /* newSuperior == oldParent?, if so ==> ERROR */
367 /* newSuperior == entry being moved?, if so ==> ERROR */
368 /* Get Entry with dn=newSuperior. Does newSuperior exist? */
370 rc = bdb_dn2entry_r( be, ltid, nnewSuperior, &np, NULL, 0, locker, &lock );
376 case DB_LOCK_DEADLOCK:
377 case DB_LOCK_NOTGRANTED:
380 text = "ldap server busy";
384 text = "internal error";
390 LDAP_LOG ( OPERATION, DETAIL1,
391 "==>bdb_modrdn: newSup(ndn=%s) not here!\n",
392 np_ndn->bv_val, 0, 0 );
394 Debug( LDAP_DEBUG_TRACE,
395 "bdb_modrdn: newSup(ndn=%s) not here!\n",
396 np_ndn->bv_val, 0, 0);
403 LDAP_LOG ( OPERATION, DETAIL1,
404 "==>bdb_modrdn: wr to new parent OK np=%p, id=%ld\n",
405 np, (long) np->e_id, 0 );
407 Debug( LDAP_DEBUG_TRACE,
408 "bdb_modrdn: wr to new parent OK np=%p, id=%ld\n",
409 np, (long) np->e_id, 0 );
412 /* check newSuperior for "children" acl */
413 if ( !access_allowed( be, conn, op, np, children, NULL, ACL_WRITE, NULL ) ) {
415 LDAP_LOG ( OPERATION, DETAIL1,
416 "==>bdb_modrdn: no wr to newSup children\n", 0, 0, 0 );
418 Debug( LDAP_DEBUG_TRACE,
419 "bdb_modrdn: no wr to newSup children\n",
422 rc = LDAP_INSUFFICIENT_ACCESS;
427 if ( is_entry_alias( np ) ) {
428 /* parent is an alias, don't allow add */
430 LDAP_LOG ( OPERATION, DETAIL1,
431 "==>bdb_modrdn: entry is alias\n", 0, 0, 0 );
433 Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry is alias\n",
437 rc = LDAP_ALIAS_PROBLEM;
442 if ( is_entry_referral( np ) ) {
443 /* parent is a referral, don't allow add */
445 LDAP_LOG ( OPERATION, DETAIL1,
446 "==>bdb_modrdn: entry is referral\n", 0, 0, 0 );
448 Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry is referral\n",
452 rc = LDAP_OPERATIONS_ERROR;
457 if ( isroot == -1 ) {
458 isroot = be_isroot( be, &op->o_ndn );
463 /* no parent, modrdn entry directly under root */
465 if ( be_issuffix( be, (struct berval *)&slap_empty_bv )
466 || be_isupdate( be, &op->o_ndn ) ) {
467 np = (Entry *)&slap_entry_root;
469 /* check parent for "children" acl */
470 rc = access_allowed( be, conn, op, np,
471 children, NULL, ACL_WRITE, NULL );
478 LDAP_LOG ( OPERATION, ERR,
479 "==>bdb_modrdn: no access to superior\n", 0, 0, 0 );
481 Debug( LDAP_DEBUG_TRACE,
482 "no access to new superior\n",
485 send_ldap_result( conn, op,
486 LDAP_INSUFFICIENT_ACCESS,
487 NULL, NULL, NULL, NULL );
492 LDAP_LOG ( OPERATION, DETAIL1,
493 "bdb_modrdn: wr to children entry \"\" OK\n", 0, 0, 0 );
495 Debug( LDAP_DEBUG_TRACE,
496 "bdb_modrdn: wr to children of entry \"\" OK\n",
502 LDAP_LOG ( OPERATION, ERR,
503 "bdb_modrdn: new superior=\"\", not root & \"\" "
504 "is not suffix\n", 0, 0, 0 );
506 Debug( LDAP_DEBUG_TRACE,
507 "bdb_modrdn: new superior=\"\", not root "
508 "& \"\" is not suffix\n",
511 rc = LDAP_INSUFFICIENT_ACCESS;
517 LDAP_LOG ( OPERATION, DETAIL1,
518 "bdb_modrdn: new superior=\"\"\n", 0, 0, 0 );
520 Debug( LDAP_DEBUG_TRACE,
521 "bdb_modrdn: new superior=\"\"\n",
527 LDAP_LOG ( OPERATION, DETAIL1,
528 "bdb_modrdn: wr to new parent's children OK\n", 0, 0, 0 );
530 Debug( LDAP_DEBUG_TRACE,
531 "bdb_modrdn: wr to new parent's children OK\n",
535 new_parent_dn = np_dn;
538 /* Build target dn and make sure target entry doesn't exist already. */
539 build_new_dn( &new_dn, new_parent_dn, newrdn );
541 dnNormalize2( NULL, &new_dn, &new_ndn );
544 LDAP_LOG ( OPERATION, RESULTS,
545 "bdb_modrdn: new ndn=%s\n", new_ndn.bv_val, 0, 0 );
547 Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: new ndn=%s\n",
548 new_ndn.bv_val, 0, 0 );
551 rc = bdb_dn2id ( be, ltid, &new_ndn, &id, 0 );
553 case DB_LOCK_DEADLOCK:
554 case DB_LOCK_NOTGRANTED:
559 rc = LDAP_ALREADY_EXISTS;
563 text = "internal error";
568 LDAP_LOG ( OPERATION, ERR,
569 "bdb_modrdn: new ndn=%s does not exist\n", new_ndn.bv_val, 0, 0 );
571 Debug( LDAP_DEBUG_TRACE,
572 "bdb_modrdn: new ndn=%s does not exist\n",
573 new_ndn.bv_val, 0, 0 );
576 /* Get attribute type and attribute value of our new rdn, we will
577 * need to add that to our new entry
579 if ( ldap_bv2rdn( newrdn, &new_rdn, (char **)&text,
580 LDAP_DN_FORMAT_LDAP ) )
583 LDAP_LOG ( OPERATION, ERR,
584 "bdb_modrdn: can't figure out type(s)/values(s) of newrdn\n",
587 Debug( LDAP_DEBUG_TRACE,
588 "bdb_modrdn: can't figure out type(s)/values(s) "
589 "of newrdn\n", 0, 0, 0 );
591 rc = LDAP_OPERATIONS_ERROR;
592 text = "unknown type(s) used in RDN";
597 LDAP_LOG ( OPERATION, RESULTS,
598 "bdb_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n",
599 new_rdn[0][0]->la_attr.bv_val, new_rdn[0][0]->la_value.bv_val, 0 );
601 Debug( LDAP_DEBUG_TRACE,
602 "bdb_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n",
603 new_rdn[0][0]->la_attr.bv_val, new_rdn[0][0]->la_value.bv_val, 0 );
606 if ( ldap_bv2rdn( dn, &old_rdn, (char **)&text,
607 LDAP_DN_FORMAT_LDAP ) )
610 LDAP_LOG ( OPERATION, ERR,
611 "bdb_modrdn: can't figure out type(s)/values(s) of old_rdn\n",
614 Debug( LDAP_DEBUG_TRACE,
615 "bdb_back_modrdn: can't figure out the old_rdn "
616 "type(s)/value(s)\n", 0, 0, 0 );
619 text = "cannot parse RDN from old DN";
624 if ( newSuperior == NULL
625 && charray_strcasecmp( ( const char ** )old_rdn_types,
626 ( const char ** )new_rdn_types ) != 0 ) {
627 /* Not a big deal but we may say something */
629 LDAP_LOG ( OPERATION, ERR,
630 "bdb_modrdn: old_rdn_type(s)=%s, new_rdn_type(s)=%s do not match\n",
631 old_rdn_types[ 0 ], new_rdn_types[ 0 ], 0 );
633 Debug( LDAP_DEBUG_TRACE,
634 "bdb_modrdn: old_rdn_type(s)=%s, new_rdn_type(s)=%s "
636 old_rdn_types[ 0 ], new_rdn_types[ 0 ], 0 );
641 /* Add new attribute values to the entry */
642 for ( a_cnt = 0; new_rdn[0][ a_cnt ]; a_cnt++ ) {
644 AttributeDescription *desc = NULL;
645 Modifications *mod_tmp;
647 rc = slap_bv2ad( &new_rdn[0][ a_cnt ]->la_attr, &desc, &text );
649 if ( rc != LDAP_SUCCESS ) {
651 LDAP_LOG ( OPERATION, ERR, "bdb_modrdn: %s: %s (new)\n",
652 text, new_rdn[0][a_cnt]->la_attr.bv_val, 0 );
654 Debug( LDAP_DEBUG_TRACE,
655 "bdb_modrdn: %s: %s (new)\n",
656 text, new_rdn[0][ a_cnt ]->la_attr.bv_val, 0 );
661 /* ACL check of newly added attrs */
662 if ( !access_allowed( be, conn, op, e, desc,
663 &new_rdn[0][ a_cnt ]->la_value, ACL_WRITE, NULL ) ) {
665 LDAP_LOG ( OPERATION, ERR,
666 "bdb_modrdn: access to attr \"%s\" (new) not allowed\n",
667 new_rdn[0][a_cnt]->la_attr.bv_val, 0, 0 );
669 Debug( LDAP_DEBUG_TRACE,
670 "bdb_modrdn: access to attr \"%s\" "
671 "(new) not allowed\n",
672 new_rdn[0][ a_cnt ]->la_attr.bv_val, 0, 0 );
674 rc = LDAP_INSUFFICIENT_ACCESS;
678 /* Apply modification */
679 mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
680 + 2 * sizeof( struct berval ) );
681 mod_tmp->sml_desc = desc;
682 mod_tmp->sml_bvalues = ( BerVarray )( mod_tmp + 1 );
683 mod_tmp->sml_bvalues[ 0 ] = new_rdn[0][ a_cnt ]->la_value;
684 mod_tmp->sml_bvalues[ 1 ].bv_val = NULL;
685 mod_tmp->sml_op = SLAP_MOD_SOFTADD;
686 mod_tmp->sml_next = mod;
690 /* Remove old rdn value if required */
691 if ( deleteoldrdn ) {
692 /* Get value of old rdn */
693 if ( old_rdn == NULL) {
695 LDAP_LOG ( OPERATION, ERR,
696 "bdb_modrdn: can't figure out old RDN values(s) "
697 "from old RDN\n", 0, 0, 0 );
699 Debug( LDAP_DEBUG_TRACE,
700 "bdb_modrdn: can't figure out old RDN value(s) "
701 "from old RDN\n", 0, 0, 0 );
704 text = "could not parse value(s) from old RDN";
708 for ( d_cnt = 0; old_rdn[0][ d_cnt ]; d_cnt++ ) {
710 AttributeDescription *desc = NULL;
711 Modifications *mod_tmp;
713 rc = slap_bv2ad( &old_rdn[0][ d_cnt ]->la_attr,
716 if ( rc != LDAP_SUCCESS ) {
718 LDAP_LOG ( OPERATION, ERR, "bdb_modrdn: %s: %s (old)\n",
719 text, old_rdn[0][d_cnt]->la_attr.bv_val, 0 );
721 Debug( LDAP_DEBUG_TRACE,
722 "bdb_modrdn: %s: %s (old)\n",
723 text, old_rdn[0][ d_cnt ]->la_attr.bv_val, 0 );
728 /* ACL check of newly added attrs */
729 if ( !access_allowed( be, conn, op, e, desc,
730 &old_rdn[0][d_cnt]->la_value, ACL_WRITE, NULL ) ) {
732 LDAP_LOG ( OPERATION, ERR,
733 "bdb_modrdn: access to attr \"%s\" (old) not allowed\n",
734 old_rdn[0][d_cnt]->la_attr.bv_val, 0, 0 );
736 Debug( LDAP_DEBUG_TRACE,
737 "bdb_modrdn: access to attr \"%s\" "
738 "(old) not allowed\n",
739 old_rdn[0][ d_cnt ]->la_attr.bv_val, 0, 0 );
741 rc = LDAP_INSUFFICIENT_ACCESS;
745 /* Apply modification */
746 mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
747 + 2 * sizeof ( struct berval ) );
748 mod_tmp->sml_desc = desc;
749 mod_tmp->sml_bvalues = ( BerVarray )(mod_tmp+1);
750 mod_tmp->sml_bvalues[ 0 ] = old_rdn[0][ d_cnt ]->la_value;
751 mod_tmp->sml_bvalues[ 1 ].bv_val = NULL;
752 mod_tmp->sml_op = LDAP_MOD_DELETE;
753 mod_tmp->sml_next = mod;
759 rc = bdb_dn2id_delete( be, ltid, p_ndn.bv_val, e );
762 case DB_LOCK_DEADLOCK:
763 case DB_LOCK_NOTGRANTED:
767 text = "DN index delete fail";
771 (void) bdb_cache_delete_entry(&bdb->bi_cache, e);
773 /* Binary format uses a single contiguous block, cannot
774 * free individual fields. Leave new_dn/new_ndn set so
775 * they can be individually freed later.
778 e->e_nname = new_ndn;
780 new_dn.bv_val = NULL;
781 new_ndn.bv_val = NULL;
784 rc = bdb_dn2id_add( be, ltid, np_ndn, e );
787 case DB_LOCK_DEADLOCK:
788 case DB_LOCK_NOTGRANTED:
792 text = "DN index add failed";
797 rc = bdb_modify_internal( be, conn, op, ltid, &mod[0], e,
798 &text, textbuf, textlen );
800 if( rc != LDAP_SUCCESS ) {
802 case DB_LOCK_DEADLOCK:
803 case DB_LOCK_NOTGRANTED:
810 rc = bdb_id2entry_update( be, ltid, e );
813 case DB_LOCK_DEADLOCK:
814 case DB_LOCK_NOTGRANTED:
818 text = "entry update failed";
823 if(( rc=TXN_ABORT( ltid )) != 0 ) {
824 text = "txn_abort (no-op) failed";
830 char gid[DB_XIDDATASIZE];
832 snprintf( gid, sizeof( gid ), "%s-%08lx-%08lx",
833 bdb_uuid.bv_val, (long) op->o_connid, (long) op->o_opid );
835 if(( rc=TXN_PREPARE( ltid, gid )) != 0 ) {
836 text = "txn_prepare failed";
838 if( bdb_cache_update_entry(&bdb->bi_cache, e) == -1 ) {
839 if(( rc=TXN_ABORT( ltid )) != 0 ) {
840 text ="cache update & txn_abort failed";
843 text = "cache update failed";
847 if(( rc=TXN_COMMIT( ltid, 0 )) != 0 ) {
848 text = "txn_commit failed";
857 op->o_private = NULL;
859 if( rc == LDAP_SUCCESS ) {
861 LDAP_LOG ( OPERATION, RESULTS,
862 "bdb_modrdn: rdn modified%s id=%08lx dn=\"%s\"\n",
863 op->o_noop ? " (no-op)" : "", e->e_id, e->e_dn );
865 Debug(LDAP_DEBUG_TRACE,
866 "bdb_modrdn: rdn modified%s id=%08lx dn=\"%s\"\n",
867 op->o_noop ? " (no-op)" : "", e->e_id, e->e_dn );
870 bdb_cache_entry_commit( e );
874 LDAP_LOG ( OPERATION, RESULTS, "bdb_modrdn: %s : %s (%d)\n",
875 text, db_strerror(rc), rc );
877 Debug( LDAP_DEBUG_TRACE, "bdb_add: %s : %s (%d)\n",
878 text, db_strerror(rc), rc );
884 send_ldap_result( conn, op, rc,
885 NULL, text, NULL, NULL );
887 if( rc == LDAP_SUCCESS && bdb->bi_txn_cp ) {
888 ldap_pvt_thread_yield();
889 TXN_CHECKPOINT( bdb->bi_dbenv,
890 bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 );
894 if( new_dn.bv_val != NULL ) free( new_dn.bv_val );
895 if( new_ndn.bv_val != NULL ) free( new_ndn.bv_val );
897 /* LDAP v2 supporting correct attribute handling. */
898 if( new_rdn != NULL ) ldap_rdnfree( new_rdn );
899 if( old_rdn != NULL ) ldap_rdnfree( old_rdn );
902 for (; mod; mod=tmp ) {
908 /* LDAP v3 Support */
910 /* free new parent and reader lock */
911 bdb_unlocked_cache_return_entry_r(&bdb->bi_cache, np);
915 /* free parent and reader lock */
916 bdb_unlocked_cache_return_entry_r(&bdb->bi_cache, p);
921 bdb_unlocked_cache_return_entry_w( &bdb->bi_cache, e);
926 op->o_private = NULL;