mariadb/bdb/dist/template/rec_ctemp

63 lines
1.3 KiB
Text
Raw Normal View History

2001-03-05 01:42:05 +01:00
/*
2002-10-30 12:57:05 +01:00
* PREF_FUNC_recover --
2001-03-05 01:42:05 +01:00
* Recovery function for FUNC.
*
2002-10-30 12:57:05 +01:00
* PUBLIC: int PREF_FUNC_recover
2001-03-05 01:42:05 +01:00
* PUBLIC: __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
*/
int
2002-10-30 12:57:05 +01:00
PREF_FUNC_recover(dbenv, dbtp, lsnp, op, info)
2001-03-05 01:42:05 +01:00
DB_ENV *dbenv;
DBT *dbtp;
DB_LSN *lsnp;
db_recops op;
void *info;
{
2002-10-30 12:57:05 +01:00
PREF_FUNC_args *argp;
2001-03-05 01:42:05 +01:00
DB *file_dbp;
DBC *dbc;
DB_MPOOLFILE *mpf;
PAGE *pagep;
int cmp_n, cmp_p, modified, ret;
2002-10-30 12:57:05 +01:00
REC_PRINT(PREF_FUNC_print);
REC_INTRO(PREF_FUNC_read, 1);
2001-03-05 01:42:05 +01:00
2002-10-30 12:57:05 +01:00
if ((ret = mpf->get(mpf, &argp->pgno, 0, &pagep)) != 0)
2001-03-05 01:42:05 +01:00
if (DB_REDO(op)) {
2002-10-30 12:57:05 +01:00
if ((ret = mpf->get(mpf,
2001-03-05 01:42:05 +01:00
&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;
}
2002-10-30 12:57:05 +01:00
if (ret = mpf->put(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0))
2001-03-05 01:42:05 +01:00
goto out;
*lsnp = argp->prev_lsn;
ret = 0;
out: REC_CLOSE;
}