]> git.sur5r.net Git - openldap/commitdiff
Change list->range conversion again, avoid extra c_put.
authorHoward Chu <hyc@openldap.org>
Fri, 19 Jul 2002 23:19:53 +0000 (23:19 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 19 Jul 2002 23:19:53 +0000 (23:19 +0000)
servers/slapd/back-bdb/idl.c

index 8913404ade52b2eda0e205b9d8ab2a8f3594e1a0..09f86a7ccffd1c8507975c940ef42af46d70de77 100644 (file)
@@ -446,18 +446,30 @@ bdb_idl_insert_key(
                                }
                                if ( count >= BDB_IDL_DB_SIZE ) {
                                /* No room, convert to a range */
+                                       DBT key2 = *key;
+
+                                       key2.dlen = key2.ulen;
+                                       key2.flags |= DB_DBT_PARTIAL;
+
                                        lo = tmp;
-                                       hi = NOID;
                                        data.data = &hi;
-                                       rc = cursor->c_put( cursor, key, &data, DB_KEYLAST );
-                                       if ( rc != 0 ) {
-                                               err = "c_put NOID";
+                                       rc = cursor->c_get( cursor, &key2, &data, DB_NEXT_NODUP );
+                                       if ( rc != 0 && rc != DB_NOTFOUND ) {
+                                               err = "c_get next_nodup";
                                                goto fail;
                                        }
-                                       rc = cursor->c_get( cursor, key, &data, DB_PREV );
-                                       if ( rc != 0 ) {
-                                               err = "c_get prev";
-                                               goto fail;
+                                       if ( rc == DB_NOTFOUND ) {
+                                               rc = cursor->c_get( cursor, key, &data, DB_LAST );
+                                               if ( rc != 0 ) {
+                                                       err = "c_get last";
+                                                       goto fail;
+                                               }
+                                       } else {
+                                               rc = cursor->c_get( cursor, key, &data, DB_PREV );
+                                               if ( rc != 0 ) {
+                                                       err = "c_get prev";
+                                                       goto fail;
+                                               }
                                        }
                                        if ( id < lo )
                                                lo = id;