X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-bdb%2Fattr.c;h=4035ffc87ed422cdf8380931dde39a5218e46185;hb=cba0d05a9dfd3cad69380e3ee2b492ddd7c7ca84;hp=dd9d06f2db6c2cf9290452504fcb982e1b934c96;hpb=4788d897d240fd866e1b4daf3f8e6025029b9e30;p=openldap diff --git a/servers/slapd/back-bdb/attr.c b/servers/slapd/back-bdb/attr.c index dd9d06f2db..4035ffc87e 100644 --- a/servers/slapd/back-bdb/attr.c +++ b/servers/slapd/back-bdb/attr.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 2000-2008 The OpenLDAP Foundation. + * Copyright 2000-2011 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,14 +30,14 @@ * set point for insertion if ins is non-NULL */ int -bdb_attr_slot( struct bdb_info *bdb, AttributeDescription *ad, unsigned *ins ) +bdb_attr_slot( struct bdb_info *bdb, AttributeDescription *ad, int *ins ) { unsigned base = 0, cursor = 0; unsigned n = bdb->bi_nattrs; int val = 0; while ( 0 < n ) { - int pivot = n >> 1; + unsigned pivot = n >> 1; cursor = base + pivot; val = SLAP_PTRCMP( ad, bdb->bi_attrs[cursor]->ai_desc ); @@ -61,7 +61,7 @@ bdb_attr_slot( struct bdb_info *bdb, AttributeDescription *ad, unsigned *ins ) static int ainfo_insert( struct bdb_info *bdb, AttrInfo *a ) { - unsigned x; + int x; int i = bdb_attr_slot( bdb, a->ai_desc, &x ); /* Is it a dup? */ @@ -215,7 +215,7 @@ bdb_attr_index_config( goto done; } - if( slap_ad_is_binary( ad ) ) { + if( ad == slap_schema.si_ad_entryDN || slap_ad_is_binary( ad ) ) { if (c_reply) { snprintf(c_reply->msg, sizeof(c_reply->msg), "index of attribute \"%s\" disallowed", attrs[i] ); @@ -319,15 +319,20 @@ bdb_attr_index_config( if( rc ) { if ( bdb->bi_flags & BDB_IS_OPEN ) { AttrInfo *b = bdb_attr_mask( bdb, ad ); - /* If we were editing this attr, reset it */ - b->ai_indexmask &= ~BDB_INDEX_DELETING; - /* If this is leftover from a previous add, commit it */ - if ( b->ai_newmask ) - b->ai_indexmask = b->ai_newmask; - b->ai_newmask = a->ai_newmask; - ch_free( a ); - rc = 0; - continue; + /* If there is already an index defined for this attribute + * it must be replaced. Otherwise we end up with multiple + * olcIndex values for the same attribute */ + if ( b->ai_indexmask & BDB_INDEX_DELETING ) { + /* If we were editing this attr, reset it */ + b->ai_indexmask &= ~BDB_INDEX_DELETING; + /* If this is leftover from a previous add, commit it */ + if ( b->ai_newmask ) + b->ai_indexmask = b->ai_newmask; + b->ai_newmask = a->ai_newmask; + ch_free( a ); + rc = 0; + continue; + } } if (c_reply) { snprintf(c_reply->msg, sizeof(c_reply->msg),