make CURSOR of recno 0 do the right thing; copy the key out, too
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 24 Jun 1992 03:32:48 +0000 (19:32 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 24 Jun 1992 03:32:48 +0000 (19:32 -0800)
SCCS-vsn: lib/libc/db/recno/rec_seq.c 5.3

usr/src/lib/libc/db/recno/rec_seq.c

index f59634a..b36fad9 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)rec_seq.c  5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)rec_seq.c  5.3 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -75,10 +75,10 @@ __rec_seq(dbp, key, data, flags)
                return (RET_ERROR);
        }
        
                return (RET_ERROR);
        }
        
-       if (nrec > t->bt_nrecs) {
+       if (t->bt_nrecs == 0 || nrec > t->bt_nrecs) {
                if ((status = t->bt_irec(t, nrec)) != RET_SUCCESS)
                        return (status);
                if ((status = t->bt_irec(t, nrec)) != RET_SUCCESS)
                        return (status);
-               if (nrec > t->bt_nrecs)
+               if (t->bt_nrecs == 0 || nrec > t->bt_nrecs)
                        return (RET_SPECIAL);
        }
 
                        return (RET_SPECIAL);
        }
 
@@ -86,6 +86,8 @@ __rec_seq(dbp, key, data, flags)
                return (RET_ERROR);
 
        if ((status = __rec_ret(t, e, data)) == RET_SUCCESS) {
                return (RET_ERROR);
 
        if ((status = __rec_ret(t, e, data)) == RET_SUCCESS) {
+               key->size = sizeof(recno_t);
+               bcopy(&nrec, key->data, sizeof(recno_t));
                t->bt_rcursor = nrec;
                SET(t, BTF_SEQINIT);
                UNSET(t, BTF_DELCRSR);
                t->bt_rcursor = nrec;
                SET(t, BTF_SEQINIT);
                UNSET(t, BTF_DELCRSR);