1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 1996,2008 Oracle.  All rights reserved.
5 *
6 * $Id: db.src,v 12.14 2008/01/30 04:30:36 mjc Exp $
7 */
8
9DBPRIVATE
10PREFIX	__db
11
12INCLUDE #include "db_int.h"
13INCLUDE #include "dbinc/crypto.h"
14INCLUDE #include "dbinc/db_page.h"
15INCLUDE #include "dbinc/db_dispatch.h"
16INCLUDE #include "dbinc/db_am.h"
17INCLUDE #include "dbinc/log.h"
18INCLUDE #include "dbinc/txn.h"
19INCLUDE
20
21/*
22 * addrem -- Add or remove an entry from a duplicate page.
23 *
24 * opcode:	identifies if this is an add or delete.
25 * fileid:	file identifier of the file being modified.
26 * pgno:	duplicate page number.
27 * indx:	location at which to insert or delete.
28 * nbytes:	number of bytes added/removed to/from the page.
29 * hdr:		header for the data item.
30 * dbt:		data that is deleted or is to be added.
31 * pagelsn:	former lsn of the page.
32 *
33 * If the hdr was NULL then, the dbt is a regular B_KEYDATA.
34 * If the dbt was NULL then the hdr is a complete item to be
35 * pasted on the page.
36 */
37BEGIN addrem		42	41
38ARG	opcode		u_int32_t	lu
39DB	fileid		int32_t		ld
40ARG	pgno		db_pgno_t	lu
41ARG	indx		u_int32_t	lu
42ARG	nbytes		u_int32_t	lu
43DBT	hdr		DBT		s
44DBT	dbt		DBT		s
45POINTER	pagelsn		DB_LSN *	lu
46END
47
48/*
49 * big -- Handles addition and deletion of big key/data items.
50 *
51 * opcode:	identifies get/put.
52 * fileid:	file identifier of the file being modified.
53 * pgno:	page onto which data is being added/removed.
54 * prev_pgno:	the page before the one we are logging.
55 * next_pgno:	the page after the one we are logging.
56 * dbt:		data being written onto the page.
57 * pagelsn:	former lsn of the orig_page.
58 * prevlsn:	former lsn of the prev_pgno.
59 * nextlsn:	former lsn of the next_pgno. This is not currently used, but
60 *		may be used later if we actually do overwrites of big key/
61 *		data items in place.
62 */
63BEGIN big		42	43
64ARG	opcode		u_int32_t	lu
65DB	fileid		int32_t		ld
66ARG	pgno		db_pgno_t	lu
67ARG	prev_pgno	db_pgno_t	lu
68ARG	next_pgno	db_pgno_t	lu
69DBT	dbt		DBT		s
70POINTER	pagelsn		DB_LSN *	lu
71POINTER	prevlsn		DB_LSN *	lu
72POINTER	nextlsn		DB_LSN *	lu
73END
74
75/*
76 * ovref -- Handles increment/decrement of overflow page reference count.
77 *
78 * fileid:	identifies the file being modified.
79 * pgno:	page number whose ref count is being incremented/decremented.
80 * adjust:	the adjustment being made.
81 * lsn:		the page's original lsn.
82 */
83BEGIN ovref		42	44
84DB	fileid		int32_t		ld
85ARG	pgno		db_pgno_t	lu
86ARG	adjust		int32_t		ld
87POINTER	lsn		DB_LSN *	lu
88END
89
90/*
91 * relink -- Handles relinking around a page.
92 *
93 * opcode:	indicates if this is an addpage or delete page
94 * pgno:	the page being changed.
95 * lsn		the page's original lsn.
96 * prev:	the previous page.
97 * lsn_prev:	the previous page's original lsn.
98 * next:	the next page.
99 * lsn_next:	the previous page's original lsn.
100 */
101BEGIN_COMPAT relink		42	45
102ARG	opcode		u_int32_t	lu
103DB	fileid		int32_t		ld
104ARG	pgno		db_pgno_t	lu
105POINTER	lsn		DB_LSN *	lu
106ARG	prev		db_pgno_t	lu
107POINTER	lsn_prev	DB_LSN *	lu
108ARG	next		db_pgno_t	lu
109POINTER	lsn_next	DB_LSN *	lu
110END
111
112/*
113 * Debug -- log an operation upon entering an access method.
114 * op:		Operation (cursor, c_close, c_get, c_put, c_del,
115 *		get, put, delete).
116 * fileid:	identifies the file being acted upon.
117 * key:		key paramater
118 * data:	data parameter
119 * flags:	flags parameter
120 */
121BEGIN debug		42	47
122DBT	op		DBT		s
123ARG	fileid		int32_t		ld
124DBT	key		DBT		s
125DBT	data		DBT		s
126ARG	arg_flags	u_int32_t	lu
127END
128
129/*
130 * noop -- do nothing, but get an LSN.
131 */
132BEGIN noop		42	48
133DB	fileid		int32_t		ld
134ARG	pgno		db_pgno_t	lu
135POINTER	prevlsn		DB_LSN *	lu
136END
137
138/*
139 * pg_alloc: used to record allocating a new page.
140 *
141 * meta_lsn:	the original lsn of the page reference by meta_pgno.
142 * meta_pgno	the page pointing at the allocated page in the free list.
143 *			If the list is unsorted this is the metadata page.
144 * page_lsn:	the allocated page's original lsn.
145 * pgno:	the page allocated.
146 * ptype:	the type of the page allocated.
147 * next:	the next page on the free list.
148 * last_pgno:	the last page in the file after this op (4.3+).
149 */
150BEGIN_COMPAT pg_alloc	42	49
151DB	fileid		int32_t		ld
152POINTER	meta_lsn	DB_LSN *	lu
153ARG	meta_pgno	db_pgno_t	lu
154POINTER	page_lsn	DB_LSN *	lu
155ARG	pgno		db_pgno_t	lu
156ARG	ptype		u_int32_t	lu
157ARG	next		db_pgno_t	lu
158END
159
160BEGIN pg_alloc	43	49
161DB	fileid		int32_t		ld
162POINTER	meta_lsn	DB_LSN *	lu
163ARG	meta_pgno	db_pgno_t	lu
164POINTER	page_lsn	DB_LSN *	lu
165ARG	pgno		db_pgno_t	lu
166ARG	ptype		u_int32_t	lu
167ARG	next		db_pgno_t	lu
168ARG	last_pgno	db_pgno_t	lu
169END
170
171/*
172 * pg_free: used to record freeing a page.
173 *	If we are maintaining a sorted free list (during compact) meta_pgno
174 * will be non-zero and refer to the page that preceeds the one we are freeing
175 * in the free list.  Meta_lsn will then be the lsn of that page.
176 *
177 * pgno:	the page being freed.
178 * meta_lsn:	the meta-data page's original lsn.
179 * meta_pgno:	the meta-data page number.
180 * header:	the header from the free'd page.
181 * next:	the previous next pointer on the metadata page.
182 * last_pgno:	the last page in the file before this op (4.3+).
183 */
184BEGIN_COMPAT pg_free		42	50
185DB	fileid		int32_t		ld
186ARG	pgno		db_pgno_t	lu
187POINTER	meta_lsn	DB_LSN *	lu
188ARG	meta_pgno	db_pgno_t	lu
189PGDBT	header		DBT		s
190ARG	next		db_pgno_t	lu
191END
192
193BEGIN pg_free		43	50
194DB	fileid		int32_t		ld
195ARG	pgno		db_pgno_t	lu
196POINTER	meta_lsn	DB_LSN *	lu
197ARG	meta_pgno	db_pgno_t	lu
198PGDBT	header		DBT		s
199ARG	next		db_pgno_t	lu
200ARG	last_pgno	db_pgno_t	lu
201END
202
203/*
204 * cksum --
205 *	This log record is written when we're unable to checksum a page,
206 *	before returning DB_RUNRECOVERY.  This log record causes normal
207 *	recovery to itself return DB_RUNRECOVERY, as only catastrophic
208 *	recovery can fix things.
209 */
210BEGIN cksum		42	51
211END
212
213/*
214 * pg_freedata: used to record freeing a page with data on it.
215 *
216 * pgno:	the page being freed.
217 * meta_lsn:	the meta-data page's original lsn.
218 * meta_pgno:	the meta-data page number.
219 * header:	the header and index entries from the free'd page.
220 * data:	the data from the free'd page.
221 * next:	the previous next pointer on the metadata page.
222 * last_pgno:	the last page in the file before this op (4.3+).
223 */
224BEGIN_COMPAT pg_freedata		42	52
225DB	fileid		int32_t		ld
226ARG	pgno		db_pgno_t	lu
227POINTER	meta_lsn	DB_LSN *	lu
228ARG	meta_pgno	db_pgno_t	lu
229PGDBT	header		DBT		s
230ARG	next		db_pgno_t	lu
231PGDDBT	data		DBT		s
232END
233
234BEGIN pg_freedata		43	52
235DB	fileid		int32_t		ld
236ARG	pgno		db_pgno_t	lu
237POINTER	meta_lsn	DB_LSN *	lu
238ARG	meta_pgno	db_pgno_t	lu
239PGDBT	header		DBT		s
240ARG	next		db_pgno_t	lu
241ARG	last_pgno	db_pgno_t	lu
242PGDDBT	data		DBT		s
243END
244
245/*
246 * pg_prepare: used to record an aborted page in a prepared transaction.
247 *
248 * pgno:	the page being freed.
249 */
250X BEGIN pg_prepare		42	53
251X DB	fileid		int32_t		ld
252X ARG	pgno		db_pgno_t	lu
253X END
254
255/*
256 * pg_new: used to record a new page put on the free list.
257 *
258 * pgno:	the page being freed.
259 * meta_lsn:	the meta-data page's original lsn.
260 * meta_pgno:	the meta-data page number.
261 * header:	the header from the free'd page.
262 * next:	the previous next pointer on the metadata page.
263 */
264X BEGIN pg_new		42	54
265X DB	fileid		int32_t		ld
266X ARG	pgno		db_pgno_t	lu
267X POINTER	meta_lsn	DB_LSN *	lu
268X ARG	meta_pgno	db_pgno_t	lu
269X PGDBT	header		DBT		s
270X ARG	next		db_pgno_t	lu
271X END
272
273/*
274 * pg_init: used to reinitialize a page during truncate.
275 *
276 * pgno:	the page being initialized.
277 * header:	the header from the page.
278 * data:	data that used to be on the page.
279 */
280BEGIN pg_init		43	60
281DB	fileid		int32_t		ld
282ARG	pgno		db_pgno_t	lu
283PGDBT	header		DBT		s
284PGDDBT	data		DBT		s
285END
286
287/*
288 * pg_sort: sort the free list
289 *
290 * meta:	meta page number
291 * meta_lsn:	lsn on meta page.
292 * last_free:	page number of new last free page.
293 * last_lsn;	lsn of last free page.
294 * last_pgno:	current last page number.
295 * list:	list of pages and lsns to sort.
296 */
297BEGIN pg_sort		44	61
298DB	fileid		int32_t		ld
299ARG	meta		db_pgno_t	lu
300POINTER	meta_lsn	DB_LSN *	lu
301ARG	last_free	db_pgno_t	lu
302POINTER	last_lsn	DB_LSN *	lu
303ARG	last_pgno	db_pgno_t	lu
304DBT	list		DBT		s
305END
306
307