1 /*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 1996, 2013 Oracle and/or its affiliates. All rights reserved.
5 *
6 * $Id$
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 */
20 int
log_compare(lsn0,lsn1)21 log_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 */
33 int
__log_check_page_lsn(env,dbp,lsnp)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, DB_STR_A("2506",
53 "file %s has LSN %lu/%lu, past end of log at %lu/%lu",
54 "%s %lu %lu %lu %lu"),
55 dbp == NULL ||
56 dbp->fname == NULL ? DB_STR_P("unknown") : dbp->fname,
57 (u_long)lsnp->file, (u_long)lsnp->offset,
58 (u_long)lp->lsn.file, (u_long)lp->lsn.offset);
59 __db_errx(env, DB_STR("2507",
60 "Commonly caused by moving a database from one database environment"));
61 __db_errx(env, DB_STR("2508",
62 "to another without clearing the database LSNs, or by removing all of"));
63 __db_errx(env, DB_STR("2509",
64 "the log files from a database environment"));
65 return (EINVAL);
66 }
67