libdb/dist/template/rec_heap

267 lines
5.6 KiB
Text

#include "db_config.h"
#include "db_int.h"
#include "dbinc/db_page.h"
#include "dbinc/__heap.h"
#include "dbinc/log.h"
/*
* __heap_addrem_recover --
* Recovery function for addrem.
*
* PUBLIC: int __heap_addrem_recover
* PUBLIC: __P((env *, DBT *, DB_LSN *, db_recops, void *));
*/
int
__heap_addrem_recover(env, dbtp, lsnp, op, info)
env *env;
DBT *dbtp;
DB_LSN *lsnp;
db_recops op;
void *info;
{
__heap_addrem_args *argp;
DB *file_dbp;
DBC *dbc;
DB_MPOOLFILE *mpf;
DB_THREAD_INFO *ip;
PAGE *pagep;
int cmp_n, cmp_p, modified, ret;
ip = ((DB_TXNHEAD *)info)->thread_info;
REC_PRINT(__heap_addrem_print);
REC_INTRO(__heap_addrem_read, ip, 0);
if ((ret = mpf->get(mpf, &argp->pgno, 0, &pagep)) != 0)
if (DB_REDO(op)) {
if ((ret = mpf->get(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 = mpf->put(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0))
goto out;
*lsnp = argp->prev_lsn;
ret = 0;
out: REC_CLOSE;
}
/*
* __heap_pg_alloc_recover --
* Recovery function for pg_alloc.
*
* PUBLIC: int __heap_pg_alloc_recover
* PUBLIC: __P((env *, DBT *, DB_LSN *, db_recops, void *));
*/
int
__heap_pg_alloc_recover(env, dbtp, lsnp, op, info)
env *env;
DBT *dbtp;
DB_LSN *lsnp;
db_recops op;
void *info;
{
__heap_pg_alloc_args *argp;
DB *file_dbp;
DBC *dbc;
DB_MPOOLFILE *mpf;
DB_THREAD_INFO *ip;
PAGE *pagep;
int cmp_n, cmp_p, modified, ret;
ip = ((DB_TXNHEAD *)info)->thread_info;
REC_PRINT(__heap_pg_alloc_print);
REC_INTRO(__heap_pg_alloc_read, ip, 0);
if ((ret = mpf->get(mpf, &argp->pgno, 0, &pagep)) != 0)
if (DB_REDO(op)) {
if ((ret = mpf->get(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 = mpf->put(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0))
goto out;
*lsnp = argp->prev_lsn;
ret = 0;
out: REC_CLOSE;
}
/*
* __heap_trunc_meta_recover --
* Recovery function for trunc_meta.
*
* PUBLIC: int __heap_trunc_meta_recover
* PUBLIC: __P((env *, DBT *, DB_LSN *, db_recops, void *));
*/
int
__heap_trunc_meta_recover(env, dbtp, lsnp, op, info)
env *env;
DBT *dbtp;
DB_LSN *lsnp;
db_recops op;
void *info;
{
__heap_trunc_meta_args *argp;
DB *file_dbp;
DBC *dbc;
DB_MPOOLFILE *mpf;
DB_THREAD_INFO *ip;
PAGE *pagep;
int cmp_n, cmp_p, modified, ret;
ip = ((DB_TXNHEAD *)info)->thread_info;
REC_PRINT(__heap_trunc_meta_print);
REC_INTRO(__heap_trunc_meta_read, ip, 0);
if ((ret = mpf->get(mpf, &argp->pgno, 0, &pagep)) != 0)
if (DB_REDO(op)) {
if ((ret = mpf->get(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 = mpf->put(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0))
goto out;
*lsnp = argp->prev_lsn;
ret = 0;
out: REC_CLOSE;
}
/*
* __heap_trunc_page_recover --
* Recovery function for trunc_page.
*
* PUBLIC: int __heap_trunc_page_recover
* PUBLIC: __P((env *, DBT *, DB_LSN *, db_recops, void *));
*/
int
__heap_trunc_page_recover(env, dbtp, lsnp, op, info)
env *env;
DBT *dbtp;
DB_LSN *lsnp;
db_recops op;
void *info;
{
__heap_trunc_page_args *argp;
DB *file_dbp;
DBC *dbc;
DB_MPOOLFILE *mpf;
DB_THREAD_INFO *ip;
PAGE *pagep;
int cmp_n, cmp_p, modified, ret;
ip = ((DB_TXNHEAD *)info)->thread_info;
REC_PRINT(__heap_trunc_page_print);
REC_INTRO(__heap_trunc_page_read, ip, 0);
if ((ret = mpf->get(mpf, &argp->pgno, 0, &pagep)) != 0)
if (DB_REDO(op)) {
if ((ret = mpf->get(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 = mpf->put(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0))
goto out;
*lsnp = argp->prev_lsn;
ret = 0;
out: REC_CLOSE;
}