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  *	@(#)db_am.h	10.15 (Sleepycat) 11/22/98
8*7c478bd9Sstevel@tonic-gate  */
9*7c478bd9Sstevel@tonic-gate #ifndef _DB_AM_H
10*7c478bd9Sstevel@tonic-gate #define _DB_AM_H
11*7c478bd9Sstevel@tonic-gate 
12*7c478bd9Sstevel@tonic-gate #define DB_ISBIG	0x01
13*7c478bd9Sstevel@tonic-gate #define	DB_ADD_DUP	0x10
14*7c478bd9Sstevel@tonic-gate #define	DB_REM_DUP	0x20
15*7c478bd9Sstevel@tonic-gate #define	DB_ADD_BIG	0x30
16*7c478bd9Sstevel@tonic-gate #define	DB_REM_BIG	0x40
17*7c478bd9Sstevel@tonic-gate #define	DB_SPLITOLD	0x50
18*7c478bd9Sstevel@tonic-gate #define	DB_SPLITNEW	0x60
19*7c478bd9Sstevel@tonic-gate #define	DB_ADD_PAGE	0x70
20*7c478bd9Sstevel@tonic-gate #define	DB_REM_PAGE	0x80
21*7c478bd9Sstevel@tonic-gate 
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Standard initialization and shutdown macros for all recovery functions.
24*7c478bd9Sstevel@tonic-gate  *
25*7c478bd9Sstevel@tonic-gate  * Requires the following local variables:
26*7c478bd9Sstevel@tonic-gate  *
27*7c478bd9Sstevel@tonic-gate  *	DB *file_dbp, *mdbp;
28*7c478bd9Sstevel@tonic-gate  *	DB_MPOOLFILE *mpf;
29*7c478bd9Sstevel@tonic-gate  *	int ret;
30*7c478bd9Sstevel@tonic-gate  */
31*7c478bd9Sstevel@tonic-gate #define	REC_INTRO(func) {						\
32*7c478bd9Sstevel@tonic-gate 	file_dbp = NULL;						\
33*7c478bd9Sstevel@tonic-gate 	dbc = NULL;							\
34*7c478bd9Sstevel@tonic-gate 	if ((ret = func(dbtp->data, &argp)) != 0)			\
35*7c478bd9Sstevel@tonic-gate 		goto out;						\
36*7c478bd9Sstevel@tonic-gate 	if ((ret =							\
37*7c478bd9Sstevel@tonic-gate 	    __db_fileid_to_db(logp, &file_dbp, argp->fileid)) != 0) {	\
38*7c478bd9Sstevel@tonic-gate 		if (ret	== DB_DELETED) {				\
39*7c478bd9Sstevel@tonic-gate 			ret = 0;					\
40*7c478bd9Sstevel@tonic-gate 			goto done;					\
41*7c478bd9Sstevel@tonic-gate 		}							\
42*7c478bd9Sstevel@tonic-gate 		goto out;						\
43*7c478bd9Sstevel@tonic-gate 	}								\
44*7c478bd9Sstevel@tonic-gate 	if (file_dbp == NULL)						\
45*7c478bd9Sstevel@tonic-gate 		goto out;						\
46*7c478bd9Sstevel@tonic-gate 	if ((ret = file_dbp->cursor(file_dbp, NULL, &dbc, 0)) != 0)	\
47*7c478bd9Sstevel@tonic-gate 		goto out;						\
48*7c478bd9Sstevel@tonic-gate 	F_SET(dbc, DBC_RECOVER);					\
49*7c478bd9Sstevel@tonic-gate 	mpf = file_dbp->mpf;						\
50*7c478bd9Sstevel@tonic-gate }
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate #define	REC_CLOSE {							\
53*7c478bd9Sstevel@tonic-gate 	if (argp != NULL)						\
54*7c478bd9Sstevel@tonic-gate 		__os_free(argp, sizeof(*argp));				\
55*7c478bd9Sstevel@tonic-gate 	if (dbc != NULL)						\
56*7c478bd9Sstevel@tonic-gate 		dbc->c_close(dbc);					\
57*7c478bd9Sstevel@tonic-gate 	return (ret);							\
58*7c478bd9Sstevel@tonic-gate }
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate /*
61*7c478bd9Sstevel@tonic-gate  * No-op versions of the same macros.
62*7c478bd9Sstevel@tonic-gate  */
63*7c478bd9Sstevel@tonic-gate #define	REC_NOOP_INTRO(func) {						\
64*7c478bd9Sstevel@tonic-gate 	if ((ret = func(dbtp->data, &argp)) != 0)			\
65*7c478bd9Sstevel@tonic-gate 		return (ret);						\
66*7c478bd9Sstevel@tonic-gate }
67*7c478bd9Sstevel@tonic-gate #define	REC_NOOP_CLOSE {						\
68*7c478bd9Sstevel@tonic-gate 	if (argp != NULL)						\
69*7c478bd9Sstevel@tonic-gate 		__os_free(argp, sizeof(*argp));				\
70*7c478bd9Sstevel@tonic-gate 	return (ret);							\
71*7c478bd9Sstevel@tonic-gate }
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate /*
74*7c478bd9Sstevel@tonic-gate  * Standard debugging macro for all recovery functions.
75*7c478bd9Sstevel@tonic-gate  */
76*7c478bd9Sstevel@tonic-gate #ifdef DEBUG_RECOVER
77*7c478bd9Sstevel@tonic-gate #define	REC_PRINT(func)							\
78*7c478bd9Sstevel@tonic-gate 	(void)func(logp, dbtp, lsnp, redo, info);
79*7c478bd9Sstevel@tonic-gate #else
80*7c478bd9Sstevel@tonic-gate #define	REC_PRINT(func)							\
81*7c478bd9Sstevel@tonic-gate 	COMPQUIET(info, NULL);
82*7c478bd9Sstevel@tonic-gate #endif
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate #include "db_auto.h"
85*7c478bd9Sstevel@tonic-gate #include "db_ext.h"
86*7c478bd9Sstevel@tonic-gate #endif
87