If two keys compare equal, return the index of the matching key
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Thu, 12 Dec 1991 02:16:15 +0000 (18:16 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Thu, 12 Dec 1991 02:16:15 +0000 (18:16 -0800)
not the next index.  Test case is inserting two identical keys
into the database at the beginning of a page (before anything else).

SCCS-vsn: lib/libc/db/btree/bt_put.c 5.6

usr/src/lib/libc/db/btree/bt_put.c

index e8b36aa..53406d4 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_put.c   5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)bt_put.c   5.6 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -252,7 +252,7 @@ bt_fast(t, key, data, exactp)
                        goto miss;
                if ((cmp = __bt_cmp(t, key, &e)) < 0)
                        goto miss;
                        goto miss;
                if ((cmp = __bt_cmp(t, key, &e)) < 0)
                        goto miss;
-               t->bt_last.index = ++e.index;
+               t->bt_last.index = cmp ? ++e.index : e.index;
        } else {
                if (e.page->prevpg != P_INVALID)
                        goto miss;
        } else {
                if (e.page->prevpg != P_INVALID)
                        goto miss;