Debian Codegraph @

servers/slapd/back-wt/modify.c

raw
1 /* OpenLDAP WiredTiger backend */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 *
5 * Copyright 2002-2024 The OpenLDAP Foundation.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
10 * Public License.
11 *
12 * A copy of this license is available in the file LICENSE in the
13 B * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
15 */
16 /* ACKNOWLEDGEMENTS:
17 * This work was developed by HAMANO Tsukasa <[email protected]>
18 * based on back-bdb for inclusion in OpenLDAP Software.
19 * WiredTiger is a product of MongoDB Inc.
20 */
21 #include "portable.h"
22
23 #include <stdio.h>
24 #include <ac/string.h>
25 #include "back-wt.h"
26 #include "slap-config.h"
27
28 static struct berval scbva[] = {
29 BER_BVC("glue"),
30 BER_BVNULL
31 };
32
33 static void
34 wt_modify_idxflags(
35 Operation *op,
36 AttributeDescription *desc,
37 int got_delete,
38 Attribute *newattrs,
39 Attribute *oldattrs )
40 {
41 struct berval ix_at;
42 AttrInfo *ai;
43
44 /* check if modified attribute was indexed
45 * but not in case of NOOP... */
46 ai = wt_index_mask( op->o_bd, desc, &ix_at );
47 if ( ai ) {
48 if ( got_delete ) {
49 Attribute *ap;
50 struct berval ix2;
51
52 ap = attr_find( oldattrs, desc );
53 if ( ap ) ap->a_flags |= SLAP_ATTR_IXDEL;
54
55 /* Find all other attrs that index to same slot */
56 for ( ap = newattrs; ap; ap = ap->a_next ) {
57 ai = wt_index_mask( op->o_bd, ap->a_desc, &ix2 );
58 if ( ai && ix2.bv_val == ix_at.bv_val )
59 ap->a_flags |= SLAP_ATTR_IXADD;
60 }
61
62 } else {
63 Attribute *ap;
64
65 ap = attr_find( newattrs, desc );
66 if ( ap ) ap->a_flags |= SLAP_ATTR_IXADD;
67 }
68 }
69 }
70
71 int wt_modify_internal(
72 Operation *op,
73 wt_ctx *wc,
74 Modifications *modlist,
75 Entry *e,
76 const char **text,
77 char *textbuf,
78 size_t textlen )
79 {
80 int rc, err;
81 Modification *mod;
82 Modifications *ml;
83 Attribute *save_attrs;
84 Attribute *ap;
85 int glue_attr_delete = 0;
86 int got_delete;
87
88 Debug( LDAP_DEBUG_TRACE, "wt_modify_internal: 0x%08lx: %s\n",
89 e->e_id, e->e_dn );
90
91 if ( !acl_check_modlist( op, e, modlist )) {
92 return LDAP_INSUFFICIENT_ACCESS;
93 }
94
95 /* save_attrs will be disposed of by caller */
96 save_attrs = e->e_attrs;
97 e->e_attrs = attrs_dup( e->e_attrs );
98
99 for ( ml = modlist; ml != NULL; ml = ml->sml_next ) {
100 int match;
101 mod = &ml->sml_mod;
102 switch( mod->sm_op ) {
103 case LDAP_MOD_ADD:
104 case LDAP_MOD_REPLACE:
105 if ( mod->sm_desc == slap_schema.si_ad_structuralObjectClass ) {
106 value_match( &match, slap_schema.si_ad_structuralObjectClass,
107 slap_schema.si_ad_structuralObjectClass->
108 ad_type->sat_equality,
109 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
110 &mod->sm_values[0], &scbva[0], text );
111 if ( !match ) glue_attr_delete = 1;
112 }
113 }
114 if ( glue_attr_delete )
115 break;
116 }
117
118 if ( glue_attr_delete ) {
119 Attribute **app = &e->e_attrs;
120 while ( *app != NULL ) {
121 if ( !is_at_operational( (*app)->a_desc->ad_type )) {
122 Attribute *save = *app;
123 *app = (*app)->a_next;
124 attr_free( save );
125 continue;
126 }
127 app = &(*app)->a_next;
128 }
129 }
130
131 for ( ml = modlist; ml != NULL; ml = ml->sml_next ) {
132 mod = &ml->sml_mod;
133 got_delete = 0;
134
135 switch ( mod->sm_op ) {
136 case LDAP_MOD_ADD:
137 Debug(LDAP_DEBUG_ARGS,
138 "wt_modify_internal: add %s\n",
139 mod->sm_desc->ad_cname.bv_val );
140 err = modify_add_values( e, mod, get_permissiveModify(op),
141 text, textbuf, textlen );
142 if( err != LDAP_SUCCESS ) {
143 Debug(LDAP_DEBUG_ARGS, "wt_modify_internal: %d %s\n",
144 err, *text );
145 }
146 break;
147
148 case LDAP_MOD_DELETE:
149 if ( glue_attr_delete ) {
150 err = LDAP_SUCCESS;
151 break;
152 }
153
154 Debug( LDAP_DEBUG_ARGS,
155 "wt_modify_internal: delete %s\n",
156 mod->sm_desc->ad_cname.bv_val );
157 err = modify_delete_values( e, mod, get_permissiveModify(op),
158 text, textbuf, textlen );
159 if( err != LDAP_SUCCESS ) {
160 Debug(LDAP_DEBUG_ARGS,
161 "wt_modify_internal: %d %s\n", err, *text );
162 } else {
163 got_delete = 1;
164 }
165 break;
166
167 case LDAP_MOD_REPLACE:
168 Debug( LDAP_DEBUG_ARGS,
169 "wt_modify_internal: replace %s\n",
170 mod->sm_desc->ad_cname.bv_val );
171 err = modify_replace_values( e, mod, get_permissiveModify(op),
172 text, textbuf, textlen );
173 if( err != LDAP_SUCCESS ) {
174 Debug(LDAP_DEBUG_ARGS,
175 "wt_modify_internal: %d %s\n", err, *text );
176 } else {
177 got_delete = 1;
178 }
179 break;
180
181 case LDAP_MOD_INCREMENT:
182 Debug( LDAP_DEBUG_ARGS,
183 "wt_modify_internal: increment %s\n",
184 mod->sm_desc->ad_cname.bv_val );
185 err = modify_increment_values( e, mod, get_permissiveModify(op),
186 text, textbuf, textlen );
187 if( err != LDAP_SUCCESS ) {
188 Debug( LDAP_DEBUG_ARGS,
189 "wt_modify_internal: %d %s\n", err, *text );
190 } else {
191 got_delete = 1;
192 }
193 break;
194
195 case SLAP_MOD_SOFTADD:
196 Debug( LDAP_DEBUG_ARGS,
197 "wt_modify_internal: softadd %s\n",
198 mod->sm_desc->ad_cname.bv_val );
199 /* Avoid problems in index_add_mods()
200 * We need to add index if necessary.
201 */
202 mod->sm_op = LDAP_MOD_ADD;
203
204 err = modify_add_values( e, mod, get_permissiveModify(op),
205 text, textbuf, textlen );
206
207 mod->sm_op = SLAP_MOD_SOFTADD;
208
209 if ( err == LDAP_TYPE_OR_VALUE_EXISTS ) {
210 err = LDAP_SUCCESS;
211 }
212
213 if( err != LDAP_SUCCESS ) {
214 Debug(LDAP_DEBUG_ARGS, "wt_modify_internal: %d %s\n",
215 err, *text );
216 }
217 break;
218
219 case SLAP_MOD_SOFTDEL:
220 Debug( LDAP_DEBUG_ARGS,
221 "wt_modify_internal: softdel %s\n",
222 mod->sm_desc->ad_cname.bv_val );
223 /* Avoid problems in index_delete_mods()
224 * We need to add index if necessary.
225 */
226 mod->sm_op = LDAP_MOD_DELETE;
227
228 err = modify_delete_values( e, mod, get_permissiveModify(op),
229 text, textbuf, textlen );
230
231 mod->sm_op = SLAP_MOD_SOFTDEL;
232
233 if ( err == LDAP_SUCCESS ) {
234 got_delete = 1;
235 } else if ( err == LDAP_NO_SUCH_ATTRIBUTE ) {
236 err = LDAP_SUCCESS;
237 }
238
239 if( err != LDAP_SUCCESS ) {
240 Debug(LDAP_DEBUG_ARGS, "wt_modify_internal: %d %s\n",
241 err, *text );
242 }
243 break;
244
245 case SLAP_MOD_ADD_IF_NOT_PRESENT:
246 if ( attr_find( e->e_attrs, mod->sm_desc ) != NULL ) {
247 /* skip */
248 err = LDAP_SUCCESS;
249 break;
250 }
251
252 Debug(LDAP_DEBUG_ARGS,
253 "wt_modify_internal: add_if_not_present %s\n",
254 mod->sm_desc->ad_cname.bv_val );
255 /* Avoid problems in index_add_mods()
256 * We need to add index if necessary.
257 */
258 mod->sm_op = LDAP_MOD_ADD;
259
260 err = modify_add_values( e, mod, get_permissiveModify(op),
261 text, textbuf, textlen );
262
263 mod->sm_op = SLAP_MOD_ADD_IF_NOT_PRESENT;
264
265 if( err != LDAP_SUCCESS ) {
266 Debug(LDAP_DEBUG_ARGS, "wt_modify_internal: %d %s\n",
267 err, *text );
268 }
269 break;
270
271 default:
272 Debug(LDAP_DEBUG_ANY, "wt_modify_internal: invalid op %d\n",
273 mod->sm_op );
274 *text = "Invalid modify operation";
275 err = LDAP_OTHER;
276 Debug(LDAP_DEBUG_ARGS, "wt_modify_internal: %d %s\n",
277 err, *text );
278 }
279
280 if ( err != LDAP_SUCCESS ) {
281 attrs_free( e->e_attrs );
282 e->e_attrs = save_attrs;
283 /* unlock entry, delete from cache */
284 return err;
285 }
286
287 /* If objectClass was modified, reset the flags */
288 if ( mod->sm_desc == slap_schema.si_ad_objectClass ) {
289 e->e_ocflags = 0;
290 }
291
292 if ( glue_attr_delete ) e->e_ocflags = 0;
293
294
295 /* check if modified attribute was indexed
296 * but not in case of NOOP... */
297 if ( !op->o_noop ) {
298 wt_modify_idxflags( op, mod->sm_desc, got_delete, e->e_attrs, save_attrs );
299 }
300
301 }
302
303 /* check that the entry still obeys the schema */
304 ap = NULL;
305 rc = entry_schema_check( op, e, save_attrs, get_relax(op), 0, &ap,
306 text, textbuf, textlen );
307 if ( rc != LDAP_SUCCESS || op->o_noop ) {
308 attrs_free( e->e_attrs );
309 /* clear the indexing flags */
310 for ( ap = save_attrs; ap != NULL; ap = ap->a_next ) {
311 ap->a_flags &= ~(SLAP_ATTR_IXADD|SLAP_ATTR_IXDEL);
312 }
313 e->e_attrs = save_attrs;
314
315 if ( rc != LDAP_SUCCESS ) {
316 Debug( LDAP_DEBUG_ANY,
317 "entry failed schema check: %s\n", *text );
318 }
319
320 /* if NOOP then silently revert to saved attrs */
321 return rc;
322 }
323
324 /* structuralObjectClass modified! */
325 if ( ap ) {
326 assert( ap->a_desc == slap_schema.si_ad_structuralObjectClass );
327 if ( !op->o_noop ) {
328 wt_modify_idxflags( op, slap_schema.si_ad_structuralObjectClass,
329 1, e->e_attrs, save_attrs );
330 }
331 }
332
333 /* update the indices of the modified attributes */
334
335 /* start with deleting the old index entries */
336 for ( ap = save_attrs; ap != NULL; ap = ap->a_next ) {
337 if ( ap->a_flags & SLAP_ATTR_IXDEL ) {
338 struct berval *vals;
339 Attribute *a2;
340 ap->a_flags &= ~SLAP_ATTR_IXDEL;
341 a2 = attr_find( e->e_attrs, ap->a_desc );
342 if ( a2 ) {
343 /* need to detect which values were deleted */
344 int i, j;
345 /* let add know there were deletes */
346 if ( a2->a_flags & SLAP_ATTR_IXADD )
347 a2->a_flags |= SLAP_ATTR_IXDEL;
348 vals = op->o_tmpalloc( (ap->a_numvals + 1) *
349 sizeof(struct berval), op->o_tmpmemctx );
350 j = 0;
351 for ( i=0; i < ap->a_numvals; i++ ) {
352 rc = attr_valfind( a2, SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
353 &ap->a_nvals[i], NULL, op->o_tmpmemctx );
354 /* Save deleted values */
355 if ( rc == LDAP_NO_SUCH_ATTRIBUTE )
356 vals[j++] = ap->a_nvals[i];
357 }
358 BER_BVZERO(vals+j);
359 } else {
360 /* attribute was completely deleted */
361 vals = ap->a_nvals;
362 }
363 rc = 0;
364 if ( !BER_BVISNULL( vals )) {
365 rc = wt_index_values( op, wc, ap->a_desc,
366 vals, e->e_id, SLAP_INDEX_DELETE_OP );
367 if ( rc != LDAP_SUCCESS ) {
368 Debug( LDAP_DEBUG_ANY,
369 "%s: attribute \"%s\" index delete failure\n",
370 op->o_log_prefix, ap->a_desc->ad_cname.bv_val );
371 attrs_free( e->e_attrs );
372 e->e_attrs = save_attrs;
373 }
374 }
375 if ( vals != ap->a_nvals )
376 op->o_tmpfree( vals, op->o_tmpmemctx );
377 if ( rc ) return rc;
378 }
379 }
380
381 /* add the new index entries */
382 for ( ap = e->e_attrs; ap != NULL; ap = ap->a_next ) {
383 if (ap->a_flags & SLAP_ATTR_IXADD) {
384 ap->a_flags &= ~SLAP_ATTR_IXADD;
385 if ( ap->a_flags & SLAP_ATTR_IXDEL ) {
386 /* if any values were deleted, we must readd index
387 * for all remaining values.
388 */
389 ap->a_flags &= ~SLAP_ATTR_IXDEL;
390 rc = wt_index_values( op, wc, ap->a_desc, ap->a_nvals,
391 e->e_id, SLAP_INDEX_ADD_OP );
392 } else {
393 int found = 0;
394 /* if this was only an add, we only need to index
395 * the added values.
396 */
397 for ( ml = modlist; ml != NULL; ml = ml->sml_next ) {
398 struct berval *vals;
399 if ( ml->sml_desc != ap->a_desc || !ml->sml_numvals )
400 continue;
401 found = 1;
402 switch( ml->sml_op ) {
403 case LDAP_MOD_ADD:
404 case LDAP_MOD_REPLACE:
405 case LDAP_MOD_INCREMENT:
406 case SLAP_MOD_SOFTADD:
407 case SLAP_MOD_ADD_IF_NOT_PRESENT:
408 if ( ml->sml_op == LDAP_MOD_INCREMENT )
409 vals = ap->a_nvals;
410 else if ( ml->sml_nvalues )
411 vals = ml->sml_nvalues;
412 else
413 vals = ml->sml_values;
414 rc = wt_index_values( op, wc, ap->a_desc,
415 vals, e->e_id, SLAP_INDEX_ADD_OP );
416 break;
417 }
418 if ( rc )
419 break;
420 }
421 /* This attr was affected by a modify of a subtype, so
422 * there was no direct match in the modlist. Just readd
423 * all of its values.
424 */
425 if ( !found ) {
426 rc = wt_index_values( op, wc, ap->a_desc, ap->a_nvals,
427 e->e_id, SLAP_INDEX_ADD_OP );
428 }
429 }
430 if ( rc != LDAP_SUCCESS ) {
431 Debug( LDAP_DEBUG_ANY,
432 "%s: attribute \"%s\" index add failure\n",
433 op->o_log_prefix, ap->a_desc->ad_cname.bv_val );
434 attrs_free( e->e_attrs );
435 e->e_attrs = save_attrs;
436 return rc;
437 }
438 }
439 }
440
441 return rc;
442 }
443
444 int
445 wt_modify( Operation *op, SlapReply *rs )
446 {
447 struct wt_info *wi = (struct wt_info *) op->o_bd->be_private;
448 wt_ctx *wc = NULL;
449 Entry *e = NULL;
450 int manageDSAit = get_manageDSAit( op );
451 char textbuf[SLAP_TEXT_BUFLEN];
452 size_t textlen = sizeof textbuf;
453 Entry dummy = {0};
454
455 LDAPControl **preread_ctrl = NULL;
456 LDAPControl **postread_ctrl = NULL;
457 LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
458 int num_ctrls = 0;
459
460 int rc;
461
462 Debug( LDAP_DEBUG_ARGS, "wt_modify: %s\n", op->o_req_dn.bv_val );
463
464 #ifdef LDAP_X_TXN
465 if( op->o_txnSpec && txn_preop( op, rs ))
466 return rs->sr_err;
467 #endif
468
469 ctrls[num_ctrls] = NULL;
470
471 wc = wt_ctx_get(op, wi);
472 if( !wc ){
473 Debug( LDAP_DEBUG_ANY, "wt_modify: wt_ctx_get failed\n" );
474 rs->sr_err = LDAP_OTHER;
475 rs->sr_text = "internal error";
476 send_ldap_result( op, rs );
477 return rs->sr_err;
478 }
479
480 /* Don't touch the opattrs, if this is a contextCSN update
481 * initiated from updatedn */
482 if ( !be_isupdate(op) || !op->orm_modlist || op->orm_modlist->sml_next ||
483 op->orm_modlist->sml_desc != slap_schema.si_ad_contextCSN ) {
484
485 slap_mods_opattrs( op, &op->orm_modlist, 1 );
486 }
487
488 retry:
489 /* begin transaction */
490 wc->is_begin_transaction = 0;
491 rc = wc->session->begin_transaction(wc->session, "isolation=snapshot");
492 if( rc ) {
493 Debug( LDAP_DEBUG_TRACE,
494 "wt_modify: begin_transaction failed: %s (%d)\n",
495 wiredtiger_strerror(rc), rc );
496 rs->sr_err = LDAP_OTHER;
497 rs->sr_text = "begin_transaction failed";
498 goto return_results;
499 }
500 wc->is_begin_transaction = 1;
501 Debug( LDAP_DEBUG_TRACE, "wt_modify: session id: %p\n", wc->session );
502
503 /* get entry */
504 rc = wt_dn2entry(op->o_bd, wc, &op->o_req_ndn, &e);
505 switch( rc ) {
506 case 0:
507 break;
508 case WT_NOTFOUND:
509 break;
510 default:
511 Debug( LDAP_DEBUG_ANY,
512 "<== wt_modify: wt_dn2entry failed (%d)\n", rc );
513 rs->sr_err = LDAP_OTHER;
514 rs->sr_text = "internal error";
515 goto return_results;
516 }
517
518 if ( rc == WT_NOTFOUND ||
519 ( !manageDSAit && e && is_entry_glue( e ))) {
520 if ( !e ) {
521 rc = wt_dn2aentry(op->o_bd, wc, &op->o_req_ndn, &e);
522 switch( rc ) {
523 case 0:
524 break;
525 case WT_NOTFOUND:
526 rs->sr_err = LDAP_NO_SUCH_OBJECT;
527 goto return_results;
528 default:
529 Debug( LDAP_DEBUG_ANY, "wt_modify: wt_dna2entry failed (%d)\n", rc );
530 rs->sr_err = LDAP_OTHER;
531 rs->sr_text = "internal error";
532 goto return_results;
533 }
534 }
535
536 rs->sr_matched = ch_strdup( e->e_dn );
537
538 if ( is_entry_referral( e ) ) {
539 BerVarray ref = get_entry_referrals( op, e );
540 rs->sr_ref = referral_rewrite( ref, &e->e_name,
541 &op->o_req_dn, LDAP_SCOPE_DEFAULT );
542 ber_bvarray_free( ref );
543 } else {
544 rs->sr_ref = NULL;
545 }
546 rs->sr_flags = REP_MATCHED_MUSTBEFREED | REP_REF_MUSTBEFREED;
547 rs->sr_err = LDAP_REFERRAL;
548 send_ldap_result( op, rs );
549 goto done;
550 }
551
552 if ( !manageDSAit && is_entry_referral( e ) ) {
553 /* entry is a referral, don't allow modify */
554 rs->sr_ref = get_entry_referrals( op, e );
555
556 Debug( LDAP_DEBUG_TRACE, "wt_modify: entry is referral\n" );
557
558 rs->sr_err = LDAP_REFERRAL;
559 rs->sr_matched = e->e_name.bv_val;
560 rs->sr_flags = REP_REF_MUSTBEFREED;
561 send_ldap_result( op, rs );
562 rs->sr_matched = NULL;
563 goto done;
564 }
565
566 if ( get_assert( op ) &&
567 ( test_filter( op, e, get_assertion( op )) != LDAP_COMPARE_TRUE ))
568 {
569 rs->sr_err = LDAP_ASSERTION_FAILED;
570 goto return_results;
571 }
572
573 if( op->o_preread ) {
574 if( preread_ctrl == NULL ) {
575 preread_ctrl = &ctrls[num_ctrls++];
576 ctrls[num_ctrls] = NULL;
577 }
578 if ( slap_read_controls( op, rs, e,
579 &slap_pre_read_bv, preread_ctrl ) )
580 {
581 Debug( LDAP_DEBUG_TRACE,
582 "<=- wt_modify: pre-read failed!\n" );
583 if ( op->o_preread & SLAP_CONTROL_CRITICAL ) {
584 /* FIXME: is it correct to abort
585 * operation if control fails? */
586 goto return_results;
587 }
588 }
589 }
590
591 /* Modify the entry */
592 dummy = *e;
593 rs->sr_err = wt_modify_internal( op, wc, op->orm_modlist,
594 &dummy, &rs->sr_text, textbuf, textlen );
595 switch ( rs->sr_err ) {
596 case LDAP_SUCCESS:
597 break;
598 case WT_ROLLBACK:
599 Debug (LDAP_DEBUG_TRACE, "wt_modify: rollback wt_modify_internal failed.\n" );
600 wc->session->rollback_transaction(wc->session, NULL);
601 goto retry;
602 default:
603 Debug( LDAP_DEBUG_ANY, "wt_modify: modify failed (%d)\n", rs->sr_err );
604 /* Only free attrs if they were dup'd. */
605 if ( dummy.e_attrs == e->e_attrs ) dummy.e_attrs = NULL;
606 goto return_results;
607 }
608
609 /* change the entry itself */
610 rs->sr_err = wt_id2entry_update( op, wc, &dummy );
611 switch ( rs->sr_err ) {
612 case 0:
613 break;
614 case WT_ROLLBACK:
615 Debug (LDAP_DEBUG_TRACE, "wt_modify: rollback wt_id2entry_update failed.\n");
616 wc->session->rollback_transaction(wc->session, NULL);
617 goto retry;
618 case LDAP_ADMINLIMIT_EXCEEDED:
619 Debug( LDAP_DEBUG_ANY, "wt_modify: id2entry update failed (%d)\n",
620 rs->sr_err);
621 rs->sr_text = "entry too big";
622 goto return_results;
623 default:
624 Debug( LDAP_DEBUG_ANY, "wt_modify: id2entry update failed (%d)\n",
625 rs->sr_err);
626 rs->sr_err = LDAP_OTHER;
627 rs->sr_text = "entry update failed";
628 goto return_results;
629 }
630
631 if( op->o_postread ) {
632 if( postread_ctrl == NULL ) {
633 postread_ctrl = &ctrls[num_ctrls++];
634 ctrls[num_ctrls] = NULL;
635 }
636 if( slap_read_controls( op, rs, &dummy,
637 &slap_post_read_bv, postread_ctrl ) )
638 {
639 Debug( LDAP_DEBUG_TRACE,
640 "<== wt_modify: post-read failed!\n");
641 if ( op->o_postread & SLAP_CONTROL_CRITICAL ) {
642 /* FIXME: is it correct to abort
643 * operation if control fails? */
644 goto return_results;
645 }
646 }
647 }
648
649 if( op->o_noop ) {
650 rs->sr_err = LDAP_X_NO_OPERATION;
651 goto return_results;
652 }
653
654 /* Only free attrs if they were dup'd. */
655 if ( dummy.e_attrs == e->e_attrs ) dummy.e_attrs = NULL;
656
657 rc = wc->session->commit_transaction(wc->session, NULL);
658 wc->is_begin_transaction = 0;
659 if( rc ) {
660 Debug( LDAP_DEBUG_TRACE,
661 "<== wt_modify: commit failed: %s (%d)\n",
662 wiredtiger_strerror(rc), rc );
663 rs->sr_err = LDAP_OTHER;
664 rs->sr_text = "commit failed";
665 goto return_results;
666 }
667
668 Debug( LDAP_DEBUG_TRACE,
669 "wt_modify: updated%s id=%08lx dn=\"%s\"\n",
670 op->o_noop ? " (no-op)" : "",
671 dummy.e_id, op->o_req_dn.bv_val );
672
673 rs->sr_err = LDAP_SUCCESS;
674 rs->sr_text = NULL;
675 if( num_ctrls ) rs->sr_ctrls = ctrls;
676
677 return_results:
678 if( dummy.e_attrs ) {
679 attrs_free( dummy.e_attrs );
680 }
681 send_ldap_result( op, rs );
682
683 done:
684 slap_graduate_commit_csn( op );
685
686 if( wc && wc->is_begin_transaction ){
687 Debug( LDAP_DEBUG_TRACE, "wt_modify: rollback transaction\n" );
688 wc->session->rollback_transaction(wc->session, NULL);
689 wc->is_begin_transaction = 0;
690 }
691
692 if( e != NULL ) {
693 wt_entry_return( e );
694 }
695
696 if( preread_ctrl != NULL && (*preread_ctrl) != NULL ) {
697 slap_sl_free( (*preread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx );
698 slap_sl_free( *preread_ctrl, op->o_tmpmemctx );
699 }
700 if( postread_ctrl != NULL && (*postread_ctrl) != NULL ) {
701 slap_sl_free( (*postread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx );
702 slap_sl_free( *postread_ctrl, op->o_tmpmemctx );
703 }
704
705 return rs->sr_err;
706 }
707
708 /*
709 * Local variables:
710 * indent-tabs-mode: t
711 * tab-width: 4
712 * c-basic-offset: 4
713 * End:
714 */