1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 1996,2008 Oracle.  All rights reserved.
5 *
6 * $Id: log_compare.c,v 12.13 2008/01/08 20:58:41 bostic Exp $
7 */
8
9#include "db_config.h"
10
11#include "db_int.h"
12#include "dbinc/log.h"
13
14/*
15 * log_compare --
16 *	Compare two LSN's; return 1, 0, -1 if first is >, == or < second.
17 *
18 * EXTERN: int log_compare __P((const DB_LSN *, const DB_LSN *));
19 */
20int
21log_compare(lsn0, lsn1)
22	const DB_LSN *lsn0, *lsn1;
23{
24	return (LOG_COMPARE(lsn0, lsn1));
25}
26
27/*
28 * __log_check_page_lsn --
29 *	Panic if the page's lsn in past the end of the current log.
30 *
31 * PUBLIC: int __log_check_page_lsn __P((ENV *, DB *, DB_LSN *));
32 */
33int
34__log_check_page_lsn(env, dbp, lsnp)
35	ENV *env;
36	DB *dbp;
37	DB_LSN *lsnp;
38{
39	LOG *lp;
40	int ret;
41
42	lp = env->lg_handle->reginfo.primary;
43	LOG_SYSTEM_LOCK(env);
44
45	ret = LOG_COMPARE(lsnp, &lp->lsn);
46
47	LOG_SYSTEM_UNLOCK(env);
48
49	if (ret < 0)
50		return (0);
51
52	__db_errx(env,
53	    "file %s has LSN %lu/%lu, past end of log at %lu/%lu",
54	    dbp == NULL || dbp->fname == NULL ? "unknown" : dbp->fname,
55	    (u_long)lsnp->file, (u_long)lsnp->offset,
56	    (u_long)lp->lsn.file, (u_long)lp->lsn.offset);
57	__db_errx(env, "%s",
58    "Commonly caused by moving a database from one database environment");
59	__db_errx(env, "%s",
60    "to another without clearing the database LSNs, or by removing all of");
61	__db_errx(env, "%s",
62    "the log files from a database environment");
63	return (EINVAL);
64}
65