1
1
/* modify.c - bdb backend modify routine */
2
/* $OpenLDAP: pkg/ldap/servers/slapd/back-bdb/modify.c,v 1.156.2.11 2008/05/01 21:39:35 quanah Exp $ */
2
/* $OpenLDAP: pkg/ldap/servers/slapd/back-bdb/modify.c,v 1.156.2.16 2009/02/05 19:35:54 quanah Exp $ */
3
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5
* Copyright 2000-2008 The OpenLDAP Foundation.
5
* Copyright 2000-2009 The OpenLDAP Foundation.
6
6
* All rights reserved.
8
8
* Redistribution and use in source and binary forms, with or without
33
AttributeDescription *desc,
41
/* check if modified attribute was indexed
42
* but not in case of NOOP... */
43
ai = bdb_index_mask( op->o_bd, desc, &ix_at );
49
ap = attr_find( oldattrs, desc );
50
if ( ap ) ap->a_flags |= SLAP_ATTR_IXDEL;
52
/* Find all other attrs that index to same slot */
53
for ( ap = newattrs; ap; ap = ap->a_next ) {
54
ai = bdb_index_mask( op->o_bd, ap->a_desc, &ix2 );
55
if ( ai && ix2.bv_val == ix_at.bv_val )
56
ap->a_flags |= SLAP_ATTR_IXADD;
62
ap = attr_find( newattrs, desc );
63
if ( ap ) ap->a_flags |= SLAP_ATTR_IXADD;
30
68
int bdb_modify_internal(
203
239
if ( glue_attr_delete ) e->e_ocflags = 0;
205
242
/* check if modified attribute was indexed
206
243
* but not in case of NOOP... */
207
ai = bdb_index_mask( op->o_bd, mod->sm_desc, &ix_at );
208
if ( ai && !op->o_noop ) {
212
ap = attr_find( save_attrs, mod->sm_desc );
213
if ( ap ) ap->a_flags |= SLAP_ATTR_IXDEL;
215
/* Find all other attrs that index to same slot */
216
for ( ap = e->e_attrs; ap; ap=ap->a_next ) {
217
ai = bdb_index_mask( op->o_bd, ap->a_desc, &ix2 );
218
if ( ai && ix2.bv_val == ix_at.bv_val )
219
ap->a_flags |= SLAP_ATTR_IXADD;
222
ap = attr_find( e->e_attrs, mod->sm_desc );
223
if ( ap ) ap->a_flags |= SLAP_ATTR_IXADD;
245
bdb_modify_idxflags( op, mod->sm_desc, got_delete, e->e_attrs, save_attrs );
228
249
/* check that the entry still obeys the schema */
229
rc = entry_schema_check( op, e, save_attrs, get_relax(op), 0,
251
rc = entry_schema_check( op, e, save_attrs, get_relax(op), 0, &ap,
230
252
text, textbuf, textlen );
231
253
if ( rc != LDAP_SUCCESS || op->o_noop ) {
232
254
attrs_free( e->e_attrs );
271
/* structuralObjectClass modified! */
273
assert( ap->a_desc == slap_schema.si_ad_structuralObjectClass );
275
bdb_modify_idxflags( op, slap_schema.si_ad_structuralObjectClass,
276
1, e->e_attrs, save_attrs );
249
280
/* update the indices of the modified attributes */
251
282
/* start with deleting the old index entries */
287
318
rc = bdb_index_values( op, tid, ap->a_desc,
288
319
vals, e->e_id, SLAP_INDEX_DELETE_OP );
289
320
if ( rc != LDAP_SUCCESS ) {
321
Debug( LDAP_DEBUG_ANY,
322
"%s: attribute \"%s\" index delete failure\n",
323
op->o_log_prefix, ap->a_desc->ad_cname.bv_val, 0 );
290
324
attrs_free( e->e_attrs );
291
325
e->e_attrs = save_attrs;
292
Debug( LDAP_DEBUG_ANY,
293
"Attribute index delete failure",
307
338
e->e_id, SLAP_INDEX_ADD_OP );
308
339
if ( rc != LDAP_SUCCESS ) {
340
Debug( LDAP_DEBUG_ANY,
341
"%s: attribute \"%s\" index add failure\n",
342
op->o_log_prefix, ap->a_desc->ad_cname.bv_val, 0 );
309
343
attrs_free( e->e_attrs );
310
344
e->e_attrs = save_attrs;
311
Debug( LDAP_DEBUG_ANY,
312
"Attribute index add failure",
330
361
char textbuf[SLAP_TEXT_BUFLEN];
331
362
size_t textlen = sizeof textbuf;
332
363
DB_TXN *ltid = NULL, *lt2;
333
struct bdb_op_info opinfo = {0};
364
struct bdb_op_info opinfo = {{{ 0 }}};
334
365
Entry dummy = {0};
335
366
int fakeroot = 0;
337
BDB_LOCKER locker = 0;
340
370
int num_retries = 0;
655
683
attrs_free( dummy.e_attrs );
658
rc = bdb_cache_modify( bdb, e, dummy.e_attrs, locker, &lock );
686
rc = bdb_cache_modify( bdb, e, dummy.e_attrs, ltid, &lock );
660
688
case DB_LOCK_DEADLOCK:
661
689
case DB_LOCK_NOTGRANTED: