2
* See the file LICENSE for redistribution information.
4
* Copyright (c) 1999-2001
5
* Sleepycat Software. All rights reserved.
7
* $Id: db_verify.h,v 1.20 2001/05/10 15:33:58 krinsky Exp $
14
* Structures and macros for the storage and retrieval of all information
15
* needed for inter-page verification of a database.
19
* EPRINT is the macro for error printing. Takes as an arg the arg set
24
if (!LF_ISSET(DB_SALVAGE)) \
28
/* For fatal type errors--i.e., verifier bugs. */
29
#define TYPE_ERR_PRINT(dbenv, func, pgno, ptype) \
30
EPRINT(((dbenv), "%s called on nonsensical page %lu of type %lu", \
31
(func), (u_long)(pgno), (u_long)(ptype)));
34
* Note that 0 is, in general, a valid pgno, despite equalling PGNO_INVALID;
35
* we have to test it separately where it's not appropriate.
37
#define IS_VALID_PGNO(x) ((x) <= vdp->last_pgno)
40
* Flags understood by the btree structure checks (esp. __bam_vrfy_subtree).
41
* These share the same space as the global flags to __db_verify, and must not
42
* dip below 0x00010000.
44
#define ST_DUPOK 0x00010000 /* Duplicates are acceptable. */
45
#define ST_DUPSET 0x00020000 /* Subtree is in a duplicate tree. */
46
#define ST_DUPSORT 0x00040000 /* Duplicates are sorted. */
47
#define ST_IS_RECNO 0x00080000 /* Subtree is a recno. */
48
#define ST_OVFL_LEAF 0x00100000 /* Overflow reffed from leaf page. */
49
#define ST_RECNUM 0x00200000 /* Subtree has record numbering on. */
50
#define ST_RELEN 0x00400000 /* Subtree has fixed-length records. */
51
#define ST_TOPLEVEL 0x00800000 /* Subtree == entire tree */
54
* Flags understood by __bam_salvage and __db_salvage. These need not share
55
* the same space with the __bam_vrfy_subtree flags, but must share with
58
#define SA_SKIPFIRSTKEY 0x00080000
61
* VRFY_DBINFO is the fundamental structure; it either represents the database
62
* of subdatabases, or the sole database if there are no subdatabases.
64
struct __vrfy_dbinfo {
65
/* Info about this database in particular. */
68
/* List of subdatabase meta pages, if any. */
69
LIST_HEAD(__subdbs, __vrfy_childinfo) subdbs;
71
/* File-global info--stores VRFY_PAGEINFOs for each page. */
74
/* Child database--stores VRFY_CHILDINFOs of each page. */
77
/* Page info structures currently in use. */
78
LIST_HEAD(__activepips, __vrfy_pageinfo) activepips;
81
* DB we use to keep track of which pages are linked somehow
82
* during verification. 0 is the default, "unseen"; 1 is seen.
87
* This is a database we use during salvaging to keep track of which
88
* overflow and dup pages we need to come back to at the end and print
89
* with key "UNKNOWN". Pages which print with a good key get set
90
* to SALVAGE_IGNORE; others get set, as appropriate, to SALVAGE_LDUP,
91
* SALVAGE_LRECNODUP, SALVAGE_OVERFLOW for normal db overflow pages,
92
* and SALVAGE_BTREE, SALVAGE_LRECNO, and SALVAGE_HASH for subdb
95
#define SALVAGE_INVALID 0
96
#define SALVAGE_IGNORE 1
97
#define SALVAGE_LDUP 2
98
#define SALVAGE_LRECNODUP 3
99
#define SALVAGE_OVERFLOW 4
100
#define SALVAGE_LBTREE 5
101
#define SALVAGE_HASH 6
102
#define SALVAGE_LRECNO 7
106
db_pgno_t pgs_remaining; /* For dbp->db_feedback(). */
108
/* Queue needs these to verify data pages in the first pass. */
112
#define SALVAGE_PRINTHEADER 0x01
113
#define SALVAGE_PRINTFOOTER 0x02
118
* The amount of state information we need per-page is small enough that
119
* it's not worth the trouble to define separate structures for each
120
* possible type of page, and since we're doing verification with these we
121
* have to be open to the possibility that page N will be of a completely
122
* unexpected type anyway. So we define one structure here with all the
123
* info we need for inter-page verification.
125
struct __vrfy_pageinfo {
136
db_pgno_t free; /* Free list head. */
138
db_indx_t entries; /* Actual number of entries. */
140
db_recno_t rec_cnt; /* Record count. */
141
u_int32_t re_len; /* Record length. */
149
* Note that refcount is the refcount for an overflow page; pi_refcount
150
* is this structure's own refcount!
155
#define VRFY_DUPS_UNSORTED 0x0001 /* Have to flag the negative! */
156
#define VRFY_HAS_DUPS 0x0002
157
#define VRFY_HAS_DUPSORT 0x0004 /* Has the flag set. */
158
#define VRFY_HAS_SUBDBS 0x0008
159
#define VRFY_HAS_RECNUMS 0x0010
160
#define VRFY_INCOMPLETE 0x0020 /* Meta or item order checks incomp. */
161
#define VRFY_IS_ALLZEROES 0x0040 /* Hash page we haven't touched? */
162
#define VRFY_IS_FIXEDLEN 0x0080
163
#define VRFY_IS_RECNO 0x0100
164
#define VRFY_IS_RRECNO 0x0200
165
#define VRFY_OVFL_LEAFSEEN 0x0400
168
LIST_ENTRY(__vrfy_pageinfo) links;
169
u_int32_t pi_refcount;
170
}; /* VRFY_PAGEINFO */
172
struct __vrfy_childinfo {
175
#define V_DUPLICATE 1 /* off-page dup metadata */
176
#define V_OVERFLOW 2 /* overflow page */
177
#define V_RECNO 3 /* btree internal or leaf page */
179
db_recno_t nrecs; /* record count on a btree subtree */
180
u_int32_t tlen; /* ovfl. item total size */
182
LIST_ENTRY(__vrfy_childinfo) links;
183
}; /* VRFY_CHILDINFO */
185
#endif /* _DB_VERIFY_H_ */