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