static VALUE bdb_lsn_log_compare(VALUE obj, VALUE a) { struct dblsnst *lsnst1, *lsnst2; bdb_ENV *envst1, *envst2; if (!rb_obj_is_kind_of(a, bdb_cLsn)) { rb_raise(bdb_eFatal, "invalid argument for <=>"); } GetLsn(obj, lsnst1, envst1); GetLsn(a, lsnst2, envst2); return INT2NUM(log_compare(lsnst1->lsn, lsnst2->lsn)); }
int __db_txnlist_lsnadd(int val, DB_TXNLIST *elp, DB_LSN *lsnp, u_int32_t flags) { int i; for (i = 0; i < (!(flags & (0x1)) ? 1 : elp->u.l.ntxns); i++) { int __j; DB_LSN __tmp; val++; for (__j = 0; __j < elp->u.l.ntxns - 1; __j++) if (log_compare(&elp->u.l.lsn_array[__j], &elp->u.l.lsn_array[__j + 1]) < 0) { __tmp = elp->u.l.lsn_array[__j]; elp->u.l.lsn_array[__j] = elp->u.l.lsn_array[__j + 1]; elp->u.l.lsn_array[__j + 1] = __tmp; } } *lsnp = elp->u.l.lsn_array[0]; return val; }
/* * Log_setline -- * Reset the line to its original appearance. * * XXX * There's a bug in this code due to our not logging cursor movements * unless a change was made. If you do a change, move off the line, * then move back on and do a 'U', the line will be restored to the way * it was before the original change. * * PUBLIC: int log_setline __P((SCR *)); */ int log_setline(SCR *sp) { EXF *ep; LMARK lm; MARK m; db_recno_t lno; u_char *p; size_t size; ep = sp->ep; if (F_ISSET(ep, F_NOLOG)) { msgq(sp, M_ERR, "012|Logging not being performed, undo not possible"); return (1); } if (log_compare(&ep->lsn_cur, &ep->lsn_first) <= 0) { msgq(sp, M_BERR, "011|No changes to undo"); return (1); } return __vi_log_traverse(sp, UNDO_SETLINE, &m); }
/* * Log_forward -- * Roll the log forward one operation. * * PUBLIC: int log_forward __P((SCR *, MARK *)); */ int log_forward(SCR *sp, MARK *rp) { EXF *ep; LMARK lm; MARK m; db_recno_t lno; int didop; u_char *p; size_t size; ep = sp->ep; if (F_ISSET(ep, F_NOLOG)) { msgq(sp, M_ERR, "013|Logging not being performed, roll-forward not possible"); return (1); } if (log_compare(&ep->lsn_cur, &ep->lsn_high) >= 0) { msgq(sp, M_BERR, "014|No changes to re-do"); return (1); } return __vi_log_traverse(sp, UNDO_FORWARD, rp); }
/* * Log_backward -- * Roll the log backward one operation. * * PUBLIC: int log_backward __P((SCR *, MARK *)); */ int log_backward(SCR *sp, MARK *rp) { EXF *ep; LMARK lm; MARK m; db_recno_t lno; int didop; u_char *p; size_t size; ep = sp->ep; if (F_ISSET(ep, F_NOLOG)) { msgq(sp, M_ERR, "010|Logging not being performed, undo not possible"); return (1); } if (log_compare(&ep->lsn_cur, &ep->lsn_first) <= 0) { msgq(sp, M_BERR, "011|No changes to undo"); return (1); } return __vi_log_traverse(sp, UNDO_BACKWARD, rp); }