Deleted Added
full compact
bt_debug.c (1573) bt_debug.c (14272)
1/*-
1/*-
2 * Copyright (c) 1990, 1993
2 * Copyright (c) 1990, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Mike Olson.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:

--- 19 unchanged lines hidden (view full) ---

30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Mike Olson.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:

--- 19 unchanged lines hidden (view full) ---

30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char sccsid[] = "@(#)bt_debug.c 8.2 (Berkeley) 2/21/94";
38static char sccsid[] = "@(#)bt_debug.c 8.5 (Berkeley) 8/17/94";
39#endif /* LIBC_SCCS and not lint */
40
41#include <sys/param.h>
42
43#include <stdio.h>
44#include <stdlib.h>
45#include <string.h>
46

--- 13 unchanged lines hidden (view full) ---

60{
61 BTREE *t;
62 PAGE *h;
63 pgno_t i;
64 char *sep;
65
66 t = dbp->internal;
67 (void)fprintf(stderr, "%s: pgsz %d",
39#endif /* LIBC_SCCS and not lint */
40
41#include <sys/param.h>
42
43#include <stdio.h>
44#include <stdlib.h>
45#include <string.h>
46

--- 13 unchanged lines hidden (view full) ---

60{
61 BTREE *t;
62 PAGE *h;
63 pgno_t i;
64 char *sep;
65
66 t = dbp->internal;
67 (void)fprintf(stderr, "%s: pgsz %d",
68 ISSET(t, B_INMEM) ? "memory" : "disk", t->bt_psize);
69 if (ISSET(t, R_RECNO))
68 F_ISSET(t, B_INMEM) ? "memory" : "disk", t->bt_psize);
69 if (F_ISSET(t, R_RECNO))
70 (void)fprintf(stderr, " keys %lu", t->bt_nrecs);
71#undef X
72#define X(flag, name) \
70 (void)fprintf(stderr, " keys %lu", t->bt_nrecs);
71#undef X
72#define X(flag, name) \
73 if (ISSET(t, flag)) { \
73 if (F_ISSET(t, flag)) { \
74 (void)fprintf(stderr, "%s%s", sep, name); \
75 sep = ", "; \
76 }
74 (void)fprintf(stderr, "%s%s", sep, name); \
75 sep = ", "; \
76 }
77 if (t->bt_flags) {
77 if (t->flags != 0) {
78 sep = " flags (";
78 sep = " flags (";
79 X(B_DELCRSR, "DELCRSR");
80 X(R_FIXLEN, "FIXLEN");
81 X(B_INMEM, "INMEM");
82 X(B_NODUPS, "NODUPS");
83 X(B_RDONLY, "RDONLY");
84 X(R_RECNO, "RECNO");
79 X(R_FIXLEN, "FIXLEN");
80 X(B_INMEM, "INMEM");
81 X(B_NODUPS, "NODUPS");
82 X(B_RDONLY, "RDONLY");
83 X(R_RECNO, "RECNO");
85 X(B_SEQINIT, "SEQINIT");
86 X(B_METADIRTY,"METADIRTY");
87 (void)fprintf(stderr, ")\n");
88 }
89#undef X
90
91 for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) {
92 __bt_dpage(h);
93 (void)mpool_put(t->bt_mp, h, 0);

--- 9 unchanged lines hidden (view full) ---

103void
104__bt_dmpage(h)
105 PAGE *h;
106{
107 BTMETA *m;
108 char *sep;
109
110 m = (BTMETA *)h;
84 X(B_METADIRTY,"METADIRTY");
85 (void)fprintf(stderr, ")\n");
86 }
87#undef X
88
89 for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) {
90 __bt_dpage(h);
91 (void)mpool_put(t->bt_mp, h, 0);

--- 9 unchanged lines hidden (view full) ---

101void
102__bt_dmpage(h)
103 PAGE *h;
104{
105 BTMETA *m;
106 char *sep;
107
108 m = (BTMETA *)h;
111 (void)fprintf(stderr, "magic %lx\n", m->m_magic);
112 (void)fprintf(stderr, "version %lu\n", m->m_version);
113 (void)fprintf(stderr, "psize %lu\n", m->m_psize);
114 (void)fprintf(stderr, "free %lu\n", m->m_free);
115 (void)fprintf(stderr, "nrecs %lu\n", m->m_nrecs);
116 (void)fprintf(stderr, "flags %lu", m->m_flags);
109 (void)fprintf(stderr, "magic %lx\n", m->magic);
110 (void)fprintf(stderr, "version %lu\n", m->version);
111 (void)fprintf(stderr, "psize %lu\n", m->psize);
112 (void)fprintf(stderr, "free %lu\n", m->free);
113 (void)fprintf(stderr, "nrecs %lu\n", m->nrecs);
114 (void)fprintf(stderr, "flags %lu", m->flags);
117#undef X
118#define X(flag, name) \
115#undef X
116#define X(flag, name) \
119 if (m->m_flags & flag) { \
117 if (m->flags & flag) { \
120 (void)fprintf(stderr, "%s%s", sep, name); \
121 sep = ", "; \
122 }
118 (void)fprintf(stderr, "%s%s", sep, name); \
119 sep = ", "; \
120 }
123 if (m->m_flags) {
121 if (m->flags) {
124 sep = " (";
125 X(B_NODUPS, "NODUPS");
126 X(R_RECNO, "RECNO");
127 (void)fprintf(stderr, ")");
128 }
129}
130
131/*

--- 55 unchanged lines hidden (view full) ---

187 if (h->flags & P_OVERFLOW)
188 return;
189
190 top = NEXTINDEX(h);
191 (void)fprintf(stderr, " lower %3d upper %3d nextind %d\n",
192 h->lower, h->upper, top);
193 for (cur = 0; cur < top; cur++) {
194 (void)fprintf(stderr, "\t[%03d] %4d ", cur, h->linp[cur]);
122 sep = " (";
123 X(B_NODUPS, "NODUPS");
124 X(R_RECNO, "RECNO");
125 (void)fprintf(stderr, ")");
126 }
127}
128
129/*

--- 55 unchanged lines hidden (view full) ---

185 if (h->flags & P_OVERFLOW)
186 return;
187
188 top = NEXTINDEX(h);
189 (void)fprintf(stderr, " lower %3d upper %3d nextind %d\n",
190 h->lower, h->upper, top);
191 for (cur = 0; cur < top; cur++) {
192 (void)fprintf(stderr, "\t[%03d] %4d ", cur, h->linp[cur]);
195 switch(h->flags & P_TYPE) {
193 switch (h->flags & P_TYPE) {
196 case P_BINTERNAL:
197 bi = GETBINTERNAL(h, cur);
198 (void)fprintf(stderr,
199 "size %03d pgno %03d", bi->ksize, bi->pgno);
200 if (bi->flags & P_BIGKEY)
201 (void)fprintf(stderr, " (indirect)");
202 else if (bi->ksize)
203 (void)fprintf(stderr,

--- 5 unchanged lines hidden (view full) ---

209 ri->nrecs, ri->pgno);
210 break;
211 case P_BLEAF:
212 bl = GETBLEAF(h, cur);
213 if (bl->flags & P_BIGKEY)
214 (void)fprintf(stderr,
215 "big key page %lu size %u/",
216 *(pgno_t *)bl->bytes,
194 case P_BINTERNAL:
195 bi = GETBINTERNAL(h, cur);
196 (void)fprintf(stderr,
197 "size %03d pgno %03d", bi->ksize, bi->pgno);
198 if (bi->flags & P_BIGKEY)
199 (void)fprintf(stderr, " (indirect)");
200 else if (bi->ksize)
201 (void)fprintf(stderr,

--- 5 unchanged lines hidden (view full) ---

207 ri->nrecs, ri->pgno);
208 break;
209 case P_BLEAF:
210 bl = GETBLEAF(h, cur);
211 if (bl->flags & P_BIGKEY)
212 (void)fprintf(stderr,
213 "big key page %lu size %u/",
214 *(pgno_t *)bl->bytes,
217 *(size_t *)(bl->bytes + sizeof(pgno_t)));
215 *(u_int32_t *)(bl->bytes + sizeof(pgno_t)));
218 else if (bl->ksize)
219 (void)fprintf(stderr, "%s/", bl->bytes);
220 if (bl->flags & P_BIGDATA)
221 (void)fprintf(stderr,
222 "big data page %lu size %u",
223 *(pgno_t *)(bl->bytes + bl->ksize),
216 else if (bl->ksize)
217 (void)fprintf(stderr, "%s/", bl->bytes);
218 if (bl->flags & P_BIGDATA)
219 (void)fprintf(stderr,
220 "big data page %lu size %u",
221 *(pgno_t *)(bl->bytes + bl->ksize),
224 *(size_t *)(bl->bytes + bl->ksize +
222 *(u_int32_t *)(bl->bytes + bl->ksize +
225 sizeof(pgno_t)));
226 else if (bl->dsize)
227 (void)fprintf(stderr, "%.*s",
228 (int)bl->dsize, bl->bytes + bl->ksize);
229 break;
230 case P_RLEAF:
231 rl = GETRLEAF(h, cur);
232 if (rl->flags & P_BIGDATA)
233 (void)fprintf(stderr,
234 "big data page %lu size %u",
235 *(pgno_t *)rl->bytes,
223 sizeof(pgno_t)));
224 else if (bl->dsize)
225 (void)fprintf(stderr, "%.*s",
226 (int)bl->dsize, bl->bytes + bl->ksize);
227 break;
228 case P_RLEAF:
229 rl = GETRLEAF(h, cur);
230 if (rl->flags & P_BIGDATA)
231 (void)fprintf(stderr,
232 "big data page %lu size %u",
233 *(pgno_t *)rl->bytes,
236 *(size_t *)(rl->bytes + sizeof(pgno_t)));
234 *(u_int32_t *)(rl->bytes + sizeof(pgno_t)));
237 else if (rl->dsize)
238 (void)fprintf(stderr,
239 "%.*s", (int)rl->dsize, rl->bytes);
240 break;
241 }
242 (void)fprintf(stderr, "\n");
243 }
244}

--- 17 unchanged lines hidden (view full) ---

262 pgno_t i, pcont, pinternal, pleaf;
263 u_long ifree, lfree, nkeys;
264 int levels;
265
266 t = dbp->internal;
267 pcont = pinternal = pleaf = 0;
268 nkeys = ifree = lfree = 0;
269 for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) {
235 else if (rl->dsize)
236 (void)fprintf(stderr,
237 "%.*s", (int)rl->dsize, rl->bytes);
238 break;
239 }
240 (void)fprintf(stderr, "\n");
241 }
242}

--- 17 unchanged lines hidden (view full) ---

260 pgno_t i, pcont, pinternal, pleaf;
261 u_long ifree, lfree, nkeys;
262 int levels;
263
264 t = dbp->internal;
265 pcont = pinternal = pleaf = 0;
266 nkeys = ifree = lfree = 0;
267 for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) {
270 switch(h->flags & P_TYPE) {
268 switch (h->flags & P_TYPE) {
271 case P_BINTERNAL:
272 case P_RINTERNAL:
273 ++pinternal;
274 ifree += h->upper - h->lower;
275 break;
276 case P_BLEAF:
277 case P_RLEAF:
278 ++pleaf;

--- 11 unchanged lines hidden (view full) ---

290 for (i = P_ROOT, levels = 0 ;; ++levels) {
291 h = mpool_get(t->bt_mp, i, 0);
292 if (h->flags & (P_BLEAF|P_RLEAF)) {
293 if (levels == 0)
294 levels = 1;
295 (void)mpool_put(t->bt_mp, h, 0);
296 break;
297 }
269 case P_BINTERNAL:
270 case P_RINTERNAL:
271 ++pinternal;
272 ifree += h->upper - h->lower;
273 break;
274 case P_BLEAF:
275 case P_RLEAF:
276 ++pleaf;

--- 11 unchanged lines hidden (view full) ---

288 for (i = P_ROOT, levels = 0 ;; ++levels) {
289 h = mpool_get(t->bt_mp, i, 0);
290 if (h->flags & (P_BLEAF|P_RLEAF)) {
291 if (levels == 0)
292 levels = 1;
293 (void)mpool_put(t->bt_mp, h, 0);
294 break;
295 }
298 i = ISSET(t, R_RECNO) ?
296 i = F_ISSET(t, R_RECNO) ?
299 GETRINTERNAL(h, 0)->pgno :
300 GETBINTERNAL(h, 0)->pgno;
301 (void)mpool_put(t->bt_mp, h, 0);
302 }
303
304 (void)fprintf(stderr, "%d level%s with %ld keys",
305 levels, levels == 1 ? "" : "s", nkeys);
297 GETRINTERNAL(h, 0)->pgno :
298 GETBINTERNAL(h, 0)->pgno;
299 (void)mpool_put(t->bt_mp, h, 0);
300 }
301
302 (void)fprintf(stderr, "%d level%s with %ld keys",
303 levels, levels == 1 ? "" : "s", nkeys);
306 if (ISSET(t, R_RECNO))
304 if (F_ISSET(t, R_RECNO))
307 (void)fprintf(stderr, " (%ld header count)", t->bt_nrecs);
308 (void)fprintf(stderr,
309 "\n%lu pages (leaf %ld, internal %ld, overflow %ld)\n",
310 pinternal + pleaf + pcont, pleaf, pinternal, pcont);
311 (void)fprintf(stderr, "%ld cache hits, %ld cache misses\n",
312 bt_cache_hit, bt_cache_miss);
313 (void)fprintf(stderr, "%ld splits (%ld root splits, %ld sort splits)\n",
314 bt_split, bt_rootsplit, bt_sortsplit);

--- 17 unchanged lines hidden ---
305 (void)fprintf(stderr, " (%ld header count)", t->bt_nrecs);
306 (void)fprintf(stderr,
307 "\n%lu pages (leaf %ld, internal %ld, overflow %ld)\n",
308 pinternal + pleaf + pcont, pleaf, pinternal, pcont);
309 (void)fprintf(stderr, "%ld cache hits, %ld cache misses\n",
310 bt_cache_hit, bt_cache_miss);
311 (void)fprintf(stderr, "%ld splits (%ld root splits, %ld sort splits)\n",
312 bt_split, bt_rootsplit, bt_sortsplit);

--- 17 unchanged lines hidden ---