1 | /*- |
---|
2 | * See the file LICENSE for redistribution information. |
---|
3 | * |
---|
4 | * Copyright (c) 1996-2002 |
---|
5 | * Sleepycat Software. All rights reserved. |
---|
6 | * |
---|
7 | * Id: btree.src,v 10.35 2002/04/17 19:02:56 krinsky Exp |
---|
8 | */ |
---|
9 | |
---|
10 | PREFIX __bam |
---|
11 | DBPRIVATE |
---|
12 | |
---|
13 | INCLUDE #include "db_config.h" |
---|
14 | INCLUDE |
---|
15 | INCLUDE #ifndef NO_SYSTEM_INCLUDES |
---|
16 | INCLUDE #include <sys/types.h> |
---|
17 | INCLUDE |
---|
18 | INCLUDE #include <ctype.h> |
---|
19 | INCLUDE #include <string.h> |
---|
20 | INCLUDE #endif |
---|
21 | INCLUDE |
---|
22 | INCLUDE #include "db_int.h" |
---|
23 | INCLUDE #include "dbinc/crypto.h" |
---|
24 | INCLUDE #include "dbinc/db_page.h" |
---|
25 | INCLUDE #include "dbinc/db_dispatch.h" |
---|
26 | INCLUDE #include "dbinc/db_am.h" |
---|
27 | INCLUDE #include "dbinc/btree.h" |
---|
28 | INCLUDE #include "dbinc/log.h" |
---|
29 | INCLUDE #include "dbinc/rep.h" |
---|
30 | INCLUDE #include "dbinc/txn.h" |
---|
31 | INCLUDE |
---|
32 | |
---|
33 | /* |
---|
34 | * NOTE: pg_alloc and pg_free have been moved to db.src, where they belong. |
---|
35 | */ |
---|
36 | |
---|
37 | /* |
---|
38 | * BTREE-split: used to log a page split. |
---|
39 | * |
---|
40 | * left: the page number for the low-order contents. |
---|
41 | * llsn: the left page's original LSN. |
---|
42 | * right: the page number for the high-order contents. |
---|
43 | * rlsn: the right page's original LSN. |
---|
44 | * indx: the number of entries that went to the left page. |
---|
45 | * npgno: the next page number |
---|
46 | * nlsn: the next page's original LSN (or 0 if no next page). |
---|
47 | * root_pgno: the root page number |
---|
48 | * pg: the split page's contents before the split. |
---|
49 | * opflags: SPL_NRECS: if splitting a tree that maintains a record count. |
---|
50 | */ |
---|
51 | BEGIN split 62 |
---|
52 | DB fileid int32_t ld |
---|
53 | WRLOCK left db_pgno_t lu |
---|
54 | POINTER llsn DB_LSN * lu |
---|
55 | WRLOCK right db_pgno_t lu |
---|
56 | POINTER rlsn DB_LSN * lu |
---|
57 | ARG indx u_int32_t lu |
---|
58 | ARG npgno db_pgno_t lu |
---|
59 | POINTER nlsn DB_LSN * lu |
---|
60 | WRLOCKNZ root_pgno db_pgno_t lu |
---|
61 | PGDBT pg DBT s |
---|
62 | ARG opflags u_int32_t lu |
---|
63 | END |
---|
64 | |
---|
65 | /* |
---|
66 | * BTREE-rsplit: used to log a reverse-split |
---|
67 | * |
---|
68 | * pgno: the page number of the page copied over the root. |
---|
69 | * pgdbt: the page being copied on the root page. |
---|
70 | * root_pgno: the root page number. |
---|
71 | * nrec: the tree's record count. |
---|
72 | * rootent: last entry on the root page. |
---|
73 | * rootlsn: the root page's original lsn. |
---|
74 | */ |
---|
75 | BEGIN rsplit 63 |
---|
76 | DB fileid int32_t ld |
---|
77 | WRLOCK pgno db_pgno_t lu |
---|
78 | PGDBT pgdbt DBT s |
---|
79 | WRLOCK root_pgno db_pgno_t lu |
---|
80 | ARG nrec db_pgno_t lu |
---|
81 | DBT rootent DBT s |
---|
82 | POINTER rootlsn DB_LSN * lu |
---|
83 | END |
---|
84 | |
---|
85 | /* |
---|
86 | * BTREE-adj: used to log the adjustment of an index. |
---|
87 | * |
---|
88 | * pgno: the page modified. |
---|
89 | * lsn: the page's original lsn. |
---|
90 | * indx: the index adjusted. |
---|
91 | * indx_copy: the index to copy if inserting. |
---|
92 | * is_insert: 0 if a delete, 1 if an insert. |
---|
93 | */ |
---|
94 | BEGIN adj 55 |
---|
95 | DB fileid int32_t ld |
---|
96 | WRLOCK pgno db_pgno_t lu |
---|
97 | POINTER lsn DB_LSN * lu |
---|
98 | ARG indx u_int32_t lu |
---|
99 | ARG indx_copy u_int32_t lu |
---|
100 | ARG is_insert u_int32_t lu |
---|
101 | END |
---|
102 | |
---|
103 | /* |
---|
104 | * BTREE-cadjust: used to adjust the count change in an internal page. |
---|
105 | * |
---|
106 | * pgno: the page modified. |
---|
107 | * lsn: the page's original lsn. |
---|
108 | * indx: the index to be adjusted. |
---|
109 | * adjust: the signed adjustment. |
---|
110 | * opflags: CAD_UPDATEROOT: if root page count was adjusted. |
---|
111 | */ |
---|
112 | BEGIN cadjust 56 |
---|
113 | DB fileid int32_t ld |
---|
114 | WRLOCK pgno db_pgno_t lu |
---|
115 | POINTER lsn DB_LSN * lu |
---|
116 | ARG indx u_int32_t lu |
---|
117 | ARG adjust int32_t ld |
---|
118 | ARG opflags u_int32_t lu |
---|
119 | END |
---|
120 | |
---|
121 | /* |
---|
122 | * BTREE-cdel: used to log the intent-to-delete of a cursor record. |
---|
123 | * |
---|
124 | * pgno: the page modified. |
---|
125 | * lsn: the page's original lsn. |
---|
126 | * indx: the index to be deleted. |
---|
127 | */ |
---|
128 | BEGIN cdel 57 |
---|
129 | DB fileid int32_t ld |
---|
130 | WRLOCK pgno db_pgno_t lu |
---|
131 | POINTER lsn DB_LSN * lu |
---|
132 | ARG indx u_int32_t lu |
---|
133 | END |
---|
134 | |
---|
135 | /* |
---|
136 | * BTREE-repl: used to log the replacement of an item. |
---|
137 | * |
---|
138 | * pgno: the page modified. |
---|
139 | * lsn: the page's original lsn. |
---|
140 | * orig: the original data. |
---|
141 | * new: the replacement data. |
---|
142 | * duplicate: the prefix of the replacement that matches the original. |
---|
143 | */ |
---|
144 | BEGIN repl 58 |
---|
145 | DB fileid int32_t ld |
---|
146 | WRLOCK pgno db_pgno_t lu |
---|
147 | POINTER lsn DB_LSN * lu |
---|
148 | ARG indx u_int32_t lu |
---|
149 | ARG isdeleted u_int32_t lu |
---|
150 | DBT orig DBT s |
---|
151 | DBT repl DBT s |
---|
152 | ARG prefix u_int32_t lu |
---|
153 | ARG suffix u_int32_t lu |
---|
154 | END |
---|
155 | |
---|
156 | /* |
---|
157 | * BTREE-root: log the assignment of a root btree page. |
---|
158 | */ |
---|
159 | BEGIN root 59 |
---|
160 | DB fileid int32_t ld |
---|
161 | WRLOCK meta_pgno db_pgno_t lu |
---|
162 | WRLOCK root_pgno db_pgno_t lu |
---|
163 | POINTER meta_lsn DB_LSN * lu |
---|
164 | END |
---|
165 | |
---|
166 | /* |
---|
167 | * BTREE-curadj: undo cursor adjustments on txn abort. |
---|
168 | * Should only be processed during DB_TXN_ABORT. |
---|
169 | * NOTE: the first_indx field gets used to hold |
---|
170 | * signed index adjustment in one case. |
---|
171 | * care should be taken if its size is changed. |
---|
172 | */ |
---|
173 | BEGIN curadj 64 |
---|
174 | /* Fileid of db affected. */ |
---|
175 | DB fileid int32_t ld |
---|
176 | /* Which adjustment. */ |
---|
177 | ARG mode db_ca_mode ld |
---|
178 | /* Page entry is from. */ |
---|
179 | ARG from_pgno db_pgno_t lu |
---|
180 | /* Page entry went to. */ |
---|
181 | ARG to_pgno db_pgno_t lu |
---|
182 | /* Left page of root split. */ |
---|
183 | ARG left_pgno db_pgno_t lu |
---|
184 | /* First index of dup set. Also used as adjustment. */ |
---|
185 | ARG first_indx u_int32_t lu |
---|
186 | /* Index entry is from. */ |
---|
187 | ARG from_indx u_int32_t lu |
---|
188 | /* Index where entry went. */ |
---|
189 | ARG to_indx u_int32_t lu |
---|
190 | END |
---|
191 | |
---|
192 | /* |
---|
193 | * BTREE-rcuradj: undo cursor adjustments on txn abort in |
---|
194 | * renumbering recno trees. |
---|
195 | * Should only be processed during DB_TXN_ABORT. |
---|
196 | */ |
---|
197 | BEGIN rcuradj 65 |
---|
198 | /* Fileid of db affected. */ |
---|
199 | DB fileid int32_t ld |
---|
200 | /* Which adjustment. */ |
---|
201 | ARG mode ca_recno_arg ld |
---|
202 | /* Root page number. */ |
---|
203 | ARG root db_pgno_t ld |
---|
204 | /* Recno of the adjustment. */ |
---|
205 | ARG recno db_recno_t ld |
---|
206 | /* Order number of the adjustment. */ |
---|
207 | ARG order u_int32_t ld |
---|
208 | END |
---|