Deleted Added
full compact
rec_delete.c (1573) rec_delete.c (14272)
1/*-
1/*-
2 * Copyright (c) 1990, 1993
2 * Copyright (c) 1990, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Mike Olson.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:

--- 19 unchanged lines hidden (view full) ---

30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Mike Olson.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:

--- 19 unchanged lines hidden (view full) ---

30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char sccsid[] = "@(#)rec_delete.c 8.4 (Berkeley) 2/21/94";
38static char sccsid[] = "@(#)rec_delete.c 8.7 (Berkeley) 7/14/94";
39#endif /* LIBC_SCCS and not lint */
40
41#include <sys/types.h>
42
43#include <errno.h>
44#include <stdio.h>
45#include <string.h>
46

--- 36 unchanged lines hidden (view full) ---

83 if ((nrec = *(recno_t *)key->data) == 0)
84 goto einval;
85 if (nrec > t->bt_nrecs)
86 return (RET_SPECIAL);
87 --nrec;
88 status = rec_rdelete(t, nrec);
89 break;
90 case R_CURSOR:
39#endif /* LIBC_SCCS and not lint */
40
41#include <sys/types.h>
42
43#include <errno.h>
44#include <stdio.h>
45#include <string.h>
46

--- 36 unchanged lines hidden (view full) ---

83 if ((nrec = *(recno_t *)key->data) == 0)
84 goto einval;
85 if (nrec > t->bt_nrecs)
86 return (RET_SPECIAL);
87 --nrec;
88 status = rec_rdelete(t, nrec);
89 break;
90 case R_CURSOR:
91 if (!ISSET(t, B_SEQINIT))
91 if (!F_ISSET(&t->bt_cursor, CURS_INIT))
92 goto einval;
93 if (t->bt_nrecs == 0)
94 return (RET_SPECIAL);
92 goto einval;
93 if (t->bt_nrecs == 0)
94 return (RET_SPECIAL);
95 status = rec_rdelete(t, t->bt_rcursor - 1);
95 status = rec_rdelete(t, t->bt_cursor.rcursor - 1);
96 if (status == RET_SUCCESS)
96 if (status == RET_SUCCESS)
97 --t->bt_rcursor;
97 --t->bt_cursor.rcursor;
98 break;
99 default:
100einval: errno = EINVAL;
101 return (RET_ERROR);
102 }
103
104 if (status == RET_SUCCESS)
98 break;
99 default:
100einval: errno = EINVAL;
101 return (RET_ERROR);
102 }
103
104 if (status == RET_SUCCESS)
105 SET(t, B_MODIFIED | R_MODIFIED);
105 F_SET(t, B_MODIFIED | R_MODIFIED);
106 return (status);
107}
108
109/*
110 * REC_RDELETE -- Delete the data matching the specified key.
111 *
112 * Parameters:
113 * tree: tree

--- 35 unchanged lines hidden (view full) ---

149 *
150 * Returns:
151 * RET_SUCCESS, RET_ERROR.
152 */
153int
154__rec_dleaf(t, h, index)
155 BTREE *t;
156 PAGE *h;
106 return (status);
107}
108
109/*
110 * REC_RDELETE -- Delete the data matching the specified key.
111 *
112 * Parameters:
113 * tree: tree

--- 35 unchanged lines hidden (view full) ---

149 *
150 * Returns:
151 * RET_SUCCESS, RET_ERROR.
152 */
153int
154__rec_dleaf(t, h, index)
155 BTREE *t;
156 PAGE *h;
157 indx_t index;
157 u_int32_t index;
158{
158{
159 register RLEAF *rl;
160 register indx_t *ip, cnt, offset;
161 register size_t nbytes;
159 RLEAF *rl;
160 indx_t *ip, cnt, offset;
161 u_int32_t nbytes;
162 char *from;
163 void *to;
164
165 /*
166 * Delete a record from a recno leaf page. Internal records are never
167 * deleted from internal pages, regardless of the records that caused
168 * them to be added being deleted. Pages made empty by deletion are
169 * not reclaimed. They are, however, made available for reuse.

--- 28 unchanged lines hidden ---
162 char *from;
163 void *to;
164
165 /*
166 * Delete a record from a recno leaf page. Internal records are never
167 * deleted from internal pages, regardless of the records that caused
168 * them to be added being deleted. Pages made empty by deletion are
169 * not reclaimed. They are, however, made available for reuse.

--- 28 unchanged lines hidden ---