/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2000-2005 The OpenLDAP Foundation.
+ * Copyright 2000-2006 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Entry *p = NULL;
EntryInfo *ei = NULL, *eip = NULL, *nei = NULL, *neip = NULL;
/* LDAP v2 supporting correct attribute handling. */
- LDAPRDN new_rdn = NULL;
- LDAPRDN old_rdn = NULL;
char textbuf[SLAP_TEXT_BUFLEN];
size_t textlen = sizeof textbuf;
DB_TXN *ltid = NULL, *lt2;
struct berval *np_ndn = NULL; /* newSuperior ndn */
struct berval *new_parent_dn = NULL; /* np_dn, p_dn, or NULL */
- /* Used to interface with bdb_modify_internal() */
- Modifications *mod = NULL; /* Used to delete old rdn */
-
int manageDSAit = get_manageDSAit( op );
u_int32_t locker = 0;
int parent_is_glue = 0;
int parent_is_leaf = 0;
- ctrls[num_ctrls] = NULL;
+#ifdef LDAP_X_TXN
+ int settle = 0;
+#endif
Debug( LDAP_DEBUG_TRACE, "==>" LDAP_XSTRING(bdb_modrdn) "(%s,%s,%s)\n",
op->o_req_dn.bv_val,op->oq_modrdn.rs_newrdn.bv_val,
op->oq_modrdn.rs_newSup ? op->oq_modrdn.rs_newSup->bv_val : "NULL" );
+#ifdef LDAP_X_TXN
+ if( op->o_txnSpec ) {
+ /* acquire connection lock */
+ ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
+ if( op->o_conn->c_txn == CONN_TXN_INACTIVE ) {
+ rs->sr_text = "invalid transaction identifier";
+ rs->sr_err = LDAP_X_TXN_ID_INVALID;
+ goto txnReturn;
+ } else if( op->o_conn->c_txn == CONN_TXN_SETTLE ) {
+ settle=1;
+ goto txnReturn;
+ }
+
+ if( op->o_conn->c_txn_backend == NULL ) {
+ op->o_conn->c_txn_backend = op->o_bd;
+
+ } else if( op->o_conn->c_txn_backend != op->o_bd ) {
+ rs->sr_text = "transaction cannot span multiple database contexts";
+ rs->sr_err = LDAP_AFFECTS_MULTIPLE_DSAS;
+ goto txnReturn;
+ }
+
+ /* insert operation into transaction */
+
+ rs->sr_text = "transaction specified";
+ rs->sr_err = LDAP_X_TXN_SPECIFY_OKAY;
+
+txnReturn:
+ /* release connection lock */
+ ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
+
+ if( !settle ) {
+ send_ldap_result( op, rs );
+ return rs->sr_err;
+ }
+ }
+#endif
+
+ ctrls[num_ctrls] = NULL;
+
+ slap_mods_opattrs( op, &op->orr_modlist, 1 );
+
if( 0 ) {
retry: /* transaction retry */
if ( dummy.e_attrs ) {
}
parent_is_glue = 0;
parent_is_leaf = 0;
- ldap_pvt_thread_yield();
bdb_trans_backoff( ++num_retries );
}
goto return_results;
}
- /* Get attribute type and attribute value of our new rdn, we will
- * need to add that to our new entry
- */
- if ( !new_rdn && ldap_bv2rdn_x( &op->oq_modrdn.rs_newrdn, &new_rdn,
- (char **)&rs->sr_text, LDAP_DN_FORMAT_LDAP, op->o_tmpmemctx ) )
- {
- Debug( LDAP_DEBUG_TRACE,
- LDAP_XSTRING(bdb_modrdn) ": can't figure out "
- "type(s)/values(s) of newrdn\n",
- 0, 0, 0 );
- rs->sr_err = LDAP_INVALID_DN_SYNTAX;
- rs->sr_text = "unknown type(s) used in RDN";
- goto return_results;
- }
-
- Debug( LDAP_DEBUG_TRACE,
- LDAP_XSTRING(bdb_modrdn)
- ": new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n",
- new_rdn[ 0 ]->la_attr.bv_val,
- new_rdn[ 0 ]->la_value.bv_val, 0 );
-
- if ( op->oq_modrdn.rs_deleteoldrdn ) {
- if ( !old_rdn && ldap_bv2rdn_x( &op->o_req_dn, &old_rdn,
- (char **)&rs->sr_text, LDAP_DN_FORMAT_LDAP, op->o_tmpmemctx ) )
- {
- Debug( LDAP_DEBUG_TRACE,
- LDAP_XSTRING(bdb_modrdn) ": can't figure out "
- "the old_rdn type(s)/value(s)\n",
- 0, 0, 0 );
- rs->sr_err = LDAP_OTHER;
- rs->sr_text = "cannot parse RDN from old DN";
- goto return_results;
- }
- }
-
- /* prepare modlist of modifications from old/new rdn */
- if (!mod) {
- rs->sr_err = slap_modrdn2mods( op, rs, e, old_rdn, new_rdn, &mod );
- if ( rs->sr_err != LDAP_SUCCESS ) {
- goto return_results;
- }
- }
+ assert( op->orr_modlist != NULL );
if( op->o_preread ) {
if( preread_ctrl == NULL ) {
dummy.e_attrs = e->e_attrs;
/* modify entry */
- rs->sr_err = bdb_modify_internal( op, lt2, &mod[0], &dummy,
+ rs->sr_err = bdb_modify_internal( op, lt2, op->orr_modlist, &dummy,
&rs->sr_text, textbuf, textlen );
if( rs->sr_err != LDAP_SUCCESS ) {
Debug(LDAP_DEBUG_TRACE,
if(( rs->sr_err=TXN_ABORT( ltid )) != 0 ) {
rs->sr_text = "txn_abort (no-op) failed";
} else {
- rs->sr_err = LDAP_NO_OPERATION;
+ rs->sr_err = LDAP_X_NO_OPERATION;
ltid = NULL;
goto return_results;
}
send_ldap_result( op, rs );
if( rs->sr_err == LDAP_SUCCESS && bdb->bi_txn_cp ) {
- ldap_pvt_thread_yield();
TXN_CHECKPOINT( bdb->bi_dbenv,
bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 );
}
}
done:
+ slap_graduate_commit_csn( op );
+
if( new_dn.bv_val != NULL ) free( new_dn.bv_val );
if( new_ndn.bv_val != NULL ) free( new_ndn.bv_val );
- /* LDAP v2 supporting correct attribute handling. */
- if ( new_rdn != NULL ) {
- ldap_rdnfree_x( new_rdn, op->o_tmpmemctx );
- }
- if ( old_rdn != NULL ) {
- ldap_rdnfree_x( old_rdn, op->o_tmpmemctx );
- }
- if( mod != NULL ) {
- Modifications *tmp;
- for (; mod; mod=tmp ) {
- tmp = mod->sml_next;
- /* slap_modrdn2mods does things one way,
- * slap_mods_opattrs does it differently
- */
- if ( mod->sml_op != SLAP_MOD_SOFTADD &&
- mod->sml_op != LDAP_MOD_DELETE ) break;
- if ( mod->sml_nvalues ) free( mod->sml_nvalues[0].bv_val );
- free( mod );
- }
- slap_mods_free( mod, 1 );
- }
-
/* LDAP v3 Support */
if( np != NULL ) {
/* free new parent and reader lock */
}
op->o_private = NULL;
- if( preread_ctrl != NULL ) {
+ if( preread_ctrl != NULL && (*preread_ctrl) != NULL ) {
slap_sl_free( (*preread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx );
slap_sl_free( *preread_ctrl, op->o_tmpmemctx );
}
- if( postread_ctrl != NULL ) {
+ if( postread_ctrl != NULL && (*postread_ctrl) != NULL ) {
slap_sl_free( (*postread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx );
slap_sl_free( *postread_ctrl, op->o_tmpmemctx );
}