]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-mdb/idl.c
Merge remote-tracking branch 'origin/mdb.master'
[openldap] / servers / slapd / back-mdb / idl.c
index 29a3796345a84ce4efea3deed297e738a99d2f87..2cba7c27590745a9fc66f457589d53eb558c5ede 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2012 The OpenLDAP Foundation.
+ * Copyright 2000-2013 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -391,14 +391,16 @@ mdb_idl_fetch_key(
 
 int
 mdb_idl_insert_keys(
+       BackendDB       *be,
        MDB_cursor      *cursor,
        struct berval *keys,
        ID                      id )
 {
+       struct mdb_info *mdb = be->be_private;
        MDB_val key, data;
        ID lo, hi, *i;
        char *err;
-       int     rc, k;
+       int     rc = 0, k;
        unsigned int flag = MDB_NODUPDATA;
 #ifndef        MISALIGNED_OK
        int kbuf[2];
@@ -414,7 +416,7 @@ mdb_idl_insert_keys(
        assert( id != NOID );
 
 #ifndef MISALIGNED_OK
-       if (keys[0].bv_len & 0x03)
+       if (keys[0].bv_len & ALIGNER)
                kbuf[1] = 0;
 #endif
        for ( k=0; keys[k].bv_val; k++ ) {
@@ -422,7 +424,7 @@ mdb_idl_insert_keys(
         * exists and if it's a range.
         */
 #ifndef MISALIGNED_OK
-       if (keys[k].bv_len & 0x03) {
+       if (keys[k].bv_len & ALIGNER) {
                key.mv_size = sizeof(kbuf);
                key.mv_data = kbuf;
                memcpy(key.mv_data, keys[k].bv_val, keys[k].bv_len);
@@ -490,8 +492,8 @@ mdb_idl_insert_keys(
                                }
                        } else {
                        /* There's room, just store it */
-                               if ( slapMode & SLAP_TOOL_QUICK )
-                                       flag |= MDB_APPEND;
+                               if (id == mdb->mi_nextid)
+                                       flag |= MDB_APPENDDUP;
                                goto put1;
                        }
                } else {
@@ -518,6 +520,7 @@ mdb_idl_insert_keys(
                        }
                }
        } else if ( rc == MDB_NOTFOUND ) {
+               flag &= ~MDB_APPENDDUP;
 put1:  data.mv_data = &id;
                data.mv_size = sizeof(ID);
                rc = mdb_cursor_put( cursor, &key, &data, flag );
@@ -541,11 +544,12 @@ fail:
 
 int
 mdb_idl_delete_keys(
+       BackendDB       *be,
        MDB_cursor      *cursor,
        struct berval *keys,
        ID                      id )
 {
-       int     rc, k;
+       int     rc = 0, k;
        MDB_val key, data;
        ID lo, hi, tmp, *i;
        char *err;
@@ -562,7 +566,7 @@ mdb_idl_delete_keys(
        assert( id != NOID );
 
 #ifndef MISALIGNED_OK
-       if (keys[0].bv_len & 0x03)
+       if (keys[0].bv_len & ALIGNER)
                kbuf[1] = 0;
 #endif
        for ( k=0; keys[k].bv_val; k++) {
@@ -570,7 +574,7 @@ mdb_idl_delete_keys(
         * exists and if it's a range.
         */
 #ifndef MISALIGNED_OK
-       if (keys[k].bv_len & 0x03) {
+       if (keys[k].bv_len & ALIGNER) {
                key.mv_size = sizeof(kbuf);
                key.mv_data = kbuf;
                memcpy(key.mv_data, keys[k].bv_val, keys[k].bv_len);
@@ -1080,7 +1084,7 @@ mdb_idl_sort( ID *ids, ID *tmp )
 /* 8 bit Radix sort + insertion sort
  * 
  * based on code from http://www.cubic.org/docs/radix.htm
- * with improvements by mbackes@symas.com and hyc@symas.com
+ * with improvements by ebackes@symas.com and hyc@symas.com
  *
  * This code is O(n) but has a relatively high constant factor. For lists
  * up to ~50 Quicksort is slightly faster; up to ~100 they are even.