xref: /illumos-gate/usr/src/cmd/sendmail/db/db/db_rec.c (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*-
2*7c478bd9Sstevel@tonic-gate  * See the file LICENSE for redistribution information.
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1996, 1997, 1998
5*7c478bd9Sstevel@tonic-gate  *	Sleepycat Software.  All rights reserved.
6*7c478bd9Sstevel@tonic-gate  */
7*7c478bd9Sstevel@tonic-gate 
8*7c478bd9Sstevel@tonic-gate #include "config.h"
9*7c478bd9Sstevel@tonic-gate 
10*7c478bd9Sstevel@tonic-gate #ifndef lint
11*7c478bd9Sstevel@tonic-gate static const char sccsid[] = "@(#)db_rec.c	10.19 (Sleepycat) 9/27/98";
12*7c478bd9Sstevel@tonic-gate #endif /* not lint */
13*7c478bd9Sstevel@tonic-gate 
14*7c478bd9Sstevel@tonic-gate #ifndef NO_SYSTEM_INCLUDES
15*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
16*7c478bd9Sstevel@tonic-gate 
17*7c478bd9Sstevel@tonic-gate #include <string.h>
18*7c478bd9Sstevel@tonic-gate #endif
19*7c478bd9Sstevel@tonic-gate 
20*7c478bd9Sstevel@tonic-gate #include "db_int.h"
21*7c478bd9Sstevel@tonic-gate #include "shqueue.h"
22*7c478bd9Sstevel@tonic-gate #include "db_page.h"
23*7c478bd9Sstevel@tonic-gate #include "log.h"
24*7c478bd9Sstevel@tonic-gate #include "hash.h"
25*7c478bd9Sstevel@tonic-gate #include "btree.h"
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*
28*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __db_addrem_recover
29*7c478bd9Sstevel@tonic-gate  * PUBLIC:    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
30*7c478bd9Sstevel@tonic-gate  *
31*7c478bd9Sstevel@tonic-gate  * This log message is generated whenever we add or remove a duplicate
32*7c478bd9Sstevel@tonic-gate  * to/from a duplicate page.  On recover, we just do the opposite.
33*7c478bd9Sstevel@tonic-gate  */
34*7c478bd9Sstevel@tonic-gate int
__db_addrem_recover(logp,dbtp,lsnp,redo,info)35*7c478bd9Sstevel@tonic-gate __db_addrem_recover(logp, dbtp, lsnp, redo, info)
36*7c478bd9Sstevel@tonic-gate 	DB_LOG *logp;
37*7c478bd9Sstevel@tonic-gate 	DBT *dbtp;
38*7c478bd9Sstevel@tonic-gate 	DB_LSN *lsnp;
39*7c478bd9Sstevel@tonic-gate 	int redo;
40*7c478bd9Sstevel@tonic-gate 	void *info;
41*7c478bd9Sstevel@tonic-gate {
42*7c478bd9Sstevel@tonic-gate 	__db_addrem_args *argp;
43*7c478bd9Sstevel@tonic-gate 	DB *file_dbp;
44*7c478bd9Sstevel@tonic-gate 	DBC *dbc;
45*7c478bd9Sstevel@tonic-gate 	DB_MPOOLFILE *mpf;
46*7c478bd9Sstevel@tonic-gate 	PAGE *pagep;
47*7c478bd9Sstevel@tonic-gate 	u_int32_t change;
48*7c478bd9Sstevel@tonic-gate 	int cmp_n, cmp_p, ret;
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate 	REC_PRINT(__db_addrem_print);
51*7c478bd9Sstevel@tonic-gate 	REC_INTRO(__db_addrem_read);
52*7c478bd9Sstevel@tonic-gate 
53*7c478bd9Sstevel@tonic-gate 	if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0) {
54*7c478bd9Sstevel@tonic-gate 		if (!redo) {
55*7c478bd9Sstevel@tonic-gate 			/*
56*7c478bd9Sstevel@tonic-gate 			 * We are undoing and the page doesn't exist.  That
57*7c478bd9Sstevel@tonic-gate 			 * is equivalent to having a pagelsn of 0, so we
58*7c478bd9Sstevel@tonic-gate 			 * would not have to undo anything.  In this case,
59*7c478bd9Sstevel@tonic-gate 			 * don't bother creating a page.
60*7c478bd9Sstevel@tonic-gate 			 */
61*7c478bd9Sstevel@tonic-gate 			goto done;
62*7c478bd9Sstevel@tonic-gate 		} else
63*7c478bd9Sstevel@tonic-gate 			if ((ret = memp_fget(mpf,
64*7c478bd9Sstevel@tonic-gate 			    &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0)
65*7c478bd9Sstevel@tonic-gate 				goto out;
66*7c478bd9Sstevel@tonic-gate 	}
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate 	cmp_n = log_compare(lsnp, &LSN(pagep));
69*7c478bd9Sstevel@tonic-gate 	cmp_p = log_compare(&LSN(pagep), &argp->pagelsn);
70*7c478bd9Sstevel@tonic-gate 	change = 0;
71*7c478bd9Sstevel@tonic-gate 	if ((cmp_p == 0 && redo && argp->opcode == DB_ADD_DUP) ||
72*7c478bd9Sstevel@tonic-gate 	    (cmp_n == 0 && !redo && argp->opcode == DB_REM_DUP)) {
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate 		/* Need to redo an add, or undo a delete. */
75*7c478bd9Sstevel@tonic-gate 		if ((ret = __db_pitem(dbc, pagep, argp->indx, argp->nbytes,
76*7c478bd9Sstevel@tonic-gate 		    argp->hdr.size == 0 ? NULL : &argp->hdr,
77*7c478bd9Sstevel@tonic-gate 		    argp->dbt.size == 0 ? NULL : &argp->dbt)) != 0)
78*7c478bd9Sstevel@tonic-gate 			goto out;
79*7c478bd9Sstevel@tonic-gate 
80*7c478bd9Sstevel@tonic-gate 		change = DB_MPOOL_DIRTY;
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate 	} else if ((cmp_n == 0 && !redo && argp->opcode == DB_ADD_DUP) ||
83*7c478bd9Sstevel@tonic-gate 	    (cmp_p == 0 && redo && argp->opcode == DB_REM_DUP)) {
84*7c478bd9Sstevel@tonic-gate 		/* Need to undo an add, or redo a delete. */
85*7c478bd9Sstevel@tonic-gate 		if ((ret = __db_ditem(dbc,
86*7c478bd9Sstevel@tonic-gate 		    pagep, argp->indx, argp->nbytes)) != 0)
87*7c478bd9Sstevel@tonic-gate 			goto out;
88*7c478bd9Sstevel@tonic-gate 		change = DB_MPOOL_DIRTY;
89*7c478bd9Sstevel@tonic-gate 	}
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate 	if (change)
92*7c478bd9Sstevel@tonic-gate 		if (redo)
93*7c478bd9Sstevel@tonic-gate 			LSN(pagep) = *lsnp;
94*7c478bd9Sstevel@tonic-gate 		else
95*7c478bd9Sstevel@tonic-gate 			LSN(pagep) = argp->pagelsn;
96*7c478bd9Sstevel@tonic-gate 
97*7c478bd9Sstevel@tonic-gate 	if ((ret = memp_fput(mpf, pagep, change)) != 0)
98*7c478bd9Sstevel@tonic-gate 		goto out;
99*7c478bd9Sstevel@tonic-gate 
100*7c478bd9Sstevel@tonic-gate done:	*lsnp = argp->prev_lsn;
101*7c478bd9Sstevel@tonic-gate 	ret = 0;
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate out:	REC_CLOSE;
104*7c478bd9Sstevel@tonic-gate }
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate /*
107*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __db_split_recover __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
108*7c478bd9Sstevel@tonic-gate  */
109*7c478bd9Sstevel@tonic-gate int
__db_split_recover(logp,dbtp,lsnp,redo,info)110*7c478bd9Sstevel@tonic-gate __db_split_recover(logp, dbtp, lsnp, redo, info)
111*7c478bd9Sstevel@tonic-gate 	DB_LOG *logp;
112*7c478bd9Sstevel@tonic-gate 	DBT *dbtp;
113*7c478bd9Sstevel@tonic-gate 	DB_LSN *lsnp;
114*7c478bd9Sstevel@tonic-gate 	int redo;
115*7c478bd9Sstevel@tonic-gate 	void *info;
116*7c478bd9Sstevel@tonic-gate {
117*7c478bd9Sstevel@tonic-gate 	__db_split_args *argp;
118*7c478bd9Sstevel@tonic-gate 	DB *file_dbp;
119*7c478bd9Sstevel@tonic-gate 	DBC *dbc;
120*7c478bd9Sstevel@tonic-gate 	DB_MPOOLFILE *mpf;
121*7c478bd9Sstevel@tonic-gate 	PAGE *pagep;
122*7c478bd9Sstevel@tonic-gate 	int change, cmp_n, cmp_p, ret;
123*7c478bd9Sstevel@tonic-gate 
124*7c478bd9Sstevel@tonic-gate 	REC_PRINT(__db_split_print);
125*7c478bd9Sstevel@tonic-gate 	REC_INTRO(__db_split_read);
126*7c478bd9Sstevel@tonic-gate 
127*7c478bd9Sstevel@tonic-gate 	if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0)
128*7c478bd9Sstevel@tonic-gate 		if (!redo) {
129*7c478bd9Sstevel@tonic-gate 			/*
130*7c478bd9Sstevel@tonic-gate 			 * We are undoing and the page doesn't exist.  That
131*7c478bd9Sstevel@tonic-gate 			 * is equivalent to having a pagelsn of 0, so we
132*7c478bd9Sstevel@tonic-gate 			 * would not have to undo anything.  In this case,
133*7c478bd9Sstevel@tonic-gate 			 * don't bother creating a page.
134*7c478bd9Sstevel@tonic-gate 			 */
135*7c478bd9Sstevel@tonic-gate 			goto done;
136*7c478bd9Sstevel@tonic-gate 		} else
137*7c478bd9Sstevel@tonic-gate 			if ((ret = memp_fget(mpf,
138*7c478bd9Sstevel@tonic-gate 			    &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0)
139*7c478bd9Sstevel@tonic-gate 				goto out;
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate 	/*
142*7c478bd9Sstevel@tonic-gate 	 * There are two types of log messages here, one for the old page
143*7c478bd9Sstevel@tonic-gate 	 * and one for the new pages created.  The original image in the
144*7c478bd9Sstevel@tonic-gate 	 * SPLITOLD record is used for undo.  The image in the SPLITNEW
145*7c478bd9Sstevel@tonic-gate 	 * is used for redo.  We should never have a case where there is
146*7c478bd9Sstevel@tonic-gate 	 * a redo operation and the SPLITOLD record is on disk, but not
147*7c478bd9Sstevel@tonic-gate 	 * the SPLITNEW record.  Therefore, we only redo NEW messages
148*7c478bd9Sstevel@tonic-gate 	 * and only undo OLD messages.
149*7c478bd9Sstevel@tonic-gate 	 */
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate 	change = 0;
152*7c478bd9Sstevel@tonic-gate 	cmp_n = log_compare(lsnp, &LSN(pagep));
153*7c478bd9Sstevel@tonic-gate 	cmp_p = log_compare(&LSN(pagep), &argp->pagelsn);
154*7c478bd9Sstevel@tonic-gate 	if (cmp_p == 0 && redo) {
155*7c478bd9Sstevel@tonic-gate 		if (argp->opcode == DB_SPLITNEW) {
156*7c478bd9Sstevel@tonic-gate 			/* Need to redo the split described. */
157*7c478bd9Sstevel@tonic-gate 			memcpy(pagep,
158*7c478bd9Sstevel@tonic-gate 			    argp->pageimage.data, argp->pageimage.size);
159*7c478bd9Sstevel@tonic-gate 		}
160*7c478bd9Sstevel@tonic-gate 		LSN(pagep) = *lsnp;
161*7c478bd9Sstevel@tonic-gate 		change = DB_MPOOL_DIRTY;
162*7c478bd9Sstevel@tonic-gate 	} else if (cmp_n == 0 && !redo) {
163*7c478bd9Sstevel@tonic-gate 		if (argp->opcode == DB_SPLITOLD) {
164*7c478bd9Sstevel@tonic-gate 			/* Put back the old image. */
165*7c478bd9Sstevel@tonic-gate 			memcpy(pagep,
166*7c478bd9Sstevel@tonic-gate 			    argp->pageimage.data, argp->pageimage.size);
167*7c478bd9Sstevel@tonic-gate 		}
168*7c478bd9Sstevel@tonic-gate 		LSN(pagep) = argp->pagelsn;
169*7c478bd9Sstevel@tonic-gate 		change = DB_MPOOL_DIRTY;
170*7c478bd9Sstevel@tonic-gate 	}
171*7c478bd9Sstevel@tonic-gate 	if ((ret = memp_fput(mpf, pagep, change)) != 0)
172*7c478bd9Sstevel@tonic-gate 		goto out;
173*7c478bd9Sstevel@tonic-gate 
174*7c478bd9Sstevel@tonic-gate done:	*lsnp = argp->prev_lsn;
175*7c478bd9Sstevel@tonic-gate 	ret = 0;
176*7c478bd9Sstevel@tonic-gate 
177*7c478bd9Sstevel@tonic-gate out:	REC_CLOSE;
178*7c478bd9Sstevel@tonic-gate }
179*7c478bd9Sstevel@tonic-gate 
180*7c478bd9Sstevel@tonic-gate /*
181*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __db_big_recover __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
182*7c478bd9Sstevel@tonic-gate  */
183*7c478bd9Sstevel@tonic-gate int
__db_big_recover(logp,dbtp,lsnp,redo,info)184*7c478bd9Sstevel@tonic-gate __db_big_recover(logp, dbtp, lsnp, redo, info)
185*7c478bd9Sstevel@tonic-gate 	DB_LOG *logp;
186*7c478bd9Sstevel@tonic-gate 	DBT *dbtp;
187*7c478bd9Sstevel@tonic-gate 	DB_LSN *lsnp;
188*7c478bd9Sstevel@tonic-gate 	int redo;
189*7c478bd9Sstevel@tonic-gate 	void *info;
190*7c478bd9Sstevel@tonic-gate {
191*7c478bd9Sstevel@tonic-gate 	__db_big_args *argp;
192*7c478bd9Sstevel@tonic-gate 	DB *file_dbp;
193*7c478bd9Sstevel@tonic-gate 	DBC *dbc;
194*7c478bd9Sstevel@tonic-gate 	DB_MPOOLFILE *mpf;
195*7c478bd9Sstevel@tonic-gate 	PAGE *pagep;
196*7c478bd9Sstevel@tonic-gate 	u_int32_t change;
197*7c478bd9Sstevel@tonic-gate 	int cmp_n, cmp_p, ret;
198*7c478bd9Sstevel@tonic-gate 
199*7c478bd9Sstevel@tonic-gate 	REC_PRINT(__db_big_print);
200*7c478bd9Sstevel@tonic-gate 	REC_INTRO(__db_big_read);
201*7c478bd9Sstevel@tonic-gate 
202*7c478bd9Sstevel@tonic-gate 	if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0) {
203*7c478bd9Sstevel@tonic-gate 		if (!redo) {
204*7c478bd9Sstevel@tonic-gate 			/*
205*7c478bd9Sstevel@tonic-gate 			 * We are undoing and the page doesn't exist.  That
206*7c478bd9Sstevel@tonic-gate 			 * is equivalent to having a pagelsn of 0, so we
207*7c478bd9Sstevel@tonic-gate 			 * would not have to undo anything.  In this case,
208*7c478bd9Sstevel@tonic-gate 			 * don't bother creating a page.
209*7c478bd9Sstevel@tonic-gate 			 */
210*7c478bd9Sstevel@tonic-gate 			ret = 0;
211*7c478bd9Sstevel@tonic-gate 			goto ppage;
212*7c478bd9Sstevel@tonic-gate 		} else
213*7c478bd9Sstevel@tonic-gate 			if ((ret = memp_fget(mpf,
214*7c478bd9Sstevel@tonic-gate 			    &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0)
215*7c478bd9Sstevel@tonic-gate 				goto out;
216*7c478bd9Sstevel@tonic-gate 	}
217*7c478bd9Sstevel@tonic-gate 
218*7c478bd9Sstevel@tonic-gate 	/*
219*7c478bd9Sstevel@tonic-gate 	 * There are three pages we need to check.  The one on which we are
220*7c478bd9Sstevel@tonic-gate 	 * adding data, the previous one whose next_pointer may have
221*7c478bd9Sstevel@tonic-gate 	 * been updated, and the next one whose prev_pointer may have
222*7c478bd9Sstevel@tonic-gate 	 * been updated.
223*7c478bd9Sstevel@tonic-gate 	 */
224*7c478bd9Sstevel@tonic-gate 	cmp_n = log_compare(lsnp, &LSN(pagep));
225*7c478bd9Sstevel@tonic-gate 	cmp_p = log_compare(&LSN(pagep), &argp->pagelsn);
226*7c478bd9Sstevel@tonic-gate 	change = 0;
227*7c478bd9Sstevel@tonic-gate 	if ((cmp_p == 0 && redo && argp->opcode == DB_ADD_BIG) ||
228*7c478bd9Sstevel@tonic-gate 	    (cmp_n == 0 && !redo && argp->opcode == DB_REM_BIG)) {
229*7c478bd9Sstevel@tonic-gate 		/* We are either redo-ing an add, or undoing a delete. */
230*7c478bd9Sstevel@tonic-gate 		P_INIT(pagep, file_dbp->pgsize, argp->pgno, argp->prev_pgno,
231*7c478bd9Sstevel@tonic-gate 			argp->next_pgno, 0, P_OVERFLOW);
232*7c478bd9Sstevel@tonic-gate 		OV_LEN(pagep) = argp->dbt.size;
233*7c478bd9Sstevel@tonic-gate 		OV_REF(pagep) = 1;
234*7c478bd9Sstevel@tonic-gate 		memcpy((u_int8_t *)pagep + P_OVERHEAD, argp->dbt.data,
235*7c478bd9Sstevel@tonic-gate 		    argp->dbt.size);
236*7c478bd9Sstevel@tonic-gate 		PREV_PGNO(pagep) = argp->prev_pgno;
237*7c478bd9Sstevel@tonic-gate 		change = DB_MPOOL_DIRTY;
238*7c478bd9Sstevel@tonic-gate 	} else if ((cmp_n == 0 && !redo && argp->opcode == DB_ADD_BIG) ||
239*7c478bd9Sstevel@tonic-gate 	    (cmp_p == 0 && redo && argp->opcode == DB_REM_BIG)) {
240*7c478bd9Sstevel@tonic-gate 		/*
241*7c478bd9Sstevel@tonic-gate 		 * We are either undo-ing an add or redo-ing a delete.
242*7c478bd9Sstevel@tonic-gate 		 * The page is about to be reclaimed in either case, so
243*7c478bd9Sstevel@tonic-gate 		 * there really isn't anything to do here.
244*7c478bd9Sstevel@tonic-gate 		 */
245*7c478bd9Sstevel@tonic-gate 		change = DB_MPOOL_DIRTY;
246*7c478bd9Sstevel@tonic-gate 	}
247*7c478bd9Sstevel@tonic-gate 	if (change)
248*7c478bd9Sstevel@tonic-gate 		LSN(pagep) = redo ? *lsnp : argp->pagelsn;
249*7c478bd9Sstevel@tonic-gate 
250*7c478bd9Sstevel@tonic-gate 	if ((ret = memp_fput(mpf, pagep, change)) != 0)
251*7c478bd9Sstevel@tonic-gate 		goto out;
252*7c478bd9Sstevel@tonic-gate 
253*7c478bd9Sstevel@tonic-gate 	/* Now check the previous page. */
254*7c478bd9Sstevel@tonic-gate ppage:	if (argp->prev_pgno != PGNO_INVALID) {
255*7c478bd9Sstevel@tonic-gate 		change = 0;
256*7c478bd9Sstevel@tonic-gate 		if ((ret = memp_fget(mpf, &argp->prev_pgno, 0, &pagep)) != 0)
257*7c478bd9Sstevel@tonic-gate 			if (!redo) {
258*7c478bd9Sstevel@tonic-gate 				/*
259*7c478bd9Sstevel@tonic-gate 				 * We are undoing and the page doesn't exist.
260*7c478bd9Sstevel@tonic-gate 				 * That is equivalent to having a pagelsn of 0,
261*7c478bd9Sstevel@tonic-gate 				 * so we would not have to undo anything.  In
262*7c478bd9Sstevel@tonic-gate 				 * this case, don't bother creating a page.
263*7c478bd9Sstevel@tonic-gate 				 */
264*7c478bd9Sstevel@tonic-gate 				*lsnp = argp->prev_lsn;
265*7c478bd9Sstevel@tonic-gate 				ret = 0;
266*7c478bd9Sstevel@tonic-gate 				goto npage;
267*7c478bd9Sstevel@tonic-gate 			} else
268*7c478bd9Sstevel@tonic-gate 				if ((ret = memp_fget(mpf, &argp->prev_pgno,
269*7c478bd9Sstevel@tonic-gate 				    DB_MPOOL_CREATE, &pagep)) != 0)
270*7c478bd9Sstevel@tonic-gate 					goto out;
271*7c478bd9Sstevel@tonic-gate 
272*7c478bd9Sstevel@tonic-gate 		cmp_n = log_compare(lsnp, &LSN(pagep));
273*7c478bd9Sstevel@tonic-gate 		cmp_p = log_compare(&LSN(pagep), &argp->prevlsn);
274*7c478bd9Sstevel@tonic-gate 
275*7c478bd9Sstevel@tonic-gate 		if ((cmp_p == 0 && redo && argp->opcode == DB_ADD_BIG) ||
276*7c478bd9Sstevel@tonic-gate 		    (cmp_n == 0 && !redo && argp->opcode == DB_REM_BIG)) {
277*7c478bd9Sstevel@tonic-gate 			/* Redo add, undo delete. */
278*7c478bd9Sstevel@tonic-gate 			NEXT_PGNO(pagep) = argp->pgno;
279*7c478bd9Sstevel@tonic-gate 			change = DB_MPOOL_DIRTY;
280*7c478bd9Sstevel@tonic-gate 		} else if ((cmp_n == 0 &&
281*7c478bd9Sstevel@tonic-gate 		    !redo && argp->opcode == DB_ADD_BIG) ||
282*7c478bd9Sstevel@tonic-gate 		    (cmp_p == 0 && redo && argp->opcode == DB_REM_BIG)) {
283*7c478bd9Sstevel@tonic-gate 			/* Redo delete, undo add. */
284*7c478bd9Sstevel@tonic-gate 			NEXT_PGNO(pagep) = argp->next_pgno;
285*7c478bd9Sstevel@tonic-gate 			change = DB_MPOOL_DIRTY;
286*7c478bd9Sstevel@tonic-gate 		}
287*7c478bd9Sstevel@tonic-gate 		if (change)
288*7c478bd9Sstevel@tonic-gate 			LSN(pagep) = redo ? *lsnp : argp->prevlsn;
289*7c478bd9Sstevel@tonic-gate 		if ((ret = memp_fput(mpf, pagep, change)) != 0)
290*7c478bd9Sstevel@tonic-gate 			goto out;
291*7c478bd9Sstevel@tonic-gate 	}
292*7c478bd9Sstevel@tonic-gate 
293*7c478bd9Sstevel@tonic-gate 	/* Now check the next page.  Can only be set on a delete. */
294*7c478bd9Sstevel@tonic-gate npage:	if (argp->next_pgno != PGNO_INVALID) {
295*7c478bd9Sstevel@tonic-gate 		change = 0;
296*7c478bd9Sstevel@tonic-gate 		if ((ret = memp_fget(mpf, &argp->next_pgno, 0, &pagep)) != 0)
297*7c478bd9Sstevel@tonic-gate 			if (!redo) {
298*7c478bd9Sstevel@tonic-gate 				/*
299*7c478bd9Sstevel@tonic-gate 				 * We are undoing and the page doesn't exist.
300*7c478bd9Sstevel@tonic-gate 				 * That is equivalent to having a pagelsn of 0,
301*7c478bd9Sstevel@tonic-gate 				 * so we would not have to undo anything.  In
302*7c478bd9Sstevel@tonic-gate 				 * this case, don't bother creating a page.
303*7c478bd9Sstevel@tonic-gate 				 */
304*7c478bd9Sstevel@tonic-gate 				goto done;
305*7c478bd9Sstevel@tonic-gate 			} else
306*7c478bd9Sstevel@tonic-gate 				if ((ret = memp_fget(mpf, &argp->next_pgno,
307*7c478bd9Sstevel@tonic-gate 				    DB_MPOOL_CREATE, &pagep)) != 0)
308*7c478bd9Sstevel@tonic-gate 					goto out;
309*7c478bd9Sstevel@tonic-gate 
310*7c478bd9Sstevel@tonic-gate 		cmp_n = log_compare(lsnp, &LSN(pagep));
311*7c478bd9Sstevel@tonic-gate 		cmp_p = log_compare(&LSN(pagep), &argp->nextlsn);
312*7c478bd9Sstevel@tonic-gate 		if (cmp_p == 0 && redo) {
313*7c478bd9Sstevel@tonic-gate 			PREV_PGNO(pagep) = PGNO_INVALID;
314*7c478bd9Sstevel@tonic-gate 			change = DB_MPOOL_DIRTY;
315*7c478bd9Sstevel@tonic-gate 		} else if (cmp_n == 0 && !redo) {
316*7c478bd9Sstevel@tonic-gate 			PREV_PGNO(pagep) = argp->pgno;
317*7c478bd9Sstevel@tonic-gate 			change = DB_MPOOL_DIRTY;
318*7c478bd9Sstevel@tonic-gate 		}
319*7c478bd9Sstevel@tonic-gate 		if (change)
320*7c478bd9Sstevel@tonic-gate 			LSN(pagep) = redo ? *lsnp : argp->nextlsn;
321*7c478bd9Sstevel@tonic-gate 		if ((ret = memp_fput(mpf, pagep, change)) != 0)
322*7c478bd9Sstevel@tonic-gate 			goto out;
323*7c478bd9Sstevel@tonic-gate 	}
324*7c478bd9Sstevel@tonic-gate 
325*7c478bd9Sstevel@tonic-gate done:	*lsnp = argp->prev_lsn;
326*7c478bd9Sstevel@tonic-gate 	ret = 0;
327*7c478bd9Sstevel@tonic-gate 
328*7c478bd9Sstevel@tonic-gate out:	REC_CLOSE;
329*7c478bd9Sstevel@tonic-gate }
330*7c478bd9Sstevel@tonic-gate 
331*7c478bd9Sstevel@tonic-gate /*
332*7c478bd9Sstevel@tonic-gate  * __db_ovref_recover --
333*7c478bd9Sstevel@tonic-gate  *	Recovery function for __db_ovref().
334*7c478bd9Sstevel@tonic-gate  *
335*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __db_ovref_recover __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
336*7c478bd9Sstevel@tonic-gate  */
337*7c478bd9Sstevel@tonic-gate int
__db_ovref_recover(logp,dbtp,lsnp,redo,info)338*7c478bd9Sstevel@tonic-gate __db_ovref_recover(logp, dbtp, lsnp, redo, info)
339*7c478bd9Sstevel@tonic-gate 	DB_LOG *logp;
340*7c478bd9Sstevel@tonic-gate 	DBT *dbtp;
341*7c478bd9Sstevel@tonic-gate 	DB_LSN *lsnp;
342*7c478bd9Sstevel@tonic-gate 	int redo;
343*7c478bd9Sstevel@tonic-gate 	void *info;
344*7c478bd9Sstevel@tonic-gate {
345*7c478bd9Sstevel@tonic-gate 	__db_ovref_args *argp;
346*7c478bd9Sstevel@tonic-gate 	DB *file_dbp;
347*7c478bd9Sstevel@tonic-gate 	DBC *dbc;
348*7c478bd9Sstevel@tonic-gate 	DB_MPOOLFILE *mpf;
349*7c478bd9Sstevel@tonic-gate 	PAGE *pagep;
350*7c478bd9Sstevel@tonic-gate 	int modified, ret;
351*7c478bd9Sstevel@tonic-gate 
352*7c478bd9Sstevel@tonic-gate 	REC_PRINT(__db_ovref_print);
353*7c478bd9Sstevel@tonic-gate 	REC_INTRO(__db_ovref_read);
354*7c478bd9Sstevel@tonic-gate 
355*7c478bd9Sstevel@tonic-gate 	if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0) {
356*7c478bd9Sstevel@tonic-gate 		(void)__db_pgerr(file_dbp, argp->pgno);
357*7c478bd9Sstevel@tonic-gate 		goto out;
358*7c478bd9Sstevel@tonic-gate 	}
359*7c478bd9Sstevel@tonic-gate 
360*7c478bd9Sstevel@tonic-gate 	modified = 0;
361*7c478bd9Sstevel@tonic-gate 	if (log_compare(&LSN(pagep), &argp->lsn) == 0 && redo) {
362*7c478bd9Sstevel@tonic-gate 		/* Need to redo update described. */
363*7c478bd9Sstevel@tonic-gate 		OV_REF(pagep) += argp->adjust;
364*7c478bd9Sstevel@tonic-gate 
365*7c478bd9Sstevel@tonic-gate 		pagep->lsn = *lsnp;
366*7c478bd9Sstevel@tonic-gate 		modified = 1;
367*7c478bd9Sstevel@tonic-gate 	} else if (log_compare(lsnp, &LSN(pagep)) == 0 && !redo) {
368*7c478bd9Sstevel@tonic-gate 		/* Need to undo update described. */
369*7c478bd9Sstevel@tonic-gate 		OV_REF(pagep) -= argp->adjust;
370*7c478bd9Sstevel@tonic-gate 
371*7c478bd9Sstevel@tonic-gate 		pagep->lsn = argp->lsn;
372*7c478bd9Sstevel@tonic-gate 		modified = 1;
373*7c478bd9Sstevel@tonic-gate 	}
374*7c478bd9Sstevel@tonic-gate 	if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0)
375*7c478bd9Sstevel@tonic-gate 		goto out;
376*7c478bd9Sstevel@tonic-gate 
377*7c478bd9Sstevel@tonic-gate done:	*lsnp = argp->prev_lsn;
378*7c478bd9Sstevel@tonic-gate 	ret = 0;
379*7c478bd9Sstevel@tonic-gate 
380*7c478bd9Sstevel@tonic-gate out:	REC_CLOSE;
381*7c478bd9Sstevel@tonic-gate }
382*7c478bd9Sstevel@tonic-gate 
383*7c478bd9Sstevel@tonic-gate /*
384*7c478bd9Sstevel@tonic-gate  * __db_relink_recover --
385*7c478bd9Sstevel@tonic-gate  *	Recovery function for relink.
386*7c478bd9Sstevel@tonic-gate  *
387*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __db_relink_recover
388*7c478bd9Sstevel@tonic-gate  * PUBLIC:   __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
389*7c478bd9Sstevel@tonic-gate  */
390*7c478bd9Sstevel@tonic-gate int
__db_relink_recover(logp,dbtp,lsnp,redo,info)391*7c478bd9Sstevel@tonic-gate __db_relink_recover(logp, dbtp, lsnp, redo, info)
392*7c478bd9Sstevel@tonic-gate 	DB_LOG *logp;
393*7c478bd9Sstevel@tonic-gate 	DBT *dbtp;
394*7c478bd9Sstevel@tonic-gate 	DB_LSN *lsnp;
395*7c478bd9Sstevel@tonic-gate 	int redo;
396*7c478bd9Sstevel@tonic-gate 	void *info;
397*7c478bd9Sstevel@tonic-gate {
398*7c478bd9Sstevel@tonic-gate 	__db_relink_args *argp;
399*7c478bd9Sstevel@tonic-gate 	DB *file_dbp;
400*7c478bd9Sstevel@tonic-gate 	DBC *dbc;
401*7c478bd9Sstevel@tonic-gate 	DB_MPOOLFILE *mpf;
402*7c478bd9Sstevel@tonic-gate 	PAGE *pagep;
403*7c478bd9Sstevel@tonic-gate 	int cmp_n, cmp_p, modified, ret;
404*7c478bd9Sstevel@tonic-gate 
405*7c478bd9Sstevel@tonic-gate 	REC_PRINT(__db_relink_print);
406*7c478bd9Sstevel@tonic-gate 	REC_INTRO(__db_relink_read);
407*7c478bd9Sstevel@tonic-gate 
408*7c478bd9Sstevel@tonic-gate 	/*
409*7c478bd9Sstevel@tonic-gate 	 * There are up to three pages we need to check -- the page, and the
410*7c478bd9Sstevel@tonic-gate 	 * previous and next pages, if they existed.  For a page add operation,
411*7c478bd9Sstevel@tonic-gate 	 * the current page is the result of a split and is being recovered
412*7c478bd9Sstevel@tonic-gate 	 * elsewhere, so all we need do is recover the next page.
413*7c478bd9Sstevel@tonic-gate 	 */
414*7c478bd9Sstevel@tonic-gate 	if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0) {
415*7c478bd9Sstevel@tonic-gate 		if (redo) {
416*7c478bd9Sstevel@tonic-gate 			(void)__db_pgerr(file_dbp, argp->pgno);
417*7c478bd9Sstevel@tonic-gate 			goto out;
418*7c478bd9Sstevel@tonic-gate 		}
419*7c478bd9Sstevel@tonic-gate 		goto next;
420*7c478bd9Sstevel@tonic-gate 	}
421*7c478bd9Sstevel@tonic-gate 	if (argp->opcode == DB_ADD_PAGE)
422*7c478bd9Sstevel@tonic-gate 		goto next;
423*7c478bd9Sstevel@tonic-gate 
424*7c478bd9Sstevel@tonic-gate 	modified = 0;
425*7c478bd9Sstevel@tonic-gate 	if (log_compare(&LSN(pagep), &argp->lsn) == 0 && redo) {
426*7c478bd9Sstevel@tonic-gate 		/* Redo the relink. */
427*7c478bd9Sstevel@tonic-gate 		pagep->lsn = *lsnp;
428*7c478bd9Sstevel@tonic-gate 		modified = 1;
429*7c478bd9Sstevel@tonic-gate 	} else if (log_compare(lsnp, &LSN(pagep)) == 0 && !redo) {
430*7c478bd9Sstevel@tonic-gate 		/* Undo the relink. */
431*7c478bd9Sstevel@tonic-gate 		pagep->next_pgno = argp->next;
432*7c478bd9Sstevel@tonic-gate 		pagep->prev_pgno = argp->prev;
433*7c478bd9Sstevel@tonic-gate 
434*7c478bd9Sstevel@tonic-gate 		pagep->lsn = argp->lsn;
435*7c478bd9Sstevel@tonic-gate 		modified = 1;
436*7c478bd9Sstevel@tonic-gate 	}
437*7c478bd9Sstevel@tonic-gate 	if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0)
438*7c478bd9Sstevel@tonic-gate 		goto out;
439*7c478bd9Sstevel@tonic-gate 
440*7c478bd9Sstevel@tonic-gate next:	if ((ret = memp_fget(mpf, &argp->next, 0, &pagep)) != 0) {
441*7c478bd9Sstevel@tonic-gate 		if (redo) {
442*7c478bd9Sstevel@tonic-gate 			(void)__db_pgerr(file_dbp, argp->next);
443*7c478bd9Sstevel@tonic-gate 			goto out;
444*7c478bd9Sstevel@tonic-gate 		}
445*7c478bd9Sstevel@tonic-gate 		goto prev;
446*7c478bd9Sstevel@tonic-gate 	}
447*7c478bd9Sstevel@tonic-gate 	modified = 0;
448*7c478bd9Sstevel@tonic-gate 	cmp_n = log_compare(lsnp, &LSN(pagep));
449*7c478bd9Sstevel@tonic-gate 	cmp_p = log_compare(&LSN(pagep), &argp->lsn_next);
450*7c478bd9Sstevel@tonic-gate 	if ((argp->opcode == DB_REM_PAGE && cmp_p == 0 && redo) ||
451*7c478bd9Sstevel@tonic-gate 	    (argp->opcode == DB_ADD_PAGE && cmp_n == 0 && !redo)) {
452*7c478bd9Sstevel@tonic-gate 		/* Redo the remove or undo the add. */
453*7c478bd9Sstevel@tonic-gate 		pagep->prev_pgno = argp->prev;
454*7c478bd9Sstevel@tonic-gate 
455*7c478bd9Sstevel@tonic-gate 		pagep->lsn = *lsnp;
456*7c478bd9Sstevel@tonic-gate 		modified = 1;
457*7c478bd9Sstevel@tonic-gate 	} else if ((argp->opcode == DB_REM_PAGE && cmp_n == 0 && !redo) ||
458*7c478bd9Sstevel@tonic-gate 	    (argp->opcode == DB_ADD_PAGE && cmp_p == 0 && redo)) {
459*7c478bd9Sstevel@tonic-gate 		/* Undo the remove or redo the add. */
460*7c478bd9Sstevel@tonic-gate 		pagep->prev_pgno = argp->pgno;
461*7c478bd9Sstevel@tonic-gate 
462*7c478bd9Sstevel@tonic-gate 		pagep->lsn = argp->lsn_next;
463*7c478bd9Sstevel@tonic-gate 		modified = 1;
464*7c478bd9Sstevel@tonic-gate 	}
465*7c478bd9Sstevel@tonic-gate 	if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0)
466*7c478bd9Sstevel@tonic-gate 		goto out;
467*7c478bd9Sstevel@tonic-gate 	if (argp->opcode == DB_ADD_PAGE)
468*7c478bd9Sstevel@tonic-gate 		goto done;
469*7c478bd9Sstevel@tonic-gate 
470*7c478bd9Sstevel@tonic-gate prev:	if ((ret = memp_fget(mpf, &argp->prev, 0, &pagep)) != 0) {
471*7c478bd9Sstevel@tonic-gate 		if (redo) {
472*7c478bd9Sstevel@tonic-gate 			(void)__db_pgerr(file_dbp, argp->prev);
473*7c478bd9Sstevel@tonic-gate 			goto out;
474*7c478bd9Sstevel@tonic-gate 		}
475*7c478bd9Sstevel@tonic-gate 		goto done;
476*7c478bd9Sstevel@tonic-gate 	}
477*7c478bd9Sstevel@tonic-gate 	modified = 0;
478*7c478bd9Sstevel@tonic-gate 	if (log_compare(&LSN(pagep), &argp->lsn_prev) == 0 && redo) {
479*7c478bd9Sstevel@tonic-gate 		/* Redo the relink. */
480*7c478bd9Sstevel@tonic-gate 		pagep->next_pgno = argp->next;
481*7c478bd9Sstevel@tonic-gate 
482*7c478bd9Sstevel@tonic-gate 		pagep->lsn = *lsnp;
483*7c478bd9Sstevel@tonic-gate 		modified = 1;
484*7c478bd9Sstevel@tonic-gate 	} else if (log_compare(lsnp, &LSN(pagep)) == 0 && !redo) {
485*7c478bd9Sstevel@tonic-gate 		/* Undo the relink. */
486*7c478bd9Sstevel@tonic-gate 		pagep->next_pgno = argp->pgno;
487*7c478bd9Sstevel@tonic-gate 
488*7c478bd9Sstevel@tonic-gate 		pagep->lsn = argp->lsn_prev;
489*7c478bd9Sstevel@tonic-gate 		modified = 1;
490*7c478bd9Sstevel@tonic-gate 	}
491*7c478bd9Sstevel@tonic-gate 	if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0)
492*7c478bd9Sstevel@tonic-gate 		goto out;
493*7c478bd9Sstevel@tonic-gate 
494*7c478bd9Sstevel@tonic-gate done:	*lsnp = argp->prev_lsn;
495*7c478bd9Sstevel@tonic-gate 	ret = 0;
496*7c478bd9Sstevel@tonic-gate 
497*7c478bd9Sstevel@tonic-gate out:	REC_CLOSE;
498*7c478bd9Sstevel@tonic-gate }
499*7c478bd9Sstevel@tonic-gate 
500*7c478bd9Sstevel@tonic-gate /*
501*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __db_addpage_recover
502*7c478bd9Sstevel@tonic-gate  * PUBLIC:    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
503*7c478bd9Sstevel@tonic-gate  */
504*7c478bd9Sstevel@tonic-gate int
__db_addpage_recover(logp,dbtp,lsnp,redo,info)505*7c478bd9Sstevel@tonic-gate __db_addpage_recover(logp, dbtp, lsnp, redo, info)
506*7c478bd9Sstevel@tonic-gate 	DB_LOG *logp;
507*7c478bd9Sstevel@tonic-gate 	DBT *dbtp;
508*7c478bd9Sstevel@tonic-gate 	DB_LSN *lsnp;
509*7c478bd9Sstevel@tonic-gate 	int redo;
510*7c478bd9Sstevel@tonic-gate 	void *info;
511*7c478bd9Sstevel@tonic-gate {
512*7c478bd9Sstevel@tonic-gate 	__db_addpage_args *argp;
513*7c478bd9Sstevel@tonic-gate 	DB *file_dbp;
514*7c478bd9Sstevel@tonic-gate 	DBC *dbc;
515*7c478bd9Sstevel@tonic-gate 	DB_MPOOLFILE *mpf;
516*7c478bd9Sstevel@tonic-gate 	PAGE *pagep;
517*7c478bd9Sstevel@tonic-gate 	u_int32_t change;
518*7c478bd9Sstevel@tonic-gate 	int cmp_n, cmp_p, ret;
519*7c478bd9Sstevel@tonic-gate 
520*7c478bd9Sstevel@tonic-gate 	REC_PRINT(__db_addpage_print);
521*7c478bd9Sstevel@tonic-gate 	REC_INTRO(__db_addpage_read);
522*7c478bd9Sstevel@tonic-gate 
523*7c478bd9Sstevel@tonic-gate 	/*
524*7c478bd9Sstevel@tonic-gate 	 * We need to check two pages: the old one and the new one onto
525*7c478bd9Sstevel@tonic-gate 	 * which we're going to add duplicates.  Do the old one first.
526*7c478bd9Sstevel@tonic-gate 	 */
527*7c478bd9Sstevel@tonic-gate 	if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0)
528*7c478bd9Sstevel@tonic-gate 		goto out;
529*7c478bd9Sstevel@tonic-gate 
530*7c478bd9Sstevel@tonic-gate 	change = 0;
531*7c478bd9Sstevel@tonic-gate 	cmp_n = log_compare(lsnp, &LSN(pagep));
532*7c478bd9Sstevel@tonic-gate 	cmp_p = log_compare(&LSN(pagep), &argp->lsn);
533*7c478bd9Sstevel@tonic-gate 	if (cmp_p == 0 && redo) {
534*7c478bd9Sstevel@tonic-gate 		NEXT_PGNO(pagep) = argp->nextpgno;
535*7c478bd9Sstevel@tonic-gate 
536*7c478bd9Sstevel@tonic-gate 		LSN(pagep) = *lsnp;
537*7c478bd9Sstevel@tonic-gate 		change = DB_MPOOL_DIRTY;
538*7c478bd9Sstevel@tonic-gate 	} else if (cmp_n == 0 && !redo) {
539*7c478bd9Sstevel@tonic-gate 		NEXT_PGNO(pagep) = PGNO_INVALID;
540*7c478bd9Sstevel@tonic-gate 
541*7c478bd9Sstevel@tonic-gate 		LSN(pagep) = argp->lsn;
542*7c478bd9Sstevel@tonic-gate 		change = DB_MPOOL_DIRTY;
543*7c478bd9Sstevel@tonic-gate 	}
544*7c478bd9Sstevel@tonic-gate 	if ((ret = memp_fput(mpf, pagep, change)) != 0)
545*7c478bd9Sstevel@tonic-gate 		goto out;
546*7c478bd9Sstevel@tonic-gate 
547*7c478bd9Sstevel@tonic-gate 	if ((ret = memp_fget(mpf, &argp->nextpgno, 0, &pagep)) != 0)
548*7c478bd9Sstevel@tonic-gate 		if (!redo) {
549*7c478bd9Sstevel@tonic-gate 			/*
550*7c478bd9Sstevel@tonic-gate 			 * We are undoing and the page doesn't exist.  That
551*7c478bd9Sstevel@tonic-gate 			 * is equivalent to having a pagelsn of 0, so we
552*7c478bd9Sstevel@tonic-gate 			 * would not have to undo anything.  In this case,
553*7c478bd9Sstevel@tonic-gate 			 * don't bother creating a page.
554*7c478bd9Sstevel@tonic-gate 			 */
555*7c478bd9Sstevel@tonic-gate 			goto done;
556*7c478bd9Sstevel@tonic-gate 		} else
557*7c478bd9Sstevel@tonic-gate 			if ((ret = memp_fget(mpf,
558*7c478bd9Sstevel@tonic-gate 			    &argp->nextpgno, DB_MPOOL_CREATE, &pagep)) != 0)
559*7c478bd9Sstevel@tonic-gate 				goto out;
560*7c478bd9Sstevel@tonic-gate 
561*7c478bd9Sstevel@tonic-gate 	change = 0;
562*7c478bd9Sstevel@tonic-gate 	cmp_n = log_compare(lsnp, &LSN(pagep));
563*7c478bd9Sstevel@tonic-gate 	cmp_p = log_compare(&LSN(pagep), &argp->nextlsn);
564*7c478bd9Sstevel@tonic-gate 	if (cmp_p == 0 && redo) {
565*7c478bd9Sstevel@tonic-gate 		PREV_PGNO(pagep) = argp->pgno;
566*7c478bd9Sstevel@tonic-gate 
567*7c478bd9Sstevel@tonic-gate 		LSN(pagep) = *lsnp;
568*7c478bd9Sstevel@tonic-gate 		change = DB_MPOOL_DIRTY;
569*7c478bd9Sstevel@tonic-gate 	} else if (cmp_n == 0 && !redo) {
570*7c478bd9Sstevel@tonic-gate 		PREV_PGNO(pagep) = PGNO_INVALID;
571*7c478bd9Sstevel@tonic-gate 
572*7c478bd9Sstevel@tonic-gate 		LSN(pagep) = argp->nextlsn;
573*7c478bd9Sstevel@tonic-gate 		change = DB_MPOOL_DIRTY;
574*7c478bd9Sstevel@tonic-gate 	}
575*7c478bd9Sstevel@tonic-gate 	if ((ret = memp_fput(mpf, pagep, change)) != 0)
576*7c478bd9Sstevel@tonic-gate 		goto out;
577*7c478bd9Sstevel@tonic-gate 
578*7c478bd9Sstevel@tonic-gate done:	*lsnp = argp->prev_lsn;
579*7c478bd9Sstevel@tonic-gate 	ret = 0;
580*7c478bd9Sstevel@tonic-gate 
581*7c478bd9Sstevel@tonic-gate out:	REC_CLOSE;
582*7c478bd9Sstevel@tonic-gate }
583*7c478bd9Sstevel@tonic-gate 
584*7c478bd9Sstevel@tonic-gate /*
585*7c478bd9Sstevel@tonic-gate  * __db_debug_recover --
586*7c478bd9Sstevel@tonic-gate  *	Recovery function for debug.
587*7c478bd9Sstevel@tonic-gate  *
588*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __db_debug_recover __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
589*7c478bd9Sstevel@tonic-gate  */
590*7c478bd9Sstevel@tonic-gate int
__db_debug_recover(logp,dbtp,lsnp,redo,info)591*7c478bd9Sstevel@tonic-gate __db_debug_recover(logp, dbtp, lsnp, redo, info)
592*7c478bd9Sstevel@tonic-gate 	DB_LOG *logp;
593*7c478bd9Sstevel@tonic-gate 	DBT *dbtp;
594*7c478bd9Sstevel@tonic-gate 	DB_LSN *lsnp;
595*7c478bd9Sstevel@tonic-gate 	int redo;
596*7c478bd9Sstevel@tonic-gate 	void *info;
597*7c478bd9Sstevel@tonic-gate {
598*7c478bd9Sstevel@tonic-gate 	__db_debug_args *argp;
599*7c478bd9Sstevel@tonic-gate 	int ret;
600*7c478bd9Sstevel@tonic-gate 
601*7c478bd9Sstevel@tonic-gate 	COMPQUIET(redo, 0);
602*7c478bd9Sstevel@tonic-gate 	COMPQUIET(logp, NULL);
603*7c478bd9Sstevel@tonic-gate 
604*7c478bd9Sstevel@tonic-gate 	REC_PRINT(__db_debug_print);
605*7c478bd9Sstevel@tonic-gate 	REC_NOOP_INTRO(__db_debug_read);
606*7c478bd9Sstevel@tonic-gate 
607*7c478bd9Sstevel@tonic-gate 	*lsnp = argp->prev_lsn;
608*7c478bd9Sstevel@tonic-gate 	ret = 0;
609*7c478bd9Sstevel@tonic-gate 
610*7c478bd9Sstevel@tonic-gate 	REC_NOOP_CLOSE;
611*7c478bd9Sstevel@tonic-gate }
612