summaryrefslogtreecommitdiff
path: root/db/dist/template/rec_ctemp
blob: 6be6d3166b8b2621537cd71451845251343ac9c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * __PREF_FUNC_recover --
 *	Recovery function for FUNC.
 *
 * PUBLIC: int __PREF_FUNC_recover
 * PUBLIC:   __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
 */
int
__PREF_FUNC_recover(dbenv, dbtp, lsnp, op, info)
	DB_ENV *dbenv;
	DBT *dbtp;
	DB_LSN *lsnp;
	db_recops op;
	void *info;
{
	__PREF_FUNC_args *argp;
	DB *file_dbp;
	DBC *dbc;
	DB_MPOOLFILE *mpf;
	PAGE *pagep;
	int cmp_n, cmp_p, modified, ret;

	REC_PRINT(__PREF_FUNC_print);
	REC_INTRO(__PREF_FUNC_read);

	if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0)
		if (DB_REDO(op)) {
			if ((ret = memp_fget(mpf,
			    &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0)
				goto out;
		} else {
			*lsnp = argp->prev_lsn;
			ret = 0;
			goto out;
		}

	modified = 0;
	cmp_n = log_compare(lsnp, &LSN(pagep));

	/*
	 * Use this when there is something like "pagelsn" in the argp
	 * structure.  Sometimes, you might need to compare meta-data
	 * lsn's instead.
	 *
	 * cmp_p = log_compare(&LSN(pagep), argp->pagelsn);
	 */
	if (cmp_p == 0 && DB_REDO(op)) {
		/* Need to redo update described. */
		modified = 1;
	} else if (cmp_n == 0 && !DB_REDO(op)) {
		/* Need to undo update described. */
		modified = 1;
	}
	if (ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0))
		goto out;

	*lsnp = argp->prev_lsn;
	ret = 0;

out:	REC_CLOSE;
}