diff options
Diffstat (limited to 'db/qam/qam_rec.c')
-rw-r--r-- | db/qam/qam_rec.c | 446 |
1 files changed, 148 insertions, 298 deletions
diff --git a/db/qam/qam_rec.c b/db/qam/qam_rec.c index 4d330f586..d846118ac 100644 --- a/db/qam/qam_rec.c +++ b/db/qam/qam_rec.c @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1999, 2000 + * Copyright (c) 1999-2003 * Sleepycat Software. All rights reserved. */ #include "db_config.h" #ifndef lint -static const char revid[] = "$Id: qam_rec.c,v 11.34 2001/01/19 18:01:59 bostic Exp $"; +static const char revid[] = "$Id: qam_rec.c,v 11.75 2003/08/17 23:38:14 ubell Exp $"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -18,91 +18,13 @@ static const char revid[] = "$Id: qam_rec.c,v 11.34 2001/01/19 18:01:59 bostic E #endif #include "db_int.h" -#include "db_page.h" -#include "db_shash.h" -#include "lock.h" -#include "db_am.h" -#include "qam.h" -#include "log.h" - -/* - * __qam_inc_recover -- - * Recovery function for inc. - * - * PUBLIC: int __qam_inc_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *)); - */ -int -__qam_inc_recover(dbenv, dbtp, lsnp, op, info) - DB_ENV *dbenv; - DBT *dbtp; - DB_LSN *lsnp; - db_recops op; - void *info; -{ - __qam_inc_args *argp; - DB *file_dbp; - DBC *dbc; - DB_LOCK lock; - DB_MPOOLFILE *mpf; - QMETA *meta; - db_pgno_t metapg; - int cmp_p, modified, ret; - - COMPQUIET(info, NULL); - REC_PRINT(__qam_inc_print); - REC_INTRO(__qam_inc_read, 1); - - metapg = ((QUEUE *)file_dbp->q_internal)->q_meta; - - if ((ret = __db_lget(dbc, - LCK_ROLLBACK, metapg, DB_LOCK_WRITE, 0, &lock)) != 0) - goto done; - if ((ret = memp_fget(mpf, &metapg, 0, &meta)) != 0) { - if (DB_REDO(op)) { - if ((ret = memp_fget(mpf, - &metapg, DB_MPOOL_CREATE, &meta)) != 0) { - (void)__LPUT(dbc, lock); - goto out; - } - meta->dbmeta.pgno = metapg; - meta->dbmeta.type = P_QAMMETA; - - } else { - *lsnp = argp->prev_lsn; - ret = 0; - (void)__LPUT(dbc, lock); - goto out; - } - } - - modified = 0; - cmp_p = log_compare(&LSN(meta), &argp->lsn); - CHECK_LSN(op, cmp_p, &LSN(meta), &argp->lsn); - - /* - * The cur_recno never goes backwards. It is a point of - * contention among appenders. If one fails cur_recno will - * most likely be beyond that one when it aborts. - * We move it ahead on either an abort or a commit - * and make the LSN reflect that fact. - */ - if (cmp_p == 0) { - modified = 1; - meta->cur_recno++; - if (meta->cur_recno == RECNO_OOB) - meta->cur_recno++; - meta->dbmeta.lsn = *lsnp; - } - if ((ret = memp_fput(mpf, meta, modified ? DB_MPOOL_DIRTY : 0))) - goto out; - - (void)__LPUT(dbc, lock); - -done: *lsnp = argp->prev_lsn; - ret = 0; - -out: REC_CLOSE; -} +#include "dbinc/db_page.h" +#include "dbinc/db_shash.h" +#include "dbinc/db_am.h" +#include "dbinc/lock.h" +#include "dbinc/log.h" +#include "dbinc/mp.h" +#include "dbinc/qam.h" /* * __qam_incfirst_recover -- @@ -123,13 +45,13 @@ __qam_incfirst_recover(dbenv, dbtp, lsnp, op, info) DB *file_dbp; DBC *dbc; DB_LOCK lock; + DB_LSN trunc_lsn; DB_MPOOLFILE *mpf; QMETA *meta; QUEUE_CURSOR *cp; db_pgno_t metapg; int exact, modified, ret, rec_ext; - COMPQUIET(info, NULL); REC_PRINT(__qam_incfirst_print); REC_INTRO(__qam_incfirst_read, 1); @@ -138,9 +60,9 @@ __qam_incfirst_recover(dbenv, dbtp, lsnp, op, info) if ((ret = __db_lget(dbc, LCK_ROLLBACK, metapg, DB_LOCK_WRITE, 0, &lock)) != 0) goto done; - if ((ret = memp_fget(mpf, &metapg, 0, &meta)) != 0) { + if ((ret = __memp_fget(mpf, &metapg, 0, &meta)) != 0) { if (DB_REDO(op)) { - if ((ret = memp_fget(mpf, + if ((ret = __memp_fget(mpf, &metapg, DB_MPOOL_CREATE, &meta)) != 0) { (void)__LPUT(dbc, lock); goto out; @@ -167,6 +89,14 @@ __qam_incfirst_recover(dbenv, dbtp, lsnp, op, info) meta->first_recno = argp->recno; modified = 1; } + + trunc_lsn = ((DB_TXNHEAD *)info)->trunc_lsn; + /* if we are truncating, update the LSN */ + if (!IS_ZERO_LSN(trunc_lsn) && + log_compare(&LSN(meta), &trunc_lsn) > 0) { + LSN(meta) = trunc_lsn; + modified = 1; + } } else { if (log_compare(&LSN(meta), lsnp) < 0) { LSN(meta) = *lsnp; @@ -178,11 +108,11 @@ __qam_incfirst_recover(dbenv, dbtp, lsnp, op, info) cp = (QUEUE_CURSOR *)dbc->internal; if (meta->first_recno == RECNO_OOB) meta->first_recno++; - while (meta->first_recno != meta->cur_recno - && !QAM_BEFORE_FIRST(meta, argp->recno + 1)) { + while (meta->first_recno != meta->cur_recno && + !QAM_BEFORE_FIRST(meta, argp->recno + 1)) { if ((ret = __qam_position(dbc, &meta->first_recno, QAM_READ, &exact)) != 0) - goto out; + goto err; if (cp->page != NULL) __qam_fput(file_dbp, cp->pgno, cp->page, 0); @@ -192,7 +122,7 @@ __qam_incfirst_recover(dbenv, dbtp, lsnp, op, info) rec_ext != 0 && meta->first_recno % rec_ext == 0) if ((ret = __qam_fremove(file_dbp, cp->pgno)) != 0) - goto out; + goto err; meta->first_recno++; if (meta->first_recno == RECNO_OOB) meta->first_recno++; @@ -200,14 +130,19 @@ __qam_incfirst_recover(dbenv, dbtp, lsnp, op, info) } } - if ((ret = memp_fput(mpf, meta, modified ? DB_MPOOL_DIRTY : 0))) - goto out; + if ((ret = __memp_fput(mpf, meta, modified ? DB_MPOOL_DIRTY : 0)) != 0) + goto err1; (void)__LPUT(dbc, lock); done: *lsnp = argp->prev_lsn; ret = 0; + if (0) { +err: (void)__memp_fput(mpf, meta, 0); +err1: (void)__LPUT(dbc, lock); + } + out: REC_CLOSE; } @@ -229,13 +164,13 @@ __qam_mvptr_recover(dbenv, dbtp, lsnp, op, info) __qam_mvptr_args *argp; DB *file_dbp; DBC *dbc; + DB_LSN trunc_lsn; DB_LOCK lock; DB_MPOOLFILE *mpf; QMETA *meta; db_pgno_t metapg; - int cmp_p, modified, ret; + int cmp_n, cmp_p, modified, ret; - COMPQUIET(info, NULL); REC_PRINT(__qam_mvptr_print); REC_INTRO(__qam_mvptr_read, 1); @@ -244,9 +179,9 @@ __qam_mvptr_recover(dbenv, dbtp, lsnp, op, info) if ((ret = __db_lget(dbc, LCK_ROLLBACK, metapg, DB_LOCK_WRITE, 0, &lock)) != 0) goto done; - if ((ret = memp_fget(mpf, &metapg, 0, &meta)) != 0) { + if ((ret = __memp_fget(mpf, &metapg, 0, &meta)) != 0) { if (DB_REDO(op)) { - if ((ret = memp_fget(mpf, + if ((ret = __memp_fget(mpf, &metapg, DB_MPOOL_CREATE, &meta)) != 0) { (void)__LPUT(dbc, lock); goto out; @@ -262,13 +197,31 @@ __qam_mvptr_recover(dbenv, dbtp, lsnp, op, info) } modified = 0; - cmp_p = log_compare(&meta->dbmeta.lsn, &argp->metalsn); + cmp_n = log_compare(lsnp, &LSN(meta)); + cmp_p = log_compare(&LSN(meta), &argp->metalsn); /* - * We never undo a movement of one of the pointers. - * Just move them along regardless of abort/commit. + * Under normal circumstances, we never undo a movement of one of + * the pointers. Just move them along regardless of abort/commit. + * + * If we're undoing a truncate, we need to reset the pointers to + * their state before the truncate. */ - if (cmp_p == 0) { + if (DB_UNDO(op)) { + if ((argp->opcode & QAM_TRUNCATE) && cmp_n <= 0) { + meta->first_recno = argp->old_first; + meta->cur_recno = argp->old_cur; + LSN(meta) = argp->metalsn; + modified = 1; + } + /* If the page lsn is beyond the truncate point, move it back */ + trunc_lsn = ((DB_TXNHEAD *)info)->trunc_lsn; + if (!IS_ZERO_LSN(trunc_lsn) && + log_compare(&trunc_lsn, &LSN(meta)) < 0) { + LSN(meta) = argp->metalsn; + modified = 1; + } + } else if (op == DB_TXN_APPLY || cmp_p == 0) { if (argp->opcode & QAM_SETFIRST) meta->first_recno = argp->new_first; @@ -279,7 +232,7 @@ __qam_mvptr_recover(dbenv, dbtp, lsnp, op, info) meta->dbmeta.lsn = *lsnp; } - if ((ret = memp_fput(mpf, meta, modified ? DB_MPOOL_DIRTY : 0))) + if ((ret = __memp_fput(mpf, meta, modified ? DB_MPOOL_DIRTY : 0)) != 0) goto out; (void)__LPUT(dbc, lock); @@ -289,6 +242,7 @@ done: *lsnp = argp->prev_lsn; out: REC_CLOSE; } + /* * __qam_del_recover -- * Recovery function for del. @@ -321,7 +275,7 @@ __qam_del_recover(dbenv, dbtp, lsnp, op, info) REC_INTRO(__qam_del_read, 1); if ((ret = __qam_fget(file_dbp, - &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0) + &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0) goto out; modified = 0; @@ -338,20 +292,20 @@ __qam_del_recover(dbenv, dbtp, lsnp, op, info) metapg = ((QUEUE *)file_dbp->q_internal)->q_meta; if ((ret = __db_lget(dbc, LCK_ROLLBACK, metapg, DB_LOCK_WRITE, 0, &lock)) != 0) - return (ret); - if ((ret = memp_fget(file_dbp->mpf, &metapg, 0, &meta)) != 0) { + goto err; + if ((ret = __memp_fget(mpf, &metapg, 0, &meta)) != 0) { (void)__LPUT(dbc, lock); - goto done; + goto err; } if (meta->first_recno == RECNO_OOB || - (QAM_BEFORE_FIRST(meta, argp->recno) - && (meta->first_recno <= meta->cur_recno - || meta->first_recno - + (QAM_BEFORE_FIRST(meta, argp->recno) && + (meta->first_recno <= meta->cur_recno || + meta->first_recno - argp->recno < argp->recno - meta->cur_recno))) { meta->first_recno = argp->recno; - (void)memp_fput(file_dbp->mpf, meta, DB_MPOOL_DIRTY); + (void)__memp_fput(mpf, meta, DB_MPOOL_DIRTY); } else - (void)memp_fput(file_dbp->mpf, meta, 0); + (void)__memp_fput(mpf, meta, 0); (void)__LPUT(dbc, lock); /* Need to undo delete - mark the record as present */ @@ -366,10 +320,10 @@ __qam_del_recover(dbenv, dbtp, lsnp, op, info) * is harmless in queue except when we're determining * what we need to roll forward during recovery. [#2588] */ - if (op == DB_TXN_BACKWARD_ROLL && cmp_n < 0) + if (op == DB_TXN_BACKWARD_ROLL && cmp_n <= 0) LSN(pagep) = argp->lsn; modified = 1; - } else if (cmp_n > 0 && DB_REDO(op)) { + } else if (op == DB_TXN_APPLY || (cmp_n > 0 && DB_REDO(op))) { /* Need to redo delete - clear the valid bit */ qp = QAM_GET_RECORD(file_dbp, pagep, argp->indx); F_CLR(qp, QAM_VALID); @@ -377,14 +331,18 @@ __qam_del_recover(dbenv, dbtp, lsnp, op, info) modified = 1; } if ((ret = __qam_fput(file_dbp, - argp->pgno, pagep, modified ? DB_MPOOL_DIRTY : 0))) + argp->pgno, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0) goto out; done: *lsnp = argp->prev_lsn; ret = 0; + if (0) { +err: (void)__qam_fput(file_dbp, argp->pgno, pagep, 0); + } out: REC_CLOSE; } + /* * __qam_delext_recover -- * Recovery function for del in an extent based queue. @@ -415,9 +373,19 @@ __qam_delext_recover(dbenv, dbtp, lsnp, op, info) REC_PRINT(__qam_delext_print); REC_INTRO(__qam_delext_read, 1); - if ((ret = __qam_fget(file_dbp, - &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0) - goto out; + if ((ret = __qam_fget(file_dbp, &argp->pgno, 0, &pagep)) != 0) { + if (ret != DB_PAGE_NOTFOUND && ret != ENOENT) + goto out; + /* + * If we are redoing a delete and the page is not there + * we are done. + */ + if (DB_REDO(op)) + goto done; + if ((ret = __qam_fget(file_dbp, + &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0) + goto out; + } modified = 0; if (pagep->pgno == PGNO_INVALID) { @@ -433,25 +401,25 @@ __qam_delext_recover(dbenv, dbtp, lsnp, op, info) metapg = ((QUEUE *)file_dbp->q_internal)->q_meta; if ((ret = __db_lget(dbc, LCK_ROLLBACK, metapg, DB_LOCK_WRITE, 0, &lock)) != 0) - return (ret); - if ((ret = memp_fget(file_dbp->mpf, &metapg, 0, &meta)) != 0) { + goto err; + if ((ret = __memp_fget(mpf, &metapg, 0, &meta)) != 0) { (void)__LPUT(dbc, lock); - goto done; + goto err; } if (meta->first_recno == RECNO_OOB || - (QAM_BEFORE_FIRST(meta, argp->recno) - && (meta->first_recno <= meta->cur_recno - || meta->first_recno - + (QAM_BEFORE_FIRST(meta, argp->recno) && + (meta->first_recno <= meta->cur_recno || + meta->first_recno - argp->recno < argp->recno - meta->cur_recno))) { meta->first_recno = argp->recno; - (void)memp_fput(file_dbp->mpf, meta, DB_MPOOL_DIRTY); + (void)__memp_fput(mpf, meta, DB_MPOOL_DIRTY); } else - (void)memp_fput(file_dbp->mpf, meta, 0); + (void)__memp_fput(mpf, meta, 0); (void)__LPUT(dbc, lock); if ((ret = __qam_pitem(dbc, pagep, argp->indx, argp->recno, &argp->data)) != 0) - goto done; + goto err; /* * Move the LSN back to this point; do not move it forward. @@ -461,10 +429,10 @@ __qam_delext_recover(dbenv, dbtp, lsnp, op, info) * is harmless in queue except when we're determining * what we need to roll forward during recovery. [#2588] */ - if (op == DB_TXN_BACKWARD_ROLL && cmp_n < 0) + if (op == DB_TXN_BACKWARD_ROLL && cmp_n <= 0) LSN(pagep) = argp->lsn; modified = 1; - } else if (cmp_n > 0 && DB_REDO(op)) { + } else if (op == DB_TXN_APPLY || (cmp_n > 0 && DB_REDO(op))) { /* Need to redo delete - clear the valid bit */ qp = QAM_GET_RECORD(file_dbp, pagep, argp->indx); F_CLR(qp, QAM_VALID); @@ -472,12 +440,15 @@ __qam_delext_recover(dbenv, dbtp, lsnp, op, info) modified = 1; } if ((ret = __qam_fput(file_dbp, - argp->pgno, pagep, modified ? DB_MPOOL_DIRTY : 0))) + argp->pgno, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0) goto out; done: *lsnp = argp->prev_lsn; ret = 0; + if (0) { +err: (void)__qam_fput(file_dbp, argp->pgno, pagep, 0); + } out: REC_CLOSE; } @@ -485,7 +456,8 @@ out: REC_CLOSE; * __qam_add_recover -- * Recovery function for add. * - * PUBLIC: int __qam_add_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *)); + * PUBLIC: int __qam_add_recover + * PUBLIC: __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *)); */ int __qam_add_recover(dbenv, dbtp, lsnp, op, info) @@ -503,16 +475,26 @@ __qam_add_recover(dbenv, dbtp, lsnp, op, info) QMETA *meta; QPAGE *pagep; db_pgno_t metapg; - int cmp_n, modified, ret; + int cmp_n, meta_dirty, modified, ret; COMPQUIET(info, NULL); REC_PRINT(__qam_add_print); REC_INTRO(__qam_add_read, 1); modified = 0; - if ((ret = __qam_fget(file_dbp, - &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0) - goto out; + if ((ret = __qam_fget(file_dbp, &argp->pgno, 0, &pagep)) != 0) { + if (ret != DB_PAGE_NOTFOUND && ret != ENOENT) + goto out; + /* + * If we are undoing an append and the page is not there + * we are done. + */ + if (DB_UNDO(op)) + goto done; + if ((ret = __qam_fget(file_dbp, + &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0) + goto out; + } if (pagep->pgno == PGNO_INVALID) { pagep->pgno = argp->pgno; @@ -522,25 +504,34 @@ __qam_add_recover(dbenv, dbtp, lsnp, op, info) cmp_n = log_compare(lsnp, &LSN(pagep)); - if (cmp_n > 0 && DB_REDO(op)) { - /* Need to redo add - put the record on page */ - if ((ret = __qam_pitem(dbc, pagep, argp->indx, argp->recno, - &argp->data)) != 0) - goto err; - LSN(pagep) = *lsnp; - modified = 1; - /* Make sure first pointer includes this record. */ + if (DB_REDO(op)) { + /* Fix meta-data page. */ metapg = ((QUEUE *)file_dbp->q_internal)->q_meta; - if ((ret = memp_fget(mpf, &metapg, 0, &meta)) != 0) + if ((ret = __memp_fget(mpf, &metapg, 0, &meta)) != 0) goto err; + meta_dirty = 0; if (QAM_BEFORE_FIRST(meta, argp->recno)) { meta->first_recno = argp->recno; - if ((ret = memp_fput(mpf, meta, DB_MPOOL_DIRTY)) != 0) - goto err; - } else - if ((ret = memp_fput(mpf, meta, 0)) != 0) - goto err; + meta_dirty = 1; + } + if (argp->recno == meta->cur_recno || + QAM_AFTER_CURRENT(meta, argp->recno)) { + meta->cur_recno = argp->recno + 1; + meta_dirty = 1; + } + if ((ret = __memp_fput(mpf, + meta, meta_dirty? DB_MPOOL_DIRTY : 0)) != 0) + goto err; + /* Now update the actual page if necessary. */ + if (op == DB_TXN_APPLY || cmp_n > 0) { + /* Need to redo add - put the record on page */ + if ((ret = __qam_pitem(dbc, + pagep, argp->indx, argp->recno, &argp->data)) != 0) + goto err; + LSN(pagep) = *lsnp; + modified = 1; + } } else if (DB_UNDO(op)) { /* * Need to undo add @@ -572,161 +563,20 @@ __qam_add_recover(dbenv, dbtp, lsnp, op, info) * is harmless in queue except when we're determining * what we need to roll forward during recovery. [#2588] */ - if (op == DB_TXN_BACKWARD_ROLL && cmp_n < 0) + if (op == DB_TXN_BACKWARD_ROLL && cmp_n <= 0) LSN(pagep) = argp->lsn; } -err: if ((ret = __qam_fput(file_dbp, - argp->pgno, pagep, modified ? DB_MPOOL_DIRTY : 0))) + if ((ret = __qam_fput(file_dbp, + argp->pgno, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0) goto out; done: *lsnp = argp->prev_lsn; ret = 0; -out: REC_CLOSE; -} -/* - * __qam_delete_recover -- - * Recovery function for delete of an extent. - * - * PUBLIC: int __qam_delete_recover - * PUBLIC: __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *)); - */ -int -__qam_delete_recover(dbenv, dbtp, lsnp, op, info) - DB_ENV *dbenv; - DBT *dbtp; - DB_LSN *lsnp; - db_recops op; - void *info; -{ - __qam_delete_args *argp; - int ret; - char *backup, *real_back, *real_name; - - COMPQUIET(info, NULL); - - REC_PRINT(__qam_delete_print); - - backup = real_back = real_name = NULL; - if ((ret = __qam_delete_read(dbenv, dbtp->data, &argp)) != 0) - goto out; - - if (DB_REDO(op)) { - /* - * On a recovery, as we recreate what was going on, we - * recreate the creation of the file. And so, even though - * it committed, we need to delete it. Try to delete it, - * but it is not an error if that delete fails. - */ - if ((ret = __db_appname(dbenv, DB_APP_DATA, - NULL, argp->name.data, 0, NULL, &real_name)) != 0) - goto out; - if (__os_exists(real_name, NULL) == 0) { - if ((ret = __os_unlink(dbenv, real_name)) != 0) - goto out; - } - } else if (DB_UNDO(op)) { - /* - * Trying to undo. File may or may not have been deleted. - * Try to move the backup to the original. If the backup - * exists, then this is right. If it doesn't exist, then - * nothing will happen and that's OK. - */ - if ((ret = __db_backup_name(dbenv, argp->name.data, - &backup, &argp->lsn)) != 0) - goto out; - if ((ret = __db_appname(dbenv, - DB_APP_DATA, NULL, backup, 0, NULL, &real_back)) != 0) - goto out; - if ((ret = __db_appname(dbenv, DB_APP_DATA, - NULL, argp->name.data, 0, NULL, &real_name)) != 0) - goto out; - if (__os_exists(real_back, NULL) == 0) - if ((ret = - __os_rename(dbenv, real_back, real_name)) != 0) - goto out; - } - *lsnp = argp->prev_lsn; - ret = 0; - -out: if (argp != NULL) - __os_free(argp, 0); - if (backup != NULL) - __os_freestr(backup); - if (real_back != NULL) - __os_freestr(real_back); - if (real_name != NULL) - __os_freestr(real_name); - return (ret); -} -/* - * __qam_rename_recover -- - * Recovery function for rename. - * - * PUBLIC: int __qam_rename_recover - * PUBLIC: __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *)); - */ -int -__qam_rename_recover(dbenv, dbtp, lsnp, op, info) - DB_ENV *dbenv; - DBT *dbtp; - DB_LSN *lsnp; - db_recops op; - void *info; -{ - __qam_rename_args *argp; - char *new_name, *real_name; - int ret; - - COMPQUIET(info, NULL); - - REC_PRINT(__qam_rename_print); - - new_name = real_name = NULL; - - if ((ret = __qam_rename_read(dbenv, dbtp->data, &argp)) != 0) - goto out; - - if (DB_REDO(op)) { - if ((ret = __db_appname(dbenv, DB_APP_DATA, - NULL, argp->name.data, 0, NULL, &real_name)) != 0) - goto out; - if (__os_exists(real_name, NULL) == 0) { - if ((ret = __db_appname(dbenv, - DB_APP_DATA, NULL, argp->newname.data, - 0, NULL, &new_name)) != 0) - goto out; - if ((ret = __os_rename(dbenv, - real_name, new_name)) != 0) - goto out; - } - } else { - if ((ret = __db_appname(dbenv, DB_APP_DATA, - NULL, argp->newname.data, 0, NULL, &new_name)) != 0) - goto out; - if (__os_exists(new_name, NULL) == 0) { - if ((ret = __db_appname(dbenv, - DB_APP_DATA, NULL, argp->name.data, - 0, NULL, &real_name)) != 0) - goto out; - if ((ret = __os_rename(dbenv, - new_name, real_name)) != 0) - goto out; - } + if (0) { +err: (void)__qam_fput(file_dbp, argp->pgno, pagep, 0); } - *lsnp = argp->prev_lsn; - ret = 0; - -out: if (argp != NULL) - __os_free(argp, 0); - - if (new_name != NULL) - __os_free(new_name, 0); - - if (real_name != NULL) - __os_free(real_name, 0); - - return (ret); +out: REC_CLOSE; } |