]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/attr.c
Merge remote branch 'origin/mdb.master'
[openldap] / servers / slapd / back-bdb / attr.c
index 2419a343bb02818eee259a5c5fab554be95e23a8..4035ffc87ed422cdf8380931dde39a5218e46185 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * 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
@@ -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),