rec_seq.c (8870) | rec_seq.c (14287) |
---|---|
1/*- | 1/*- |
2 * Copyright (c) 1991, 1993 | 2 * Copyright (c) 1991, 1993, 1994 |
3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright --- 16 unchanged lines hidden (view full) --- 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint | 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright --- 16 unchanged lines hidden (view full) --- 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint |
35static char sccsid[] = "@(#)rec_seq.c 8.2 (Berkeley) 9/7/93"; | 35static char sccsid[] = "@(#)rec_seq.c 8.3 (Berkeley) 7/14/94"; |
36#endif /* not lint */ 37 38#include <sys/types.h> 39 40#include <errno.h> 41#include <limits.h> 42#include <stdio.h> 43#include <string.h> --- 33 unchanged lines hidden (view full) --- 77 } 78 79 switch(flags) { 80 case R_CURSOR: 81 if ((nrec = *(recno_t *)key->data) == 0) 82 goto einval; 83 break; 84 case R_NEXT: | 36#endif /* not lint */ 37 38#include <sys/types.h> 39 40#include <errno.h> 41#include <limits.h> 42#include <stdio.h> 43#include <string.h> --- 33 unchanged lines hidden (view full) --- 77 } 78 79 switch(flags) { 80 case R_CURSOR: 81 if ((nrec = *(recno_t *)key->data) == 0) 82 goto einval; 83 break; 84 case R_NEXT: |
85 if (ISSET(t, B_SEQINIT)) { 86 nrec = t->bt_rcursor + 1; | 85 if (F_ISSET(&t->bt_cursor, CURS_INIT)) { 86 nrec = t->bt_cursor.rcursor + 1; |
87 break; 88 } 89 /* FALLTHROUGH */ 90 case R_FIRST: 91 nrec = 1; 92 break; 93 case R_PREV: | 87 break; 88 } 89 /* FALLTHROUGH */ 90 case R_FIRST: 91 nrec = 1; 92 break; 93 case R_PREV: |
94 if (ISSET(t, B_SEQINIT)) { 95 if ((nrec = t->bt_rcursor - 1) == 0) | 94 if (F_ISSET(&t->bt_cursor, CURS_INIT)) { 95 if ((nrec = t->bt_cursor.rcursor - 1) == 0) |
96 return (RET_SPECIAL); 97 break; 98 } 99 /* FALLTHROUGH */ 100 case R_LAST: | 96 return (RET_SPECIAL); 97 break; 98 } 99 /* FALLTHROUGH */ 100 case R_LAST: |
101 if (!ISSET(t, R_EOF | R_INMEM) && | 101 if (!F_ISSET(t, R_EOF | R_INMEM) && |
102 t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR) 103 return (RET_ERROR); 104 nrec = t->bt_nrecs; 105 break; 106 default: 107einval: errno = EINVAL; 108 return (RET_ERROR); 109 } | 102 t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR) 103 return (RET_ERROR); 104 nrec = t->bt_nrecs; 105 break; 106 default: 107einval: errno = EINVAL; 108 return (RET_ERROR); 109 } |
110 | 110 |
111 if (t->bt_nrecs == 0 || nrec > t->bt_nrecs) { | 111 if (t->bt_nrecs == 0 || nrec > t->bt_nrecs) { |
112 if (!ISSET(t, R_EOF | R_INMEM) && | 112 if (!F_ISSET(t, R_EOF | R_INMEM) && |
113 (status = t->bt_irec(t, nrec)) != RET_SUCCESS) 114 return (status); 115 if (t->bt_nrecs == 0 || nrec > t->bt_nrecs) 116 return (RET_SPECIAL); 117 } 118 119 if ((e = __rec_search(t, nrec - 1, SEARCH)) == NULL) 120 return (RET_ERROR); 121 | 113 (status = t->bt_irec(t, nrec)) != RET_SUCCESS) 114 return (status); 115 if (t->bt_nrecs == 0 || nrec > t->bt_nrecs) 116 return (RET_SPECIAL); 117 } 118 119 if ((e = __rec_search(t, nrec - 1, SEARCH)) == NULL) 120 return (RET_ERROR); 121 |
122 SET(t, B_SEQINIT); 123 t->bt_rcursor = nrec; | 122 F_SET(&t->bt_cursor, CURS_INIT); 123 t->bt_cursor.rcursor = nrec; |
124 125 status = __rec_ret(t, e, nrec, key, data); | 124 125 status = __rec_ret(t, e, nrec, key, data); |
126 if (ISSET(t, B_DB_LOCK)) | 126 if (F_ISSET(t, B_DB_LOCK)) |
127 mpool_put(t->bt_mp, e->page, 0); 128 else 129 t->bt_pinned = e->page; 130 return (status); 131} | 127 mpool_put(t->bt_mp, e->page, 0); 128 else 129 t->bt_pinned = e->page; 130 return (status); 131} |