2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1996, 1997, 1998
5 * Sleepycat Software. All rights reserved.
11 static const char sccsid[] = "@(#)bt_rec.c 10.28 (Sleepycat) 9/27/98";
14 #ifndef NO_SYSTEM_INCLUDES
15 #include <sys/types.h>
27 #include "common_ext.h"
30 * __bam_pg_alloc_recover --
31 * Recovery function for pg_alloc.
33 * PUBLIC: int __bam_pg_alloc_recover
34 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
37 __bam_pg_alloc_recover(logp, dbtp, lsnp, redo, info)
44 __bam_pg_alloc_args *argp;
51 int cmp_n, cmp_p, modified, ret;
53 REC_PRINT(__bam_pg_alloc_print);
54 REC_INTRO(__bam_pg_alloc_read);
57 * Fix up the allocated page. If we're redoing the operation, we have
58 * to get the page (creating it if it doesn't exist), and update its
59 * LSN. If we're undoing the operation, we have to reset the page's
60 * LSN and put it on the free list.
62 * Fix up the metadata page. If we're redoing the operation, we have
63 * to get the metadata page and update its LSN and its free pointer.
64 * If we're undoing the operation and the page was ever created, we put
68 if ((ret = memp_fget(mpf, &pgno, 0, &meta)) != 0) {
69 /* The metadata page must always exist. */
70 (void)__db_pgerr(file_dbp, pgno);
73 if ((ret = memp_fget(mpf, &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0) {
75 * We specify creation and check for it later, because this
76 * operation was supposed to create the page, and even in
77 * the undo case it's going to get linked onto the freelist
78 * which we're also fixing up.
80 (void)__db_pgerr(file_dbp, argp->pgno);
81 (void)memp_fput(mpf, meta, 0);
85 /* Fix up the allocated page. */
87 cmp_n = log_compare(lsnp, &LSN(pagep));
88 cmp_p = log_compare(&LSN(pagep), &argp->page_lsn);
89 if (cmp_p == 0 && redo) {
90 /* Need to redo update described. */
91 P_INIT(pagep, file_dbp->pgsize,
92 argp->pgno, PGNO_INVALID, PGNO_INVALID, 0, argp->ptype);
96 } else if (cmp_n == 0 && !redo) {
97 /* Need to undo update described. */
98 P_INIT(pagep, file_dbp->pgsize,
99 argp->pgno, PGNO_INVALID, meta->free, 0, P_INVALID);
101 pagep->lsn = argp->page_lsn;
104 if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0) {
105 (void)memp_fput(mpf, meta, 0);
109 /* Fix up the metadata page. */
111 cmp_n = log_compare(lsnp, &LSN(meta));
112 cmp_p = log_compare(&LSN(meta), &argp->meta_lsn);
113 if (cmp_p == 0 && redo) {
114 /* Need to redo update described. */
116 meta->free = argp->next;
118 } else if (cmp_n == 0 && !redo) {
119 /* Need to undo update described. */
120 meta->lsn = argp->meta_lsn;
121 meta->free = argp->pgno;
124 if ((ret = memp_fput(mpf, meta, modified ? DB_MPOOL_DIRTY : 0)) != 0)
127 done: *lsnp = argp->prev_lsn;
134 * __bam_pg_free_recover --
135 * Recovery function for pg_free.
137 * PUBLIC: int __bam_pg_free_recover
138 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
141 __bam_pg_free_recover(logp, dbtp, lsnp, redo, info)
148 __bam_pg_free_args *argp;
155 int cmp_n, cmp_p, modified, ret;
157 REC_PRINT(__bam_pg_free_print);
158 REC_INTRO(__bam_pg_free_read);
161 * Fix up the freed page. If we're redoing the operation we get the
162 * page and explicitly discard its contents, then update its LSN. If
163 * we're undoing the operation, we get the page and restore its header.
165 if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0) {
167 * We don't automatically create the page. The only way the
168 * page might not exist is if the alloc never happened, and
169 * the only way the alloc might never have happened is if we
170 * are undoing, in which case there's no reason to create the
175 (void)__db_pgerr(file_dbp, argp->pgno);
179 cmp_n = log_compare(lsnp, &LSN(pagep));
180 cmp_p = log_compare(&LSN(pagep), &LSN(argp->header.data));
181 if (cmp_p == 0 && redo) {
182 /* Need to redo update described. */
183 P_INIT(pagep, file_dbp->pgsize,
184 pagep->pgno, PGNO_INVALID, argp->next, 0, P_INVALID);
188 } else if (cmp_n == 0 && !redo) {
189 /* Need to undo update described. */
190 memcpy(pagep, argp->header.data, argp->header.size);
194 if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0)
198 * Fix up the metadata page. If we're redoing or undoing the operation
199 * we get the page and update its LSN and free pointer.
201 pgno = PGNO_METADATA;
202 if ((ret = memp_fget(mpf, &pgno, 0, &meta)) != 0) {
203 /* The metadata page must always exist. */
204 (void)__db_pgerr(file_dbp, pgno);
209 cmp_n = log_compare(lsnp, &LSN(meta));
210 cmp_p = log_compare(&LSN(meta), &argp->meta_lsn);
211 if (cmp_p == 0 && redo) {
212 /* Need to redo update described. */
213 meta->free = argp->pgno;
217 } else if (cmp_n == 0 && !redo) {
218 /* Need to undo update described. */
219 meta->free = argp->next;
221 meta->lsn = argp->meta_lsn;
224 if ((ret = memp_fput(mpf, meta, modified ? DB_MPOOL_DIRTY : 0)) != 0)
227 done: *lsnp = argp->prev_lsn;
234 * __bam_split_recover --
235 * Recovery function for split.
237 * PUBLIC: int __bam_split_recover
238 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
241 __bam_split_recover(logp, dbtp, lsnp, redo, info)
248 __bam_split_args *argp;
252 PAGE *_lp, *lp, *np, *pp, *_rp, *rp, *sp;
254 int l_update, p_update, r_update, ret, rootsplit, t_ret;
256 REC_PRINT(__bam_split_print);
259 _lp = lp = np = pp = _rp = rp = NULL;
261 REC_INTRO(__bam_split_read);
264 * There are two kinds of splits that we have to recover from. The
265 * first is a root-page split, where the root page is split from a
266 * leaf page into an internal page and two new leaf pages are created.
267 * The second is where a page is split into two pages, and a new key
268 * is inserted into the parent page.
272 rootsplit = pgno == PGNO_ROOT;
273 if (memp_fget(mpf, &argp->left, 0, &lp) != 0)
275 if (memp_fget(mpf, &argp->right, 0, &rp) != 0)
279 l_update = r_update = p_update = 0;
281 * Decide if we need to resplit the page.
283 * If this is a root split, then the root has to exist, it's
284 * the page we're splitting and it gets modified. If this is
285 * not a root split, then the left page has to exist, for the
289 if ((ret = memp_fget(mpf, &pgno, 0, &pp)) != 0) {
290 (void)__db_pgerr(file_dbp, pgno);
295 log_compare(&LSN(pp), &LSN(argp->pg.data)) == 0;
298 (void)__db_pgerr(file_dbp, argp->left);
301 if (lp == NULL || log_compare(&LSN(lp), &argp->llsn) == 0)
303 if (rp == NULL || log_compare(&LSN(rp), &argp->rlsn) == 0)
305 if (!p_update && !l_update && !r_update)
308 /* Allocate and initialize new left/right child pages. */
309 if ((ret = __os_malloc(file_dbp->pgsize, NULL, &_lp)) != 0 ||
310 (ret = __os_malloc(file_dbp->pgsize, NULL, &_rp)) != 0)
313 P_INIT(_lp, file_dbp->pgsize, argp->left,
315 ISINTERNAL(sp) ? PGNO_INVALID : argp->right,
316 LEVEL(sp), TYPE(sp));
317 P_INIT(_rp, file_dbp->pgsize, argp->right,
318 ISINTERNAL(sp) ? PGNO_INVALID : argp->left,
319 PGNO_INVALID, LEVEL(sp), TYPE(sp));
321 P_INIT(_lp, file_dbp->pgsize, PGNO(sp),
322 ISINTERNAL(sp) ? PGNO_INVALID : PREV_PGNO(sp),
323 ISINTERNAL(sp) ? PGNO_INVALID : argp->right,
324 LEVEL(sp), TYPE(sp));
325 P_INIT(_rp, file_dbp->pgsize, argp->right,
326 ISINTERNAL(sp) ? PGNO_INVALID : sp->pgno,
327 ISINTERNAL(sp) ? PGNO_INVALID : NEXT_PGNO(sp),
328 LEVEL(sp), TYPE(sp));
331 /* Split the page. */
332 if ((ret = __bam_copy(file_dbp, sp, _lp, 0, argp->indx)) != 0 ||
333 (ret = __bam_copy(file_dbp, sp, _rp, argp->indx,
337 /* If the left child is wrong, update it. */
338 if (lp == NULL && (ret =
339 memp_fget(mpf, &argp->left, DB_MPOOL_CREATE, &lp)) != 0) {
340 (void)__db_pgerr(file_dbp, argp->left);
345 memcpy(lp, _lp, file_dbp->pgsize);
347 if ((ret = memp_fput(mpf, lp, DB_MPOOL_DIRTY)) != 0)
352 /* If the right child is wrong, update it. */
353 if (rp == NULL && (ret = memp_fget(mpf,
354 &argp->right, DB_MPOOL_CREATE, &rp)) != 0) {
355 (void)__db_pgerr(file_dbp, argp->right);
360 memcpy(rp, _rp, file_dbp->pgsize);
362 if ((ret = memp_fput(mpf, rp, DB_MPOOL_DIRTY)) != 0)
368 * If the parent page is wrong, update it. This is of interest
369 * only if it was a root split, since root splits create parent
370 * pages. All other splits modify a parent page, but those are
371 * separately logged and recovered.
373 if (rootsplit && p_update) {
374 if (file_dbp->type == DB_BTREE)
375 P_INIT(pp, file_dbp->pgsize,
376 PGNO_ROOT, PGNO_INVALID, PGNO_INVALID,
377 _lp->level + 1, P_IBTREE);
379 P_INIT(pp, file_dbp->pgsize,
380 PGNO_ROOT, PGNO_INVALID, PGNO_INVALID,
381 _lp->level + 1, P_IRECNO);
383 file_dbp->type == DB_RECNO ||
384 F_ISSET(file_dbp, DB_BT_RECNUM) ?
385 __bam_total(_lp) + __bam_total(_rp) : 0);
387 if ((ret = memp_fput(mpf, pp, DB_MPOOL_DIRTY)) != 0)
393 * Finally, redo the next-page link if necessary. This is of
394 * interest only if it wasn't a root split -- inserting a new
395 * page in the tree requires that any following page have its
396 * previous-page pointer updated to our new page. The next
397 * page must exist because we're redoing the operation.
399 if (!rootsplit && !IS_ZERO_LSN(argp->nlsn)) {
400 if ((ret = memp_fget(mpf, &argp->npgno, 0, &np)) != 0) {
401 (void)__db_pgerr(file_dbp, argp->npgno);
405 if (log_compare(&LSN(np), &argp->nlsn) == 0) {
406 PREV_PGNO(np) = argp->right;
409 memp_fput(mpf, np, DB_MPOOL_DIRTY)) != 0)
416 * If the split page is wrong, replace its contents with the
417 * logged page contents. If the page doesn't exist, it means
418 * that the create of the page never happened, nor did any of
419 * the adds onto the page that caused the split, and there's
420 * really no undo-ing to be done.
422 if ((ret = memp_fget(mpf, &pgno, 0, &pp)) != 0) {
426 if (log_compare(lsnp, &LSN(pp)) == 0) {
427 memcpy(pp, argp->pg.data, argp->pg.size);
428 if ((ret = memp_fput(mpf, pp, DB_MPOOL_DIRTY)) != 0)
434 * If it's a root split and the left child ever existed, update
435 * its LSN. (If it's not a root split, we've updated the left
436 * page already -- it's the same as the split page.) If the
437 * right child ever existed, root split or not, update its LSN.
438 * The undo of the page allocation(s) will restore them to the
441 lrundo: if ((rootsplit && lp != NULL) || rp != NULL) {
442 if (rootsplit && lp != NULL &&
443 log_compare(lsnp, &LSN(lp)) == 0) {
444 lp->lsn = argp->llsn;
446 memp_fput(mpf, lp, DB_MPOOL_DIRTY)) != 0)
451 log_compare(lsnp, &LSN(rp)) == 0) {
452 rp->lsn = argp->rlsn;
454 memp_fput(mpf, rp, DB_MPOOL_DIRTY)) != 0)
461 * Finally, undo the next-page link if necessary. This is of
462 * interest only if it wasn't a root split -- inserting a new
463 * page in the tree requires that any following page have its
464 * previous-page pointer updated to our new page. Since it's
465 * possible that the next-page never existed, we ignore it as
466 * if there's nothing to undo.
468 if (!rootsplit && !IS_ZERO_LSN(argp->nlsn)) {
469 if ((ret = memp_fget(mpf, &argp->npgno, 0, &np)) != 0) {
473 if (log_compare(lsnp, &LSN(np)) == 0) {
474 PREV_PGNO(np) = argp->left;
475 np->lsn = argp->nlsn;
476 if (memp_fput(mpf, np, DB_MPOOL_DIRTY))
483 done: *lsnp = argp->prev_lsn;
486 out: /* Free any pages that weren't dirtied. */
487 if (pp != NULL && (t_ret = memp_fput(mpf, pp, 0)) != 0 && ret == 0)
489 if (lp != NULL && (t_ret = memp_fput(mpf, lp, 0)) != 0 && ret == 0)
491 if (np != NULL && (t_ret = memp_fput(mpf, np, 0)) != 0 && ret == 0)
493 if (rp != NULL && (t_ret = memp_fput(mpf, rp, 0)) != 0 && ret == 0)
496 /* Free any allocated space. */
498 __os_free(_lp, file_dbp->pgsize);
500 __os_free(_rp, file_dbp->pgsize);
506 * __bam_rsplit_recover --
507 * Recovery function for a reverse split.
509 * PUBLIC: int __bam_rsplit_recover
510 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
513 __bam_rsplit_recover(logp, dbtp, lsnp, redo, info)
520 __bam_rsplit_args *argp;
526 int cmp_n, cmp_p, modified, ret;
528 REC_PRINT(__bam_rsplit_print);
529 REC_INTRO(__bam_rsplit_read);
531 /* Fix the root page. */
533 if ((ret = memp_fget(mpf, &pgno, 0, &pagep)) != 0) {
534 /* The root page must always exist. */
535 __db_pgerr(file_dbp, pgno);
539 cmp_n = log_compare(lsnp, &LSN(pagep));
540 cmp_p = log_compare(&LSN(pagep), &argp->rootlsn);
541 if (cmp_p == 0 && redo) {
542 /* Need to redo update described. */
543 memcpy(pagep, argp->pgdbt.data, argp->pgdbt.size);
544 pagep->pgno = PGNO_ROOT;
547 } else if (cmp_n == 0 && !redo) {
548 /* Need to undo update described. */
549 P_INIT(pagep, file_dbp->pgsize, PGNO_ROOT,
550 argp->nrec, PGNO_INVALID, pagep->level + 1,
551 file_dbp->type == DB_BTREE ? P_IBTREE : P_IRECNO);
552 if ((ret = __db_pitem(dbc, pagep, 0,
553 argp->rootent.size, &argp->rootent, NULL)) != 0)
555 pagep->lsn = argp->rootlsn;
558 if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0)
562 * Fix the page copied over the root page. It's possible that the
563 * page never made it to disk, so if we're undo-ing and the page
564 * doesn't exist, it's okay and there's nothing further to do.
566 if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0) {
569 (void)__db_pgerr(file_dbp, argp->pgno);
573 cmp_n = log_compare(lsnp, &LSN(pagep));
574 cmp_p = log_compare(&LSN(pagep), &LSN(argp->pgdbt.data));
575 if (cmp_p == 0 && redo) {
576 /* Need to redo update described. */
579 } else if (cmp_n == 0 && !redo) {
580 /* Need to undo update described. */
581 memcpy(pagep, argp->pgdbt.data, argp->pgdbt.size);
584 if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0)
587 done: *lsnp = argp->prev_lsn;
594 * __bam_adj_recover --
595 * Recovery function for adj.
597 * PUBLIC: int __bam_adj_recover
598 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
601 __bam_adj_recover(logp, dbtp, lsnp, redo, info)
608 __bam_adj_args *argp;
613 int cmp_n, cmp_p, modified, ret;
615 REC_PRINT(__bam_adj_print);
616 REC_INTRO(__bam_adj_read);
618 /* Get the page; if it never existed and we're undoing, we're done. */
619 if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0) {
622 (void)__db_pgerr(file_dbp, argp->pgno);
627 cmp_n = log_compare(lsnp, &LSN(pagep));
628 cmp_p = log_compare(&LSN(pagep), &argp->lsn);
629 if (cmp_p == 0 && redo) {
630 /* Need to redo update described. */
631 if ((ret = __bam_adjindx(dbc,
632 pagep, argp->indx, argp->indx_copy, argp->is_insert)) != 0)
637 } else if (cmp_n == 0 && !redo) {
638 /* Need to undo update described. */
639 if ((ret = __bam_adjindx(dbc,
640 pagep, argp->indx, argp->indx_copy, !argp->is_insert)) != 0)
643 LSN(pagep) = argp->lsn;
646 if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0)
649 done: *lsnp = argp->prev_lsn;
653 err: (void)memp_fput(mpf, pagep, 0);
659 * __bam_cadjust_recover --
660 * Recovery function for the adjust of a count change in an internal
663 * PUBLIC: int __bam_cadjust_recover
664 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
667 __bam_cadjust_recover(logp, dbtp, lsnp, redo, info)
674 __bam_cadjust_args *argp;
679 int cmp_n, cmp_p, modified, ret;
681 REC_PRINT(__bam_cadjust_print);
682 REC_INTRO(__bam_cadjust_read);
684 /* Get the page; if it never existed and we're undoing, we're done. */
685 if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0) {
688 (void)__db_pgerr(file_dbp, argp->pgno);
693 cmp_n = log_compare(lsnp, &LSN(pagep));
694 cmp_p = log_compare(&LSN(pagep), &argp->lsn);
695 if (cmp_p == 0 && redo) {
696 /* Need to redo update described. */
697 if (file_dbp->type == DB_BTREE &&
698 F_ISSET(file_dbp, DB_BT_RECNUM)) {
699 GET_BINTERNAL(pagep, argp->indx)->nrecs += argp->adjust;
700 if (argp->total && PGNO(pagep) == PGNO_ROOT)
701 RE_NREC_ADJ(pagep, argp->adjust);
703 if (file_dbp->type == DB_RECNO) {
704 GET_RINTERNAL(pagep, argp->indx)->nrecs += argp->adjust;
705 if (argp->total && PGNO(pagep) == PGNO_ROOT)
706 RE_NREC_ADJ(pagep, argp->adjust);
711 } else if (cmp_n == 0 && !redo) {
712 /* Need to undo update described. */
713 if (file_dbp->type == DB_BTREE &&
714 F_ISSET(file_dbp, DB_BT_RECNUM)) {
715 GET_BINTERNAL(pagep, argp->indx)->nrecs -= argp->adjust;
716 if (argp->total && PGNO(pagep) == PGNO_ROOT)
717 RE_NREC_ADJ(pagep, argp->adjust);
719 if (file_dbp->type == DB_RECNO) {
720 GET_RINTERNAL(pagep, argp->indx)->nrecs -= argp->adjust;
721 if (argp->total && PGNO(pagep) == PGNO_ROOT)
722 RE_NREC_ADJ(pagep, -(argp->adjust));
724 LSN(pagep) = argp->lsn;
727 if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0)
730 done: *lsnp = argp->prev_lsn;
737 * __bam_cdel_recover --
738 * Recovery function for the intent-to-delete of a cursor record.
740 * PUBLIC: int __bam_cdel_recover
741 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
744 __bam_cdel_recover(logp, dbtp, lsnp, redo, info)
751 __bam_cdel_args *argp;
756 int cmp_n, cmp_p, modified, ret;
758 REC_PRINT(__bam_cdel_print);
759 REC_INTRO(__bam_cdel_read);
761 /* Get the page; if it never existed and we're undoing, we're done. */
762 if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0) {
765 (void)__db_pgerr(file_dbp, argp->pgno);
770 cmp_n = log_compare(lsnp, &LSN(pagep));
771 cmp_p = log_compare(&LSN(pagep), &argp->lsn);
772 if (cmp_p == 0 && redo) {
773 /* Need to redo update described. */
774 if (pagep->type == P_DUPLICATE)
775 B_DSET(GET_BKEYDATA(pagep, argp->indx)->type);
777 B_DSET(GET_BKEYDATA(pagep, argp->indx + O_INDX)->type);
781 } else if (cmp_n == 0 && !redo) {
782 /* Need to undo update described. */
783 if (pagep->type == P_DUPLICATE)
784 B_DCLR(GET_BKEYDATA(pagep, argp->indx)->type);
786 B_DCLR(GET_BKEYDATA(pagep, argp->indx + O_INDX)->type);
788 LSN(pagep) = argp->lsn;
791 if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0)
794 done: *lsnp = argp->prev_lsn;
801 * __bam_repl_recover --
802 * Recovery function for page item replacement.
804 * PUBLIC: int __bam_repl_recover
805 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
808 __bam_repl_recover(logp, dbtp, lsnp, redo, info)
815 __bam_repl_args *argp;
822 int cmp_n, cmp_p, modified, ret;
825 REC_PRINT(__bam_repl_print);
826 REC_INTRO(__bam_repl_read);
828 /* Get the page; if it never existed and we're undoing, we're done. */
829 if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0) {
832 (void)__db_pgerr(file_dbp, argp->pgno);
835 bk = GET_BKEYDATA(pagep, argp->indx);
838 cmp_n = log_compare(lsnp, &LSN(pagep));
839 cmp_p = log_compare(&LSN(pagep), &argp->lsn);
840 if (cmp_p == 0 && redo) {
842 * Need to redo update described.
844 * Re-build the replacement item.
846 memset(&dbt, 0, sizeof(dbt));
847 dbt.size = argp->prefix + argp->suffix + argp->repl.size;
848 if ((ret = __os_malloc(dbt.size, NULL, &dbt.data)) != 0)
851 memcpy(p, bk->data, argp->prefix);
853 memcpy(p, argp->repl.data, argp->repl.size);
854 p += argp->repl.size;
855 memcpy(p, bk->data + (bk->len - argp->suffix), argp->suffix);
857 ret = __bam_ritem(dbc, pagep, argp->indx, &dbt);
858 __os_free(dbt.data, dbt.size);
864 } else if (cmp_n == 0 && !redo) {
866 * Need to undo update described.
868 * Re-build the original item.
870 memset(&dbt, 0, sizeof(dbt));
871 dbt.size = argp->prefix + argp->suffix + argp->orig.size;
872 if ((ret = __os_malloc(dbt.size, NULL, &dbt.data)) != 0)
875 memcpy(p, bk->data, argp->prefix);
877 memcpy(p, argp->orig.data, argp->orig.size);
878 p += argp->orig.size;
879 memcpy(p, bk->data + (bk->len - argp->suffix), argp->suffix);
881 ret = __bam_ritem(dbc, pagep, argp->indx, &dbt);
882 __os_free(dbt.data, dbt.size);
886 /* Reset the deleted flag, if necessary. */
888 B_DSET(GET_BKEYDATA(pagep, argp->indx)->type);
890 LSN(pagep) = argp->lsn;
893 if ((ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0)) != 0)
896 done: *lsnp = argp->prev_lsn;
900 err: (void)memp_fput(mpf, pagep, 0);