1 | /*- |
---|
2 | * See the file LICENSE for redistribution information. |
---|
3 | * |
---|
4 | * Copyright (c) 1996, 1997, 1998, 1999, 2000 |
---|
5 | * Sleepycat Software. All rights reserved. |
---|
6 | * |
---|
7 | * $Id: btree.src,v 1.1.1.2 2002-02-11 16:29:58 ghudson Exp $ |
---|
8 | */ |
---|
9 | |
---|
10 | PREFIX bam |
---|
11 | |
---|
12 | INCLUDE #include "db_config.h" |
---|
13 | INCLUDE |
---|
14 | INCLUDE #ifndef NO_SYSTEM_INCLUDES |
---|
15 | INCLUDE #include <sys/types.h> |
---|
16 | INCLUDE |
---|
17 | INCLUDE #include <ctype.h> |
---|
18 | INCLUDE #include <errno.h> |
---|
19 | INCLUDE #include <string.h> |
---|
20 | INCLUDE #endif |
---|
21 | INCLUDE |
---|
22 | INCLUDE #include "db_int.h" |
---|
23 | INCLUDE #include "db_page.h" |
---|
24 | INCLUDE #include "db_dispatch.h" |
---|
25 | INCLUDE #include "db_am.h" |
---|
26 | INCLUDE #include "btree.h" |
---|
27 | INCLUDE #include "txn.h" |
---|
28 | INCLUDE |
---|
29 | |
---|
30 | /* |
---|
31 | * BTREE-pg_alloc: used to record allocating a new page. |
---|
32 | * |
---|
33 | * meta_lsn: the meta-data page's original lsn. |
---|
34 | * alloc_lsn: the meta-data page's original allocation lsn. |
---|
35 | * page_lsn: the allocated page's original lsn. |
---|
36 | * pgno: the page allocated. |
---|
37 | * next: the next page on the free list. |
---|
38 | */ |
---|
39 | DEPRECATED pg_alloc1 51 |
---|
40 | ARG fileid int32_t ld |
---|
41 | POINTER meta_lsn DB_LSN * lu |
---|
42 | POINTER page_lsn DB_LSN * lu |
---|
43 | ARG pgno db_pgno_t lu |
---|
44 | ARG ptype u_int32_t lu |
---|
45 | ARG next db_pgno_t lu |
---|
46 | END |
---|
47 | |
---|
48 | BEGIN pg_alloc 60 |
---|
49 | ARG fileid int32_t ld |
---|
50 | POINTER meta_lsn DB_LSN * lu |
---|
51 | POINTER alloc_lsn DB_LSN * lu |
---|
52 | POINTER page_lsn DB_LSN * lu |
---|
53 | ARG pgno db_pgno_t lu |
---|
54 | ARG ptype u_int32_t lu |
---|
55 | ARG next db_pgno_t lu |
---|
56 | END |
---|
57 | |
---|
58 | /* |
---|
59 | * BTREE-pg_free: used to record freeing a page. |
---|
60 | * |
---|
61 | * pgno: the page being freed. |
---|
62 | * meta_lsn: the meta-data page's original lsn. |
---|
63 | * alloc_lsn: the meta-data page's original allocation lsn. |
---|
64 | * header: the header from the free'd page. |
---|
65 | * next: the previous next pointer on the metadata page. |
---|
66 | */ |
---|
67 | DEPRECATED pg_free1 52 |
---|
68 | ARG fileid int32_t ld |
---|
69 | ARG pgno db_pgno_t lu |
---|
70 | POINTER meta_lsn DB_LSN * lu |
---|
71 | DBT header DBT s |
---|
72 | ARG next db_pgno_t lu |
---|
73 | END |
---|
74 | |
---|
75 | BEGIN pg_free 61 |
---|
76 | ARG fileid int32_t ld |
---|
77 | ARG pgno db_pgno_t lu |
---|
78 | POINTER meta_lsn DB_LSN * lu |
---|
79 | POINTER alloc_lsn DB_LSN * lu |
---|
80 | DBT header DBT s |
---|
81 | ARG next db_pgno_t lu |
---|
82 | END |
---|
83 | |
---|
84 | /* |
---|
85 | * BTREE-split: used to log a page split. |
---|
86 | * |
---|
87 | * left: the page number for the low-order contents. |
---|
88 | * llsn: the left page's original LSN. |
---|
89 | * right: the page number for the high-order contents. |
---|
90 | * rlsn: the right page's original LSN. |
---|
91 | * indx: the number of entries that went to the left page. |
---|
92 | * npgno: the next page number |
---|
93 | * nlsn: the next page's original LSN (or 0 if no next page). |
---|
94 | * pg: the split page's contents before the split. |
---|
95 | */ |
---|
96 | DEPRECATED split1 53 |
---|
97 | ARG fileid int32_t ld |
---|
98 | ARG left db_pgno_t lu |
---|
99 | POINTER llsn DB_LSN * lu |
---|
100 | ARG right db_pgno_t lu |
---|
101 | POINTER rlsn DB_LSN * lu |
---|
102 | ARG indx u_int32_t lu |
---|
103 | ARG npgno db_pgno_t lu |
---|
104 | POINTER nlsn DB_LSN * lu |
---|
105 | DBT pg DBT s |
---|
106 | END |
---|
107 | |
---|
108 | /* |
---|
109 | * BTREE-split: used to log a page split. |
---|
110 | * |
---|
111 | * left: the page number for the low-order contents. |
---|
112 | * llsn: the left page's original LSN. |
---|
113 | * right: the page number for the high-order contents. |
---|
114 | * rlsn: the right page's original LSN. |
---|
115 | * indx: the number of entries that went to the left page. |
---|
116 | * npgno: the next page number |
---|
117 | * npgno: the next page number |
---|
118 | * nlsn: the next page's original LSN (or 0 if no next page). |
---|
119 | * root_pgno: the root page number |
---|
120 | * pg: the split page's contents before the split. |
---|
121 | * opflags: SPL_NRECS: if splitting a tree that maintains a record count. |
---|
122 | */ |
---|
123 | BEGIN split 62 |
---|
124 | ARG fileid int32_t ld |
---|
125 | ARG left db_pgno_t lu |
---|
126 | POINTER llsn DB_LSN * lu |
---|
127 | ARG right db_pgno_t lu |
---|
128 | POINTER rlsn DB_LSN * lu |
---|
129 | ARG indx u_int32_t lu |
---|
130 | ARG npgno db_pgno_t lu |
---|
131 | POINTER nlsn DB_LSN * lu |
---|
132 | ARG root_pgno db_pgno_t lu |
---|
133 | DBT pg DBT s |
---|
134 | ARG opflags u_int32_t lu |
---|
135 | END |
---|
136 | |
---|
137 | /* |
---|
138 | * BTREE-rsplit: used to log a reverse-split |
---|
139 | * |
---|
140 | * pgno: the page number of the page copied over the root. |
---|
141 | * pgdbt: the page being copied on the root page. |
---|
142 | * nrec: the tree's record count. |
---|
143 | * rootent: last entry on the root page. |
---|
144 | * rootlsn: the root page's original lsn. |
---|
145 | */ |
---|
146 | DEPRECATED rsplit1 54 |
---|
147 | ARG fileid int32_t ld |
---|
148 | ARG pgno db_pgno_t lu |
---|
149 | DBT pgdbt DBT s |
---|
150 | ARG nrec db_pgno_t lu |
---|
151 | DBT rootent DBT s |
---|
152 | POINTER rootlsn DB_LSN * lu |
---|
153 | END |
---|
154 | |
---|
155 | /* |
---|
156 | * BTREE-rsplit: used to log a reverse-split |
---|
157 | * |
---|
158 | * pgno: the page number of the page copied over the root. |
---|
159 | * pgdbt: the page being copied on the root page. |
---|
160 | * root_pgno: the root page number. |
---|
161 | * nrec: the tree's record count. |
---|
162 | * rootent: last entry on the root page. |
---|
163 | * rootlsn: the root page's original lsn. |
---|
164 | */ |
---|
165 | BEGIN rsplit 63 |
---|
166 | ARG fileid int32_t ld |
---|
167 | ARG pgno db_pgno_t lu |
---|
168 | DBT pgdbt DBT s |
---|
169 | ARG root_pgno db_pgno_t lu |
---|
170 | ARG nrec db_pgno_t lu |
---|
171 | DBT rootent DBT s |
---|
172 | POINTER rootlsn DB_LSN * lu |
---|
173 | END |
---|
174 | |
---|
175 | /* |
---|
176 | * BTREE-adj: used to log the adjustment of an index. |
---|
177 | * |
---|
178 | * pgno: the page modified. |
---|
179 | * lsn: the page's original lsn. |
---|
180 | * indx: the index adjusted. |
---|
181 | * indx_copy: the index to copy if inserting. |
---|
182 | * is_insert: 0 if a delete, 1 if an insert. |
---|
183 | */ |
---|
184 | BEGIN adj 55 |
---|
185 | ARG fileid int32_t ld |
---|
186 | ARG pgno db_pgno_t lu |
---|
187 | POINTER lsn DB_LSN * lu |
---|
188 | ARG indx u_int32_t lu |
---|
189 | ARG indx_copy u_int32_t lu |
---|
190 | ARG is_insert u_int32_t lu |
---|
191 | END |
---|
192 | |
---|
193 | /* |
---|
194 | * BTREE-cadjust: used to adjust the count change in an internal page. |
---|
195 | * |
---|
196 | * pgno: the page modified. |
---|
197 | * lsn: the page's original lsn. |
---|
198 | * indx: the index to be adjusted. |
---|
199 | * adjust: the signed adjustment. |
---|
200 | * opflags: CAD_UPDATEROOT: if root page count was adjusted. |
---|
201 | */ |
---|
202 | BEGIN cadjust 56 |
---|
203 | ARG fileid int32_t ld |
---|
204 | ARG pgno db_pgno_t lu |
---|
205 | POINTER lsn DB_LSN * lu |
---|
206 | ARG indx u_int32_t lu |
---|
207 | ARG adjust int32_t ld |
---|
208 | ARG opflags u_int32_t lu |
---|
209 | END |
---|
210 | |
---|
211 | /* |
---|
212 | * BTREE-cdel: used to log the intent-to-delete of a cursor record. |
---|
213 | * |
---|
214 | * pgno: the page modified. |
---|
215 | * lsn: the page's original lsn. |
---|
216 | * indx: the index to be deleted. |
---|
217 | */ |
---|
218 | BEGIN cdel 57 |
---|
219 | ARG fileid int32_t ld |
---|
220 | ARG pgno db_pgno_t lu |
---|
221 | POINTER lsn DB_LSN * lu |
---|
222 | ARG indx u_int32_t lu |
---|
223 | END |
---|
224 | |
---|
225 | /* |
---|
226 | * BTREE-repl: used to log the replacement of an item. |
---|
227 | * |
---|
228 | * pgno: the page modified. |
---|
229 | * lsn: the page's original lsn. |
---|
230 | * orig: the original data. |
---|
231 | * new: the replacement data. |
---|
232 | * duplicate: the prefix of the replacement that matches the original. |
---|
233 | */ |
---|
234 | BEGIN repl 58 |
---|
235 | ARG fileid int32_t ld |
---|
236 | ARG pgno db_pgno_t lu |
---|
237 | POINTER lsn DB_LSN * lu |
---|
238 | ARG indx u_int32_t lu |
---|
239 | ARG isdeleted u_int32_t lu |
---|
240 | DBT orig DBT s |
---|
241 | DBT repl DBT s |
---|
242 | ARG prefix u_int32_t lu |
---|
243 | ARG suffix u_int32_t lu |
---|
244 | END |
---|
245 | |
---|
246 | /* |
---|
247 | * BTREE-root: log the assignment of a root btree page. |
---|
248 | */ |
---|
249 | BEGIN root 59 |
---|
250 | ARG fileid int32_t ld |
---|
251 | ARG meta_pgno db_pgno_t lu |
---|
252 | ARG root_pgno db_pgno_t lu |
---|
253 | POINTER meta_lsn DB_LSN * lu |
---|
254 | END |
---|
255 | |
---|
256 | /* |
---|
257 | * BTREE-curadj: undo cursor adjustments on abort txn. |
---|
258 | * Should only be processed during DB_TXN_ABORT. |
---|
259 | * NOTE: the first_indx field gets used to hold |
---|
260 | * signed index adjustment in one case. |
---|
261 | * care should be taken if its size is changed. |
---|
262 | */ |
---|
263 | BEGIN curadj 64 |
---|
264 | /* Fileid of db effected. */ |
---|
265 | ARG fileid int32_t ld |
---|
266 | /* Which adjustment. */ |
---|
267 | ARG mode db_ca_mode ld |
---|
268 | /* Page entry is from. */ |
---|
269 | ARG from_pgno db_pgno_t lu |
---|
270 | /* Page entry went to. */ |
---|
271 | ARG to_pgno db_pgno_t lu |
---|
272 | /* Left page of root split. */ |
---|
273 | ARG left_pgno db_pgno_t lu |
---|
274 | /* First index of dup set. Also used as adjustment. */ |
---|
275 | ARG first_indx u_int32_t lu |
---|
276 | /* Index entry is from. */ |
---|
277 | ARG from_indx u_int32_t lu |
---|
278 | /* Index where entry went. */ |
---|
279 | ARG to_indx u_int32_t lu |
---|
280 | END |
---|