mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 12:32:27 +01:00
155e78f014
BitKeeper/deleted/.del-ex_access.wpj~3df6ae8c99bf7c5f: Delete: bdb/build_vxworks/ex_access/ex_access.wpj BitKeeper/deleted/.del-ex_btrec.wpj~a7622f1c6f432dc6: Delete: bdb/build_vxworks/ex_btrec/ex_btrec.wpj BitKeeper/deleted/.del-ex_dbclient.wpj~7345440f3b204cdd: Delete: bdb/build_vxworks/ex_dbclient/ex_dbclient.wpj BitKeeper/deleted/.del-ex_env.wpj~fbe1ab10b04e8b74: Delete: bdb/build_vxworks/ex_env/ex_env.wpj BitKeeper/deleted/.del-ex_mpool.wpj~4479cfd5c45f327d: Delete: bdb/build_vxworks/ex_mpool/ex_mpool.wpj BitKeeper/deleted/.del-ex_tpcb.wpj~f78093006e14bf41: Delete: bdb/build_vxworks/ex_tpcb/ex_tpcb.wpj BitKeeper/deleted/.del-db_buildall.dsp~bd749ff6da11682: Delete: bdb/build_win32/db_buildall.dsp BitKeeper/deleted/.del-cxx_app.cpp~ad8df8e0791011ed: Delete: bdb/cxx/cxx_app.cpp BitKeeper/deleted/.del-cxx_log.cpp~a50ff3118fe06952: Delete: bdb/cxx/cxx_log.cpp BitKeeper/deleted/.del-cxx_table.cpp~ecd751e79b055556: Delete: bdb/cxx/cxx_table.cpp BitKeeper/deleted/.del-namemap.txt~796a3acd3885d8fd: Delete: bdb/cxx/namemap.txt BitKeeper/deleted/.del-Design.fileop~3ca4da68f1727373: Delete: bdb/db/Design.fileop BitKeeper/deleted/.del-db185_int.h~61bee3736e7959ef: Delete: bdb/db185/db185_int.h BitKeeper/deleted/.del-acconfig.h~411e8854d67ad8b5: Delete: bdb/dist/acconfig.h BitKeeper/deleted/.del-mutex.m4~a13383cde18a64e1: Delete: bdb/dist/aclocal/mutex.m4 BitKeeper/deleted/.del-options.m4~b9d0ca637213750a: Delete: bdb/dist/aclocal/options.m4 BitKeeper/deleted/.del-programs.m4~3ce7890b47732b30: Delete: bdb/dist/aclocal/programs.m4 BitKeeper/deleted/.del-tcl.m4~f944e2db93c3b6db: Delete: bdb/dist/aclocal/tcl.m4 BitKeeper/deleted/.del-types.m4~59cae158c9a32cff: Delete: bdb/dist/aclocal/types.m4 BitKeeper/deleted/.del-script~d38f6d3a4f159cb4: Delete: bdb/dist/build/script BitKeeper/deleted/.del-configure.in~ac795a92c8fe049c: Delete: bdb/dist/configure.in BitKeeper/deleted/.del-ltconfig~66bbd007d8024af: Delete: bdb/dist/ltconfig BitKeeper/deleted/.del-rec_ctemp~a28554362534f00a: Delete: bdb/dist/rec_ctemp BitKeeper/deleted/.del-s_tcl~2ffe4326459fcd9f: Delete: bdb/dist/s_tcl BitKeeper/deleted/.del-.IGNORE_ME~d8148b08fa7d5d15: Delete: bdb/dist/template/.IGNORE_ME BitKeeper/deleted/.del-btree.h~179f2aefec1753d: Delete: bdb/include/btree.h BitKeeper/deleted/.del-cxx_int.h~6b649c04766508f8: Delete: bdb/include/cxx_int.h BitKeeper/deleted/.del-db.src~6b433ae615b16a8d: Delete: bdb/include/db.src BitKeeper/deleted/.del-db_185.h~ad8b373d9391d35c: Delete: bdb/include/db_185.h BitKeeper/deleted/.del-db_am.h~a714912b6b75932f: Delete: bdb/include/db_am.h BitKeeper/deleted/.del-db_cxx.h~fcafadf45f5d19e9: Delete: bdb/include/db_cxx.h BitKeeper/deleted/.del-db_dispatch.h~6844f20f7eb46904: Delete: bdb/include/db_dispatch.h BitKeeper/deleted/.del-db_int.src~419a3f48b6a01da7: Delete: bdb/include/db_int.src BitKeeper/deleted/.del-db_join.h~76f9747a42c3399a: Delete: bdb/include/db_join.h BitKeeper/deleted/.del-db_page.h~e302ca3a4db3abdc: Delete: bdb/include/db_page.h BitKeeper/deleted/.del-db_server_int.h~e1d20b6ba3bca1ab: Delete: bdb/include/db_server_int.h BitKeeper/deleted/.del-db_shash.h~5fbf2d696fac90f3: Delete: bdb/include/db_shash.h BitKeeper/deleted/.del-db_swap.h~1e60887550864a59: Delete: bdb/include/db_swap.h BitKeeper/deleted/.del-db_upgrade.h~c644eee73701fc8d: Delete: bdb/include/db_upgrade.h BitKeeper/deleted/.del-db_verify.h~b8d6c297c61f342e: Delete: bdb/include/db_verify.h BitKeeper/deleted/.del-debug.h~dc2b4f2cf27ccebc: Delete: bdb/include/debug.h BitKeeper/deleted/.del-hash.h~2aaa548b28882dfb: Delete: bdb/include/hash.h BitKeeper/deleted/.del-lock.h~a761c1b7de57b77f: Delete: bdb/include/lock.h BitKeeper/deleted/.del-log.h~ff20184238e35e4d: Delete: bdb/include/log.h BitKeeper/deleted/.del-mp.h~7e317597622f3411: Delete: bdb/include/mp.h BitKeeper/deleted/.del-mutex.h~d3ae7a2977a68137: Delete: bdb/include/mutex.h BitKeeper/deleted/.del-os.h~91867cc8757cd0e3: Delete: bdb/include/os.h BitKeeper/deleted/.del-os_jump.h~e1b939fa5151d4be: Delete: bdb/include/os_jump.h BitKeeper/deleted/.del-qam.h~6fad0c1b5723d597: Delete: bdb/include/qam.h BitKeeper/deleted/.del-queue.h~4c72c0826c123d5: Delete: bdb/include/queue.h BitKeeper/deleted/.del-region.h~513fe04d977ca0fc: Delete: bdb/include/region.h BitKeeper/deleted/.del-shqueue.h~525fc3e6c2025c36: Delete: bdb/include/shqueue.h BitKeeper/deleted/.del-tcl_db.h~c536fd61a844f23f: Delete: bdb/include/tcl_db.h BitKeeper/deleted/.del-txn.h~c8d94b221ec147e4: Delete: bdb/include/txn.h BitKeeper/deleted/.del-xa.h~ecc466493aae9d9a: Delete: bdb/include/xa.h BitKeeper/deleted/.del-DbRecoveryInit.java~756b52601a0b9023: Delete: bdb/java/src/com/sleepycat/db/DbRecoveryInit.java BitKeeper/deleted/.del-DbTxnRecover.java~74607cba7ab89d6d: Delete: bdb/java/src/com/sleepycat/db/DbTxnRecover.java BitKeeper/deleted/.del-lock_conflict.c~fc5e0f14cf597a2b: Delete: bdb/lock/lock_conflict.c BitKeeper/deleted/.del-log.src~53ac9e7b5cb023f2: Delete: bdb/log/log.src BitKeeper/deleted/.del-log_findckp.c~24287f008916e81f: Delete: bdb/log/log_findckp.c BitKeeper/deleted/.del-log_rec.c~d51711f2cac09297: Delete: bdb/log/log_rec.c BitKeeper/deleted/.del-log_register.c~b40bb4efac75ca15: Delete: bdb/log/log_register.c BitKeeper/deleted/.del-Design~b3d0f179f2767b: Delete: bdb/mp/Design BitKeeper/deleted/.del-os_finit.c~95dbefc6fe79b26c: Delete: bdb/os/os_finit.c BitKeeper/deleted/.del-os_abs.c~df95d1e7db81924: Delete: bdb/os_vxworks/os_abs.c BitKeeper/deleted/.del-os_finit.c~803b484bdb9d0122: Delete: bdb/os_vxworks/os_finit.c BitKeeper/deleted/.del-os_map.c~3a6d7926398b76d3: Delete: bdb/os_vxworks/os_map.c BitKeeper/deleted/.del-os_finit.c~19a227c6d3c78ad: Delete: bdb/os_win32/os_finit.c BitKeeper/deleted/.del-log-corruption.patch~1cf2ecc7c6408d5d: Delete: bdb/patches/log-corruption.patch BitKeeper/deleted/.del-Btree.pm~af6d0c5eaed4a98e: Delete: bdb/perl.BerkeleyDB/BerkeleyDB/Btree.pm BitKeeper/deleted/.del-BerkeleyDB.pm~7244036d4482643: Delete: bdb/perl.BerkeleyDB/BerkeleyDB.pm BitKeeper/deleted/.del-BerkeleyDB.pod~e7b18fd6132448e3: Delete: bdb/perl.BerkeleyDB/BerkeleyDB.pod BitKeeper/deleted/.del-Hash.pm~10292a26c06a5c95: Delete: bdb/perl.BerkeleyDB/BerkeleyDB/Hash.pm BitKeeper/deleted/.del-BerkeleyDB.pod.P~79f76a1495eda203: Delete: bdb/perl.BerkeleyDB/BerkeleyDB.pod.P BitKeeper/deleted/.del-BerkeleyDB.xs~80c99afbd98e392c: Delete: bdb/perl.BerkeleyDB/BerkeleyDB.xs BitKeeper/deleted/.del-Changes~729c1891efa60de9: Delete: bdb/perl.BerkeleyDB/Changes BitKeeper/deleted/.del-MANIFEST~63a1e34aecf157a0: Delete: bdb/perl.BerkeleyDB/MANIFEST BitKeeper/deleted/.del-Makefile.PL~c68797707d8df87a: Delete: bdb/perl.BerkeleyDB/Makefile.PL BitKeeper/deleted/.del-README~5f2f579b1a241407: Delete: bdb/perl.BerkeleyDB/README BitKeeper/deleted/.del-Todo~dca3c66c193adda9: Delete: bdb/perl.BerkeleyDB/Todo BitKeeper/deleted/.del-config.in~ae81681e450e0999: Delete: bdb/perl.BerkeleyDB/config.in BitKeeper/deleted/.del-dbinfo~28ad67d83be4f68e: Delete: bdb/perl.BerkeleyDB/dbinfo BitKeeper/deleted/.del-mkconsts~543ab60669c7a04e: Delete: bdb/perl.BerkeleyDB/mkconsts BitKeeper/deleted/.del-mkpod~182c0ca54e439afb: Delete: bdb/perl.BerkeleyDB/mkpod BitKeeper/deleted/.del-5.004~e008cb5a48805543: Delete: bdb/perl.BerkeleyDB/patches/5.004 BitKeeper/deleted/.del-irix_6_5.pl~61662bb08afcdec8: Delete: bdb/perl.BerkeleyDB/hints/irix_6_5.pl BitKeeper/deleted/.del-solaris.pl~6771e7182394e152: Delete: bdb/perl.BerkeleyDB/hints/solaris.pl BitKeeper/deleted/.del-typemap~783b8f5295b05f3d: Delete: bdb/perl.BerkeleyDB/typemap BitKeeper/deleted/.del-5.004_01~6081ce2fff7b0bc: Delete: bdb/perl.BerkeleyDB/patches/5.004_01 BitKeeper/deleted/.del-5.004_02~87214eac35ad9e6: Delete: bdb/perl.BerkeleyDB/patches/5.004_02 BitKeeper/deleted/.del-5.004_03~9a672becec7cb40f: Delete: bdb/perl.BerkeleyDB/patches/5.004_03 BitKeeper/deleted/.del-5.004_04~e326cb51af09d154: Delete: bdb/perl.BerkeleyDB/patches/5.004_04 BitKeeper/deleted/.del-5.004_05~7ab457a1e41a92fe: Delete: bdb/perl.BerkeleyDB/patches/5.004_05 BitKeeper/deleted/.del-5.005~f9e2d59b5964cd4b: Delete: bdb/perl.BerkeleyDB/patches/5.005 BitKeeper/deleted/.del-5.005_01~3eb9fb7b5842ea8e: Delete: bdb/perl.BerkeleyDB/patches/5.005_01 BitKeeper/deleted/.del-5.005_02~67477ce0bef717cb: Delete: bdb/perl.BerkeleyDB/patches/5.005_02 BitKeeper/deleted/.del-5.005_03~c4c29a1fb21e290a: Delete: bdb/perl.BerkeleyDB/patches/5.005_03 BitKeeper/deleted/.del-5.6.0~e1fb9897d124ee22: Delete: bdb/perl.BerkeleyDB/patches/5.6.0 BitKeeper/deleted/.del-btree.t~e4a1a3c675ddc406: Delete: bdb/perl.BerkeleyDB/t/btree.t BitKeeper/deleted/.del-db-3.0.t~d2c60991d84558f2: Delete: bdb/perl.BerkeleyDB/t/db-3.0.t BitKeeper/deleted/.del-db-3.1.t~6ee88cd13f55e018: Delete: bdb/perl.BerkeleyDB/t/db-3.1.t BitKeeper/deleted/.del-db-3.2.t~f73b6461f98fd1cf: Delete: bdb/perl.BerkeleyDB/t/db-3.2.t BitKeeper/deleted/.del-destroy.t~cc6a2ae1980a2ecd: Delete: bdb/perl.BerkeleyDB/t/destroy.t BitKeeper/deleted/.del-env.t~a8604a4499c4bd07: Delete: bdb/perl.BerkeleyDB/t/env.t BitKeeper/deleted/.del-examples.t~2571b77c3cc75574: Delete: bdb/perl.BerkeleyDB/t/examples.t BitKeeper/deleted/.del-examples.t.T~8228bdd75ac78b88: Delete: bdb/perl.BerkeleyDB/t/examples.t.T BitKeeper/deleted/.del-examples3.t.T~66a186897a87026d: Delete: bdb/perl.BerkeleyDB/t/examples3.t.T BitKeeper/deleted/.del-examples3.t~fe3822ba2f2d7f83: Delete: bdb/perl.BerkeleyDB/t/examples3.t BitKeeper/deleted/.del-filter.t~f87b045c1b708637: Delete: bdb/perl.BerkeleyDB/t/filter.t BitKeeper/deleted/.del-hash.t~616bfb4d644de3a3: Delete: bdb/perl.BerkeleyDB/t/hash.t BitKeeper/deleted/.del-join.t~29fc39f74a83ca22: Delete: bdb/perl.BerkeleyDB/t/join.t BitKeeper/deleted/.del-mldbm.t~31f5015341eea040: Delete: bdb/perl.BerkeleyDB/t/mldbm.t BitKeeper/deleted/.del-queue.t~8f338034ce44a641: Delete: bdb/perl.BerkeleyDB/t/queue.t BitKeeper/deleted/.del-recno.t~d4ddbd3743add63e: Delete: bdb/perl.BerkeleyDB/t/recno.t BitKeeper/deleted/.del-strict.t~6885cdd2ea71ca2d: Delete: bdb/perl.BerkeleyDB/t/strict.t BitKeeper/deleted/.del-subdb.t~aab62a5d5864c603: Delete: bdb/perl.BerkeleyDB/t/subdb.t BitKeeper/deleted/.del-txn.t~65033b8558ae1216: Delete: bdb/perl.BerkeleyDB/t/txn.t BitKeeper/deleted/.del-unknown.t~f3710458682665e1: Delete: bdb/perl.BerkeleyDB/t/unknown.t BitKeeper/deleted/.del-Changes~436f74a5c414c65b: Delete: bdb/perl.DB_File/Changes BitKeeper/deleted/.del-DB_File.pm~ae0951c6c7665a82: Delete: bdb/perl.DB_File/DB_File.pm BitKeeper/deleted/.del-DB_File.xs~89e49a0b5556f1d8: Delete: bdb/perl.DB_File/DB_File.xs BitKeeper/deleted/.del-DB_File_BS~290fad5dbbb87069: Delete: bdb/perl.DB_File/DB_File_BS BitKeeper/deleted/.del-MANIFEST~90ee581572bdd4ac: Delete: bdb/perl.DB_File/MANIFEST BitKeeper/deleted/.del-Makefile.PL~ac0567bb5a377e38: Delete: bdb/perl.DB_File/Makefile.PL BitKeeper/deleted/.del-README~77e924a5a9bae6b3: Delete: bdb/perl.DB_File/README BitKeeper/deleted/.del-config.in~ab4c2792b86a810b: Delete: bdb/perl.DB_File/config.in BitKeeper/deleted/.del-dbinfo~461c43b30fab2cb: Delete: bdb/perl.DB_File/dbinfo BitKeeper/deleted/.del-dynixptx.pl~50dcddfae25d17e9: Delete: bdb/perl.DB_File/hints/dynixptx.pl BitKeeper/deleted/.del-typemap~55cffb3288a9e587: Delete: bdb/perl.DB_File/typemap BitKeeper/deleted/.del-version.c~a4df0e646f8b3975: Delete: bdb/perl.DB_File/version.c BitKeeper/deleted/.del-5.004_01~d6830d0082702af7: Delete: bdb/perl.DB_File/patches/5.004_01 BitKeeper/deleted/.del-5.004_02~78b082dc80c91031: Delete: bdb/perl.DB_File/patches/5.004_02 BitKeeper/deleted/.del-5.004~4411ec2e3c9e008b: Delete: bdb/perl.DB_File/patches/5.004 BitKeeper/deleted/.del-sco.pl~1e795fe14fe4dcfe: Delete: bdb/perl.DB_File/hints/sco.pl BitKeeper/deleted/.del-5.004_03~33f274648b160d95: Delete: bdb/perl.DB_File/patches/5.004_03 BitKeeper/deleted/.del-5.004_04~8f3d1b3cf18bb20a: Delete: bdb/perl.DB_File/patches/5.004_04 BitKeeper/deleted/.del-5.004_05~9c0f02e7331e142: Delete: bdb/perl.DB_File/patches/5.004_05 BitKeeper/deleted/.del-5.005~c2108cb2e3c8d951: Delete: bdb/perl.DB_File/patches/5.005 BitKeeper/deleted/.del-5.005_01~3b45e9673afc4cfa: Delete: bdb/perl.DB_File/patches/5.005_01 BitKeeper/deleted/.del-5.005_02~9fe5766bb02a4522: Delete: bdb/perl.DB_File/patches/5.005_02 BitKeeper/deleted/.del-5.005_03~ffa1c38c19ae72ea: Delete: bdb/perl.DB_File/patches/5.005_03 BitKeeper/deleted/.del-5.6.0~373be3a5ce47be85: Delete: bdb/perl.DB_File/patches/5.6.0 BitKeeper/deleted/.del-db-btree.t~3231595a1c241eb3: Delete: bdb/perl.DB_File/t/db-btree.t BitKeeper/deleted/.del-db-hash.t~7c4ad0c795c7fad2: Delete: bdb/perl.DB_File/t/db-hash.t BitKeeper/deleted/.del-db-recno.t~6c2d3d80b9ba4a50: Delete: bdb/perl.DB_File/t/db-recno.t BitKeeper/deleted/.del-db_server.sed~cdb00ebcd48a64e2: Delete: bdb/rpc_server/db_server.sed BitKeeper/deleted/.del-db_server_proc.c~d46c8f409c3747f4: Delete: bdb/rpc_server/db_server_proc.c BitKeeper/deleted/.del-db_server_svc.sed~3f5e59f334fa4607: Delete: bdb/rpc_server/db_server_svc.sed BitKeeper/deleted/.del-db_server_util.c~a809f3a4629acda: Delete: bdb/rpc_server/db_server_util.c BitKeeper/deleted/.del-log.tcl~ff1b41f1355b97d7: Delete: bdb/test/log.tcl BitKeeper/deleted/.del-mpool.tcl~b0df4dc1b04db26c: Delete: bdb/test/mpool.tcl BitKeeper/deleted/.del-mutex.tcl~52fd5c73a150565: Delete: bdb/test/mutex.tcl BitKeeper/deleted/.del-txn.tcl~c4ff071550b5446e: Delete: bdb/test/txn.tcl BitKeeper/deleted/.del-README~e800a12a5392010a: Delete: bdb/test/upgrade/README BitKeeper/deleted/.del-pack-2.6.6.pl~89d5076d758d3e98: Delete: bdb/test/upgrade/generate-2.X/pack-2.6.6.pl BitKeeper/deleted/.del-test-2.6.patch~4a52dc83d447547b: Delete: bdb/test/upgrade/generate-2.X/test-2.6.patch
1294 lines
30 KiB
C
1294 lines
30 KiB
C
/*-
|
|
* See the file LICENSE for redistribution information.
|
|
*
|
|
* Copyright (c) 1996-2002
|
|
* Sleepycat Software. All rights reserved.
|
|
*/
|
|
|
|
#include "db_config.h"
|
|
|
|
#ifndef lint
|
|
static const char revid[] = "$Id: db_pr.c,v 11.84 2002/09/10 02:45:20 bostic Exp $";
|
|
#endif /* not lint */
|
|
|
|
#ifndef NO_SYSTEM_INCLUDES
|
|
#include <sys/types.h>
|
|
|
|
#include <ctype.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
#include "db_int.h"
|
|
#include "dbinc/db_page.h"
|
|
#include "dbinc/db_shash.h"
|
|
#include "dbinc/btree.h"
|
|
#include "dbinc/hash.h"
|
|
#include "dbinc/mp.h"
|
|
#include "dbinc/qam.h"
|
|
#include "dbinc/db_verify.h"
|
|
|
|
static int __db_bmeta __P((DB *, FILE *, BTMETA *, u_int32_t));
|
|
static int __db_hmeta __P((DB *, FILE *, HMETA *, u_int32_t));
|
|
static void __db_meta __P((DB *, DBMETA *, FILE *, FN const *, u_int32_t));
|
|
static const char *__db_pagetype_to_string __P((u_int32_t));
|
|
static void __db_prdb __P((DB *, FILE *));
|
|
static void __db_proff __P((void *, FILE *));
|
|
static int __db_prtree __P((DB *, FILE *, u_int32_t));
|
|
static int __db_qmeta __P((DB *, FILE *, QMETA *, u_int32_t));
|
|
|
|
/*
|
|
* __db_loadme --
|
|
* A nice place to put a breakpoint.
|
|
*
|
|
* PUBLIC: void __db_loadme __P((void));
|
|
*/
|
|
void
|
|
__db_loadme()
|
|
{
|
|
u_int32_t id;
|
|
|
|
__os_id(&id);
|
|
}
|
|
|
|
/*
|
|
* __db_dump --
|
|
* Dump the tree to a file.
|
|
*
|
|
* PUBLIC: int __db_dump __P((DB *, char *, char *));
|
|
*/
|
|
int
|
|
__db_dump(dbp, op, name)
|
|
DB *dbp;
|
|
char *op, *name;
|
|
{
|
|
FILE *fp;
|
|
u_int32_t flags;
|
|
int ret;
|
|
|
|
for (flags = 0; *op != '\0'; ++op)
|
|
switch (*op) {
|
|
case 'a':
|
|
LF_SET(DB_PR_PAGE);
|
|
break;
|
|
case 'h':
|
|
break;
|
|
case 'r':
|
|
LF_SET(DB_PR_RECOVERYTEST);
|
|
break;
|
|
default:
|
|
return (EINVAL);
|
|
}
|
|
|
|
if (name == NULL)
|
|
fp = stdout;
|
|
else {
|
|
if ((fp = fopen(name, "w")) == NULL)
|
|
return (__os_get_errno());
|
|
}
|
|
|
|
__db_prdb(dbp, fp);
|
|
|
|
fprintf(fp, "%s\n", DB_LINE);
|
|
|
|
ret = __db_prtree(dbp, fp, flags);
|
|
|
|
fflush(fp);
|
|
if (name != NULL)
|
|
fclose(fp);
|
|
|
|
return (ret);
|
|
}
|
|
|
|
/*
|
|
* __db_inmemdbflags --
|
|
* Call a callback for printing or other handling of strings associated
|
|
* with whatever in-memory DB structure flags are set.
|
|
*
|
|
* PUBLIC: void __db_inmemdbflags __P((u_int32_t, void *,
|
|
* PUBLIC: void (*)(u_int32_t, const FN *, void *)));
|
|
*/
|
|
void
|
|
__db_inmemdbflags(flags, cookie, callback)
|
|
u_int32_t flags;
|
|
void *cookie;
|
|
void (*callback) __P((u_int32_t, const FN *, void *));
|
|
{
|
|
static const FN fn[] = {
|
|
{ DB_AM_CHKSUM, "checksumming" },
|
|
{ DB_AM_CL_WRITER, "client replica writer" },
|
|
{ DB_AM_COMPENSATE, "created by compensating transaction" },
|
|
{ DB_AM_CREATED, "database created" },
|
|
{ DB_AM_CREATED_MSTR, "encompassing file created" },
|
|
{ DB_AM_DBM_ERROR, "dbm/ndbm error" },
|
|
{ DB_AM_DELIMITER, "variable length" },
|
|
{ DB_AM_DIRTY, "dirty reads" },
|
|
{ DB_AM_DISCARD, "discard cached pages" },
|
|
{ DB_AM_DUP, "duplicates" },
|
|
{ DB_AM_DUPSORT, "sorted duplicates" },
|
|
{ DB_AM_ENCRYPT, "encrypted" },
|
|
{ DB_AM_FIXEDLEN, "fixed-length records" },
|
|
{ DB_AM_INMEM, "in-memory" },
|
|
{ DB_AM_IN_RENAME, "file is being renamed" },
|
|
{ DB_AM_OPEN_CALLED, "DB->open called" },
|
|
{ DB_AM_PAD, "pad value" },
|
|
{ DB_AM_PGDEF, "default page size" },
|
|
{ DB_AM_RDONLY, "read-only" },
|
|
{ DB_AM_RECNUM, "Btree record numbers" },
|
|
{ DB_AM_RECOVER, "opened for recovery" },
|
|
{ DB_AM_RENUMBER, "renumber" },
|
|
{ DB_AM_REVSPLITOFF, "no reverse splits" },
|
|
{ DB_AM_SECONDARY, "secondary" },
|
|
{ DB_AM_SNAPSHOT, "load on open" },
|
|
{ DB_AM_SUBDB, "subdatabases" },
|
|
{ DB_AM_SWAP, "needswap" },
|
|
{ DB_AM_TXN, "transactional" },
|
|
{ DB_AM_VERIFYING, "verifier" },
|
|
{ 0, NULL }
|
|
};
|
|
|
|
callback(flags, fn, cookie);
|
|
}
|
|
|
|
/*
|
|
* __db_prdb --
|
|
* Print out the DB structure information.
|
|
*/
|
|
static void
|
|
__db_prdb(dbp, fp)
|
|
DB *dbp;
|
|
FILE *fp;
|
|
{
|
|
BTREE *bt;
|
|
HASH *h;
|
|
QUEUE *q;
|
|
|
|
fprintf(fp,
|
|
"In-memory DB structure:\n%s: %#lx",
|
|
__db_dbtype_to_string(dbp->type), (u_long)dbp->flags);
|
|
__db_inmemdbflags(dbp->flags, fp, __db_prflags);
|
|
fprintf(fp, "\n");
|
|
|
|
switch (dbp->type) {
|
|
case DB_BTREE:
|
|
case DB_RECNO:
|
|
bt = dbp->bt_internal;
|
|
fprintf(fp, "bt_meta: %lu bt_root: %lu\n",
|
|
(u_long)bt->bt_meta, (u_long)bt->bt_root);
|
|
fprintf(fp, "bt_maxkey: %lu bt_minkey: %lu\n",
|
|
(u_long)bt->bt_maxkey, (u_long)bt->bt_minkey);
|
|
fprintf(fp, "bt_compare: %#lx bt_prefix: %#lx\n",
|
|
P_TO_ULONG(bt->bt_compare), P_TO_ULONG(bt->bt_prefix));
|
|
fprintf(fp, "bt_lpgno: %lu\n", (u_long)bt->bt_lpgno);
|
|
if (dbp->type == DB_RECNO) {
|
|
fprintf(fp,
|
|
"re_pad: %#lx re_delim: %#lx re_len: %lu re_source: %s\n",
|
|
(u_long)bt->re_pad, (u_long)bt->re_delim,
|
|
(u_long)bt->re_len,
|
|
bt->re_source == NULL ? "" : bt->re_source);
|
|
fprintf(fp, "re_modified: %d re_eof: %d re_last: %lu\n",
|
|
bt->re_modified, bt->re_eof, (u_long)bt->re_last);
|
|
}
|
|
break;
|
|
case DB_HASH:
|
|
h = dbp->h_internal;
|
|
fprintf(fp, "meta_pgno: %lu\n", (u_long)h->meta_pgno);
|
|
fprintf(fp, "h_ffactor: %lu\n", (u_long)h->h_ffactor);
|
|
fprintf(fp, "h_nelem: %lu\n", (u_long)h->h_nelem);
|
|
fprintf(fp, "h_hash: %#lx\n", P_TO_ULONG(h->h_hash));
|
|
break;
|
|
case DB_QUEUE:
|
|
q = dbp->q_internal;
|
|
fprintf(fp, "q_meta: %lu\n", (u_long)q->q_meta);
|
|
fprintf(fp, "q_root: %lu\n", (u_long)q->q_root);
|
|
fprintf(fp, "re_pad: %#lx re_len: %lu\n",
|
|
(u_long)q->re_pad, (u_long)q->re_len);
|
|
fprintf(fp, "rec_page: %lu\n", (u_long)q->rec_page);
|
|
fprintf(fp, "page_ext: %lu\n", (u_long)q->page_ext);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* __db_prtree --
|
|
* Print out the entire tree.
|
|
*/
|
|
static int
|
|
__db_prtree(dbp, fp, flags)
|
|
DB *dbp;
|
|
FILE *fp;
|
|
u_int32_t flags;
|
|
{
|
|
DB_MPOOLFILE *mpf;
|
|
PAGE *h;
|
|
db_pgno_t i, last;
|
|
int ret;
|
|
|
|
mpf = dbp->mpf;
|
|
|
|
if (dbp->type == DB_QUEUE)
|
|
return (__db_prqueue(dbp, fp, flags));
|
|
|
|
/*
|
|
* Find out the page number of the last page in the database, then
|
|
* dump each page.
|
|
*/
|
|
mpf->last_pgno(mpf, &last);
|
|
for (i = 0; i <= last; ++i) {
|
|
if ((ret = mpf->get(mpf, &i, 0, &h)) != 0)
|
|
return (ret);
|
|
(void)__db_prpage(dbp, h, fp, flags);
|
|
if ((ret = mpf->put(mpf, h, 0)) != 0)
|
|
return (ret);
|
|
}
|
|
|
|
return (0);
|
|
}
|
|
|
|
/*
|
|
* __db_meta --
|
|
* Print out common metadata information.
|
|
*/
|
|
static void
|
|
__db_meta(dbp, dbmeta, fp, fn, flags)
|
|
DB *dbp;
|
|
DBMETA *dbmeta;
|
|
FILE *fp;
|
|
FN const *fn;
|
|
u_int32_t flags;
|
|
{
|
|
DB_MPOOLFILE *mpf;
|
|
PAGE *h;
|
|
db_pgno_t pgno;
|
|
u_int8_t *p;
|
|
int cnt, ret;
|
|
const char *sep;
|
|
|
|
mpf = dbp->mpf;
|
|
|
|
fprintf(fp, "\tmagic: %#lx\n", (u_long)dbmeta->magic);
|
|
fprintf(fp, "\tversion: %lu\n", (u_long)dbmeta->version);
|
|
fprintf(fp, "\tpagesize: %lu\n", (u_long)dbmeta->pagesize);
|
|
fprintf(fp, "\ttype: %lu\n", (u_long)dbmeta->type);
|
|
fprintf(fp, "\tkeys: %lu\trecords: %lu\n",
|
|
(u_long)dbmeta->key_count, (u_long)dbmeta->record_count);
|
|
|
|
if (!LF_ISSET(DB_PR_RECOVERYTEST)) {
|
|
/*
|
|
* If we're doing recovery testing, don't display the free
|
|
* list, it may have changed and that makes the dump diff
|
|
* not work.
|
|
*/
|
|
fprintf(fp, "\tfree list: %lu", (u_long)dbmeta->free);
|
|
for (pgno = dbmeta->free,
|
|
cnt = 0, sep = ", "; pgno != PGNO_INVALID;) {
|
|
if ((ret = mpf->get(mpf, &pgno, 0, &h)) != 0) {
|
|
fprintf(fp,
|
|
"Unable to retrieve free-list page: %lu: %s\n",
|
|
(u_long)pgno, db_strerror(ret));
|
|
break;
|
|
}
|
|
pgno = h->next_pgno;
|
|
(void)mpf->put(mpf, h, 0);
|
|
fprintf(fp, "%s%lu", sep, (u_long)pgno);
|
|
if (++cnt % 10 == 0) {
|
|
fprintf(fp, "\n");
|
|
cnt = 0;
|
|
sep = "\t";
|
|
} else
|
|
sep = ", ";
|
|
}
|
|
fprintf(fp, "\n");
|
|
fprintf(fp, "\tlast_pgno: %lu\n", (u_long)dbmeta->last_pgno);
|
|
}
|
|
|
|
if (fn != NULL) {
|
|
fprintf(fp, "\tflags: %#lx", (u_long)dbmeta->flags);
|
|
__db_prflags(dbmeta->flags, fn, fp);
|
|
fprintf(fp, "\n");
|
|
}
|
|
|
|
fprintf(fp, "\tuid: ");
|
|
for (p = (u_int8_t *)dbmeta->uid,
|
|
cnt = 0; cnt < DB_FILE_ID_LEN; ++cnt) {
|
|
fprintf(fp, "%x", *p++);
|
|
if (cnt < DB_FILE_ID_LEN - 1)
|
|
fprintf(fp, " ");
|
|
}
|
|
fprintf(fp, "\n");
|
|
}
|
|
|
|
/*
|
|
* __db_bmeta --
|
|
* Print out the btree meta-data page.
|
|
*/
|
|
static int
|
|
__db_bmeta(dbp, fp, h, flags)
|
|
DB *dbp;
|
|
FILE *fp;
|
|
BTMETA *h;
|
|
u_int32_t flags;
|
|
{
|
|
static const FN mfn[] = {
|
|
{ BTM_DUP, "duplicates" },
|
|
{ BTM_RECNO, "recno" },
|
|
{ BTM_RECNUM, "btree:recnum" },
|
|
{ BTM_FIXEDLEN, "recno:fixed-length" },
|
|
{ BTM_RENUMBER, "recno:renumber" },
|
|
{ BTM_SUBDB, "multiple-databases" },
|
|
{ 0, NULL }
|
|
};
|
|
|
|
__db_meta(dbp, (DBMETA *)h, fp, mfn, flags);
|
|
|
|
fprintf(fp, "\tmaxkey: %lu minkey: %lu\n",
|
|
(u_long)h->maxkey, (u_long)h->minkey);
|
|
if (dbp->type == DB_RECNO)
|
|
fprintf(fp, "\tre_len: %#lx re_pad: %lu\n",
|
|
(u_long)h->re_len, (u_long)h->re_pad);
|
|
fprintf(fp, "\troot: %lu\n", (u_long)h->root);
|
|
|
|
return (0);
|
|
}
|
|
|
|
/*
|
|
* __db_hmeta --
|
|
* Print out the hash meta-data page.
|
|
*/
|
|
static int
|
|
__db_hmeta(dbp, fp, h, flags)
|
|
DB *dbp;
|
|
FILE *fp;
|
|
HMETA *h;
|
|
u_int32_t flags;
|
|
{
|
|
static const FN mfn[] = {
|
|
{ DB_HASH_DUP, "duplicates" },
|
|
{ DB_HASH_SUBDB, "multiple-databases" },
|
|
{ 0, NULL }
|
|
};
|
|
int i;
|
|
|
|
__db_meta(dbp, (DBMETA *)h, fp, mfn, flags);
|
|
|
|
fprintf(fp, "\tmax_bucket: %lu\n", (u_long)h->max_bucket);
|
|
fprintf(fp, "\thigh_mask: %#lx\n", (u_long)h->high_mask);
|
|
fprintf(fp, "\tlow_mask: %#lx\n", (u_long)h->low_mask);
|
|
fprintf(fp, "\tffactor: %lu\n", (u_long)h->ffactor);
|
|
fprintf(fp, "\tnelem: %lu\n", (u_long)h->nelem);
|
|
fprintf(fp, "\th_charkey: %#lx\n", (u_long)h->h_charkey);
|
|
fprintf(fp, "\tspare points: ");
|
|
for (i = 0; i < NCACHED; i++)
|
|
fprintf(fp, "%lu ", (u_long)h->spares[i]);
|
|
fprintf(fp, "\n");
|
|
|
|
return (0);
|
|
}
|
|
|
|
/*
|
|
* __db_qmeta --
|
|
* Print out the queue meta-data page.
|
|
*/
|
|
static int
|
|
__db_qmeta(dbp, fp, h, flags)
|
|
DB *dbp;
|
|
FILE *fp;
|
|
QMETA *h;
|
|
u_int32_t flags;
|
|
{
|
|
__db_meta(dbp, (DBMETA *)h, fp, NULL, flags);
|
|
|
|
fprintf(fp, "\tfirst_recno: %lu\n", (u_long)h->first_recno);
|
|
fprintf(fp, "\tcur_recno: %lu\n", (u_long)h->cur_recno);
|
|
fprintf(fp, "\tre_len: %#lx re_pad: %lu\n",
|
|
(u_long)h->re_len, (u_long)h->re_pad);
|
|
fprintf(fp, "\trec_page: %lu\n", (u_long)h->rec_page);
|
|
fprintf(fp, "\tpage_ext: %lu\n", (u_long)h->page_ext);
|
|
|
|
return (0);
|
|
}
|
|
|
|
/*
|
|
* __db_prnpage
|
|
* -- Print out a specific page.
|
|
*
|
|
* PUBLIC: int __db_prnpage __P((DB *, db_pgno_t, FILE *));
|
|
*/
|
|
int
|
|
__db_prnpage(dbp, pgno, fp)
|
|
DB *dbp;
|
|
db_pgno_t pgno;
|
|
FILE *fp;
|
|
{
|
|
DB_MPOOLFILE *mpf;
|
|
PAGE *h;
|
|
int ret, t_ret;
|
|
|
|
mpf = dbp->mpf;
|
|
|
|
if ((ret = mpf->get(mpf, &pgno, 0, &h)) != 0)
|
|
return (ret);
|
|
|
|
ret = __db_prpage(dbp, h, fp, DB_PR_PAGE);
|
|
|
|
if ((t_ret = mpf->put(mpf, h, 0)) != 0 && ret == 0)
|
|
ret = t_ret;
|
|
|
|
return (ret);
|
|
}
|
|
|
|
/*
|
|
* __db_prpage
|
|
* -- Print out a page.
|
|
*
|
|
* PUBLIC: int __db_prpage __P((DB *, PAGE *, FILE *, u_int32_t));
|
|
*/
|
|
int
|
|
__db_prpage(dbp, h, fp, flags)
|
|
DB *dbp;
|
|
PAGE *h;
|
|
FILE *fp;
|
|
u_int32_t flags;
|
|
{
|
|
BINTERNAL *bi;
|
|
BKEYDATA *bk;
|
|
HOFFPAGE a_hkd;
|
|
QAMDATA *qp, *qep;
|
|
RINTERNAL *ri;
|
|
db_indx_t dlen, len, i, *inp;
|
|
db_pgno_t pgno;
|
|
db_recno_t recno;
|
|
u_int32_t pagesize, qlen;
|
|
u_int8_t *ep, *hk, *p;
|
|
int deleted, ret;
|
|
const char *s;
|
|
void *sp;
|
|
|
|
/*
|
|
* If we're doing recovery testing and this page is P_INVALID,
|
|
* assume it's a page that's on the free list, and don't display it.
|
|
*/
|
|
if (LF_ISSET(DB_PR_RECOVERYTEST) && TYPE(h) == P_INVALID)
|
|
return (0);
|
|
|
|
s = __db_pagetype_to_string(TYPE(h));
|
|
if (s == NULL) {
|
|
fprintf(fp, "ILLEGAL PAGE TYPE: page: %lu type: %lu\n",
|
|
(u_long)h->pgno, (u_long)TYPE(h));
|
|
return (1);
|
|
}
|
|
|
|
/*
|
|
* !!!
|
|
* Find out the page size. We don't want to do it the "right" way,
|
|
* by reading the value from the meta-data page, that's going to be
|
|
* slow. Reach down into the mpool region.
|
|
*/
|
|
pagesize = (u_int32_t)dbp->mpf->mfp->stat.st_pagesize;
|
|
|
|
/* Page number, page type. */
|
|
fprintf(fp, "page %lu: %s level: %lu",
|
|
(u_long)h->pgno, s, (u_long)h->level);
|
|
|
|
/* Record count. */
|
|
if (TYPE(h) == P_IBTREE ||
|
|
TYPE(h) == P_IRECNO || (TYPE(h) == P_LRECNO &&
|
|
h->pgno == ((BTREE *)dbp->bt_internal)->bt_root))
|
|
fprintf(fp, " records: %lu", (u_long)RE_NREC(h));
|
|
|
|
/* LSN. */
|
|
if (!LF_ISSET(DB_PR_RECOVERYTEST))
|
|
fprintf(fp, " (lsn.file: %lu lsn.offset: %lu)\n",
|
|
(u_long)LSN(h).file, (u_long)LSN(h).offset);
|
|
|
|
switch (TYPE(h)) {
|
|
case P_BTREEMETA:
|
|
return (__db_bmeta(dbp, fp, (BTMETA *)h, flags));
|
|
case P_HASHMETA:
|
|
return (__db_hmeta(dbp, fp, (HMETA *)h, flags));
|
|
case P_QAMMETA:
|
|
return (__db_qmeta(dbp, fp, (QMETA *)h, flags));
|
|
case P_QAMDATA: /* Should be meta->start. */
|
|
if (!LF_ISSET(DB_PR_PAGE))
|
|
return (0);
|
|
|
|
qlen = ((QUEUE *)dbp->q_internal)->re_len;
|
|
recno = (h->pgno - 1) * QAM_RECNO_PER_PAGE(dbp) + 1;
|
|
i = 0;
|
|
qep = (QAMDATA *)((u_int8_t *)h + pagesize - qlen);
|
|
for (qp = QAM_GET_RECORD(dbp, h, i); qp < qep;
|
|
recno++, i++, qp = QAM_GET_RECORD(dbp, h, i)) {
|
|
if (!F_ISSET(qp, QAM_SET))
|
|
continue;
|
|
|
|
fprintf(fp, "%s",
|
|
F_ISSET(qp, QAM_VALID) ? "\t" : " D");
|
|
fprintf(fp, "[%03lu] %4lu ", (u_long)recno,
|
|
(u_long)((u_int8_t *)qp - (u_int8_t *)h));
|
|
__db_pr(qp->data, qlen, fp);
|
|
}
|
|
return (0);
|
|
}
|
|
|
|
/* LSN. */
|
|
if (LF_ISSET(DB_PR_RECOVERYTEST))
|
|
fprintf(fp, " (lsn.file: %lu lsn.offset: %lu)\n",
|
|
(u_long)LSN(h).file, (u_long)LSN(h).offset);
|
|
|
|
s = "\t";
|
|
if (TYPE(h) != P_IBTREE && TYPE(h) != P_IRECNO) {
|
|
fprintf(fp, "%sprev: %4lu next: %4lu",
|
|
s, (u_long)PREV_PGNO(h), (u_long)NEXT_PGNO(h));
|
|
s = " ";
|
|
}
|
|
if (TYPE(h) == P_OVERFLOW) {
|
|
fprintf(fp, "%sref cnt: %4lu ", s, (u_long)OV_REF(h));
|
|
__db_pr((u_int8_t *)h + P_OVERHEAD(dbp), OV_LEN(h), fp);
|
|
return (0);
|
|
}
|
|
fprintf(fp, "%sentries: %4lu", s, (u_long)NUM_ENT(h));
|
|
fprintf(fp, " offset: %4lu\n", (u_long)HOFFSET(h));
|
|
|
|
if (TYPE(h) == P_INVALID || !LF_ISSET(DB_PR_PAGE))
|
|
return (0);
|
|
|
|
ret = 0;
|
|
inp = P_INP(dbp, h);
|
|
for (i = 0; i < NUM_ENT(h); i++) {
|
|
if ((db_alignp_t)(P_ENTRY(dbp, h, i) - (u_int8_t *)h) <
|
|
(db_alignp_t)(P_OVERHEAD(dbp)) ||
|
|
(size_t)(P_ENTRY(dbp, h, i) - (u_int8_t *)h) >= pagesize) {
|
|
fprintf(fp,
|
|
"ILLEGAL PAGE OFFSET: indx: %lu of %lu\n",
|
|
(u_long)i, (u_long)inp[i]);
|
|
ret = EINVAL;
|
|
continue;
|
|
}
|
|
deleted = 0;
|
|
switch (TYPE(h)) {
|
|
case P_HASH:
|
|
case P_IBTREE:
|
|
case P_IRECNO:
|
|
sp = P_ENTRY(dbp, h, i);
|
|
break;
|
|
case P_LBTREE:
|
|
sp = P_ENTRY(dbp, h, i);
|
|
deleted = i % 2 == 0 &&
|
|
B_DISSET(GET_BKEYDATA(dbp, h, i + O_INDX)->type);
|
|
break;
|
|
case P_LDUP:
|
|
case P_LRECNO:
|
|
sp = P_ENTRY(dbp, h, i);
|
|
deleted = B_DISSET(GET_BKEYDATA(dbp, h, i)->type);
|
|
break;
|
|
default:
|
|
fprintf(fp,
|
|
"ILLEGAL PAGE ITEM: %lu\n", (u_long)TYPE(h));
|
|
ret = EINVAL;
|
|
continue;
|
|
}
|
|
fprintf(fp, "%s", deleted ? " D" : "\t");
|
|
fprintf(fp, "[%03lu] %4lu ", (u_long)i, (u_long)inp[i]);
|
|
switch (TYPE(h)) {
|
|
case P_HASH:
|
|
hk = sp;
|
|
switch (HPAGE_PTYPE(hk)) {
|
|
case H_OFFDUP:
|
|
memcpy(&pgno,
|
|
HOFFDUP_PGNO(hk), sizeof(db_pgno_t));
|
|
fprintf(fp,
|
|
"%4lu [offpage dups]\n", (u_long)pgno);
|
|
break;
|
|
case H_DUPLICATE:
|
|
/*
|
|
* If this is the first item on a page, then
|
|
* we cannot figure out how long it is, so
|
|
* we only print the first one in the duplicate
|
|
* set.
|
|
*/
|
|
if (i != 0)
|
|
len = LEN_HKEYDATA(dbp, h, 0, i);
|
|
else
|
|
len = 1;
|
|
|
|
fprintf(fp, "Duplicates:\n");
|
|
for (p = HKEYDATA_DATA(hk),
|
|
ep = p + len; p < ep;) {
|
|
memcpy(&dlen, p, sizeof(db_indx_t));
|
|
p += sizeof(db_indx_t);
|
|
fprintf(fp, "\t\t");
|
|
__db_pr(p, dlen, fp);
|
|
p += sizeof(db_indx_t) + dlen;
|
|
}
|
|
break;
|
|
case H_KEYDATA:
|
|
__db_pr(HKEYDATA_DATA(hk),
|
|
LEN_HKEYDATA(dbp, h, i == 0 ?
|
|
pagesize : 0, i), fp);
|
|
break;
|
|
case H_OFFPAGE:
|
|
memcpy(&a_hkd, hk, HOFFPAGE_SIZE);
|
|
fprintf(fp,
|
|
"overflow: total len: %4lu page: %4lu\n",
|
|
(u_long)a_hkd.tlen, (u_long)a_hkd.pgno);
|
|
break;
|
|
}
|
|
break;
|
|
case P_IBTREE:
|
|
bi = sp;
|
|
fprintf(fp, "count: %4lu pgno: %4lu type: %4lu",
|
|
(u_long)bi->nrecs, (u_long)bi->pgno,
|
|
(u_long)bi->type);
|
|
switch (B_TYPE(bi->type)) {
|
|
case B_KEYDATA:
|
|
__db_pr(bi->data, bi->len, fp);
|
|
break;
|
|
case B_DUPLICATE:
|
|
case B_OVERFLOW:
|
|
__db_proff(bi->data, fp);
|
|
break;
|
|
default:
|
|
fprintf(fp, "ILLEGAL BINTERNAL TYPE: %lu\n",
|
|
(u_long)B_TYPE(bi->type));
|
|
ret = EINVAL;
|
|
break;
|
|
}
|
|
break;
|
|
case P_IRECNO:
|
|
ri = sp;
|
|
fprintf(fp, "entries %4lu pgno %4lu\n",
|
|
(u_long)ri->nrecs, (u_long)ri->pgno);
|
|
break;
|
|
case P_LBTREE:
|
|
case P_LDUP:
|
|
case P_LRECNO:
|
|
bk = sp;
|
|
switch (B_TYPE(bk->type)) {
|
|
case B_KEYDATA:
|
|
__db_pr(bk->data, bk->len, fp);
|
|
break;
|
|
case B_DUPLICATE:
|
|
case B_OVERFLOW:
|
|
__db_proff(bk, fp);
|
|
break;
|
|
default:
|
|
fprintf(fp,
|
|
"ILLEGAL DUPLICATE/LBTREE/LRECNO TYPE: %lu\n",
|
|
(u_long)B_TYPE(bk->type));
|
|
ret = EINVAL;
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
(void)fflush(fp);
|
|
return (ret);
|
|
}
|
|
|
|
/*
|
|
* __db_pr --
|
|
* Print out a data element.
|
|
*
|
|
* PUBLIC: void __db_pr __P((u_int8_t *, u_int32_t, FILE *));
|
|
*/
|
|
void
|
|
__db_pr(p, len, fp)
|
|
u_int8_t *p;
|
|
u_int32_t len;
|
|
FILE *fp;
|
|
{
|
|
u_int lastch;
|
|
int i;
|
|
|
|
fprintf(fp, "len: %3lu", (u_long)len);
|
|
lastch = '.';
|
|
if (len != 0) {
|
|
fprintf(fp, " data: ");
|
|
for (i = len <= 20 ? len : 20; i > 0; --i, ++p) {
|
|
lastch = *p;
|
|
if (isprint((int)*p) || *p == '\n')
|
|
fprintf(fp, "%c", *p);
|
|
else
|
|
fprintf(fp, "0x%.2x", (u_int)*p);
|
|
}
|
|
if (len > 20) {
|
|
fprintf(fp, "...");
|
|
lastch = '.';
|
|
}
|
|
}
|
|
if (lastch != '\n')
|
|
fprintf(fp, "\n");
|
|
}
|
|
|
|
/*
|
|
* __db_prdbt --
|
|
* Print out a DBT data element.
|
|
*
|
|
* PUBLIC: int __db_prdbt __P((DBT *, int, const char *, void *,
|
|
* PUBLIC: int (*)(void *, const void *), int, VRFY_DBINFO *));
|
|
*/
|
|
int
|
|
__db_prdbt(dbtp, checkprint, prefix, handle, callback, is_recno, vdp)
|
|
DBT *dbtp;
|
|
int checkprint;
|
|
const char *prefix;
|
|
void *handle;
|
|
int (*callback) __P((void *, const void *));
|
|
int is_recno;
|
|
VRFY_DBINFO *vdp;
|
|
{
|
|
static const char hex[] = "0123456789abcdef";
|
|
db_recno_t recno;
|
|
u_int32_t len;
|
|
int ret;
|
|
#define DBTBUFLEN 100
|
|
char *p, *hp, buf[DBTBUFLEN], hbuf[DBTBUFLEN];
|
|
|
|
if (vdp != NULL) {
|
|
/*
|
|
* If vdp is non-NULL, we might be the first key in the
|
|
* "fake" subdatabase used for key/data pairs we can't
|
|
* associate with a known subdb.
|
|
*
|
|
* Check and clear the SALVAGE_PRINTHEADER flag; if
|
|
* it was set, print a subdatabase header.
|
|
*/
|
|
if (F_ISSET(vdp, SALVAGE_PRINTHEADER))
|
|
(void)__db_prheader(NULL, "__OTHER__", 0, 0,
|
|
handle, callback, vdp, 0);
|
|
F_CLR(vdp, SALVAGE_PRINTHEADER);
|
|
F_SET(vdp, SALVAGE_PRINTFOOTER);
|
|
|
|
/*
|
|
* Even if the printable flag wasn't set by our immediate
|
|
* caller, it may be set on a salvage-wide basis.
|
|
*/
|
|
if (F_ISSET(vdp, SALVAGE_PRINTABLE))
|
|
checkprint = 1;
|
|
}
|
|
|
|
/*
|
|
* !!!
|
|
* This routine is the routine that dumps out items in the format
|
|
* used by db_dump(1) and db_load(1). This means that the format
|
|
* cannot change.
|
|
*/
|
|
if (prefix != NULL && (ret = callback(handle, prefix)) != 0)
|
|
return (ret);
|
|
if (is_recno) {
|
|
/*
|
|
* We're printing a record number, and this has to be done
|
|
* in a platform-independent way. So we use the numeral in
|
|
* straight ASCII.
|
|
*/
|
|
(void)__ua_memcpy(&recno, dbtp->data, sizeof(recno));
|
|
snprintf(buf, DBTBUFLEN, "%lu", (u_long)recno);
|
|
|
|
/* If we're printing data as hex, print keys as hex too. */
|
|
if (!checkprint) {
|
|
for (len = (u_int32_t)strlen(buf), p = buf, hp = hbuf;
|
|
len-- > 0; ++p) {
|
|
*hp++ = hex[(u_int8_t)(*p & 0xf0) >> 4];
|
|
*hp++ = hex[*p & 0x0f];
|
|
}
|
|
*hp = '\0';
|
|
ret = callback(handle, hbuf);
|
|
} else
|
|
ret = callback(handle, buf);
|
|
|
|
if (ret != 0)
|
|
return (ret);
|
|
} else if (checkprint) {
|
|
for (len = dbtp->size, p = dbtp->data; len--; ++p)
|
|
if (isprint((int)*p)) {
|
|
if (*p == '\\' &&
|
|
(ret = callback(handle, "\\")) != 0)
|
|
return (ret);
|
|
snprintf(buf, DBTBUFLEN, "%c", *p);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
return (ret);
|
|
} else {
|
|
snprintf(buf, DBTBUFLEN, "\\%c%c",
|
|
hex[(u_int8_t)(*p & 0xf0) >> 4],
|
|
hex[*p & 0x0f]);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
return (ret);
|
|
}
|
|
} else
|
|
for (len = dbtp->size, p = dbtp->data; len--; ++p) {
|
|
snprintf(buf, DBTBUFLEN, "%c%c",
|
|
hex[(u_int8_t)(*p & 0xf0) >> 4],
|
|
hex[*p & 0x0f]);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
return (ret);
|
|
}
|
|
|
|
return (callback(handle, "\n"));
|
|
}
|
|
|
|
/*
|
|
* __db_proff --
|
|
* Print out an off-page element.
|
|
*/
|
|
static void
|
|
__db_proff(vp, fp)
|
|
void *vp;
|
|
FILE *fp;
|
|
{
|
|
BOVERFLOW *bo;
|
|
|
|
bo = vp;
|
|
switch (B_TYPE(bo->type)) {
|
|
case B_OVERFLOW:
|
|
fprintf(fp, "overflow: total len: %4lu page: %4lu\n",
|
|
(u_long)bo->tlen, (u_long)bo->pgno);
|
|
break;
|
|
case B_DUPLICATE:
|
|
fprintf(fp, "duplicate: page: %4lu\n", (u_long)bo->pgno);
|
|
break;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* __db_prflags --
|
|
* Print out flags values.
|
|
*
|
|
* PUBLIC: void __db_prflags __P((u_int32_t, const FN *, void *));
|
|
*/
|
|
void
|
|
__db_prflags(flags, fn, vfp)
|
|
u_int32_t flags;
|
|
FN const *fn;
|
|
void *vfp;
|
|
{
|
|
FILE *fp;
|
|
const FN *fnp;
|
|
int found;
|
|
const char *sep;
|
|
|
|
/*
|
|
* We pass the FILE * through a void * so that we can use
|
|
* this function as as a callback.
|
|
*/
|
|
fp = (FILE *)vfp;
|
|
|
|
sep = " (";
|
|
for (found = 0, fnp = fn; fnp->mask != 0; ++fnp)
|
|
if (LF_ISSET(fnp->mask)) {
|
|
fprintf(fp, "%s%s", sep, fnp->name);
|
|
sep = ", ";
|
|
found = 1;
|
|
}
|
|
if (found)
|
|
fprintf(fp, ")");
|
|
}
|
|
|
|
/*
|
|
* __db_dbtype_to_string --
|
|
* Return the name of the database type.
|
|
* PUBLIC: const char * __db_dbtype_to_string __P((DBTYPE));
|
|
*/
|
|
const char *
|
|
__db_dbtype_to_string(type)
|
|
DBTYPE type;
|
|
{
|
|
switch (type) {
|
|
case DB_BTREE:
|
|
return ("btree");
|
|
case DB_HASH:
|
|
return ("hash");
|
|
case DB_RECNO:
|
|
return ("recno");
|
|
case DB_QUEUE:
|
|
return ("queue");
|
|
default:
|
|
return ("UNKNOWN TYPE");
|
|
}
|
|
/* NOTREACHED */
|
|
}
|
|
|
|
/*
|
|
* __db_pagetype_to_string --
|
|
* Return the name of the specified page type.
|
|
*/
|
|
static const char *
|
|
__db_pagetype_to_string(type)
|
|
u_int32_t type;
|
|
{
|
|
char *s;
|
|
|
|
s = NULL;
|
|
switch (type) {
|
|
case P_BTREEMETA:
|
|
s = "btree metadata";
|
|
break;
|
|
case P_LDUP:
|
|
s = "duplicate";
|
|
break;
|
|
case P_HASH:
|
|
s = "hash";
|
|
break;
|
|
case P_HASHMETA:
|
|
s = "hash metadata";
|
|
break;
|
|
case P_IBTREE:
|
|
s = "btree internal";
|
|
break;
|
|
case P_INVALID:
|
|
s = "invalid";
|
|
break;
|
|
case P_IRECNO:
|
|
s = "recno internal";
|
|
break;
|
|
case P_LBTREE:
|
|
s = "btree leaf";
|
|
break;
|
|
case P_LRECNO:
|
|
s = "recno leaf";
|
|
break;
|
|
case P_OVERFLOW:
|
|
s = "overflow";
|
|
break;
|
|
case P_QAMMETA:
|
|
s = "queue metadata";
|
|
break;
|
|
case P_QAMDATA:
|
|
s = "queue";
|
|
break;
|
|
default:
|
|
/* Just return a NULL. */
|
|
break;
|
|
}
|
|
return (s);
|
|
}
|
|
|
|
/*
|
|
* __db_prheader --
|
|
* Write out header information in the format expected by db_load.
|
|
*
|
|
* PUBLIC: int __db_prheader __P((DB *, char *, int, int, void *,
|
|
* PUBLIC: int (*)(void *, const void *), VRFY_DBINFO *, db_pgno_t));
|
|
*/
|
|
int
|
|
__db_prheader(dbp, subname, pflag, keyflag, handle, callback, vdp, meta_pgno)
|
|
DB *dbp;
|
|
char *subname;
|
|
int pflag, keyflag;
|
|
void *handle;
|
|
int (*callback) __P((void *, const void *));
|
|
VRFY_DBINFO *vdp;
|
|
db_pgno_t meta_pgno;
|
|
{
|
|
DB_BTREE_STAT *btsp;
|
|
DB_ENV *dbenv;
|
|
DB_HASH_STAT *hsp;
|
|
DB_QUEUE_STAT *qsp;
|
|
DBT dbt;
|
|
VRFY_PAGEINFO *pip;
|
|
char *buf;
|
|
int buflen, ret, t_ret;
|
|
u_int32_t dbtype;
|
|
|
|
btsp = NULL;
|
|
hsp = NULL;
|
|
qsp = NULL;
|
|
ret = 0;
|
|
buf = NULL;
|
|
COMPQUIET(buflen, 0);
|
|
|
|
if (dbp == NULL)
|
|
dbenv = NULL;
|
|
else
|
|
dbenv = dbp->dbenv;
|
|
|
|
/*
|
|
* If we've been passed a verifier statistics object, use
|
|
* that; we're being called in a context where dbp->stat
|
|
* is unsafe.
|
|
*
|
|
* Also, the verifier may set the pflag on a per-salvage basis.
|
|
* If so, respect that.
|
|
*/
|
|
if (vdp != NULL) {
|
|
if ((ret = __db_vrfy_getpageinfo(vdp, meta_pgno, &pip)) != 0)
|
|
return (ret);
|
|
|
|
if (F_ISSET(vdp, SALVAGE_PRINTABLE))
|
|
pflag = 1;
|
|
} else
|
|
pip = NULL;
|
|
|
|
/*
|
|
* If dbp is NULL, we're being called from inside __db_prdbt,
|
|
* and this is a special subdatabase for "lost" items. Make it a btree.
|
|
* Otherwise, set dbtype to the appropriate type for the specified
|
|
* meta page, or the type of the dbp.
|
|
*/
|
|
if (dbp == NULL)
|
|
dbtype = DB_BTREE;
|
|
else if (pip != NULL)
|
|
switch (pip->type) {
|
|
case P_BTREEMETA:
|
|
if (F_ISSET(pip, VRFY_IS_RECNO))
|
|
dbtype = DB_RECNO;
|
|
else
|
|
dbtype = DB_BTREE;
|
|
break;
|
|
case P_HASHMETA:
|
|
dbtype = DB_HASH;
|
|
break;
|
|
default:
|
|
/*
|
|
* If the meta page is of a bogus type, it's
|
|
* because we have a badly corrupt database.
|
|
* (We must be in the verifier for pip to be non-NULL.)
|
|
* Pretend we're a Btree and salvage what we can.
|
|
*/
|
|
DB_ASSERT(F_ISSET(dbp, DB_AM_VERIFYING));
|
|
dbtype = DB_BTREE;
|
|
break;
|
|
}
|
|
else
|
|
dbtype = dbp->type;
|
|
|
|
if ((ret = callback(handle, "VERSION=3\n")) != 0)
|
|
goto err;
|
|
if (pflag) {
|
|
if ((ret = callback(handle, "format=print\n")) != 0)
|
|
goto err;
|
|
} else if ((ret = callback(handle, "format=bytevalue\n")) != 0)
|
|
goto err;
|
|
|
|
/*
|
|
* 64 bytes is long enough, as a minimum bound, for any of the
|
|
* fields besides subname. Subname uses __db_prdbt and therefore
|
|
* does not need buffer space here.
|
|
*/
|
|
buflen = 64;
|
|
if ((ret = __os_malloc(dbenv, buflen, &buf)) != 0)
|
|
goto err;
|
|
if (subname != NULL) {
|
|
snprintf(buf, buflen, "database=");
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
goto err;
|
|
memset(&dbt, 0, sizeof(dbt));
|
|
dbt.data = subname;
|
|
dbt.size = (u_int32_t)strlen(subname);
|
|
if ((ret = __db_prdbt(&dbt,
|
|
1, NULL, handle, callback, 0, NULL)) != 0)
|
|
goto err;
|
|
}
|
|
switch (dbtype) {
|
|
case DB_BTREE:
|
|
if ((ret = callback(handle, "type=btree\n")) != 0)
|
|
goto err;
|
|
if (pip != NULL) {
|
|
if (F_ISSET(pip, VRFY_HAS_RECNUMS))
|
|
if ((ret =
|
|
callback(handle, "recnum=1\n")) != 0)
|
|
goto err;
|
|
if (pip->bt_maxkey != 0) {
|
|
snprintf(buf, buflen,
|
|
"bt_maxkey=%lu\n", (u_long)pip->bt_maxkey);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
goto err;
|
|
}
|
|
if (pip->bt_minkey != 0 &&
|
|
pip->bt_minkey != DEFMINKEYPAGE) {
|
|
snprintf(buf, buflen,
|
|
"bt_minkey=%lu\n", (u_long)pip->bt_minkey);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
goto err;
|
|
}
|
|
break;
|
|
}
|
|
if ((ret = dbp->stat(dbp, &btsp, 0)) != 0) {
|
|
dbp->err(dbp, ret, "DB->stat");
|
|
goto err;
|
|
}
|
|
if (F_ISSET(dbp, DB_AM_RECNUM))
|
|
if ((ret = callback(handle, "recnum=1\n")) != 0)
|
|
goto err;
|
|
if (btsp->bt_maxkey != 0) {
|
|
snprintf(buf, buflen,
|
|
"bt_maxkey=%lu\n", (u_long)btsp->bt_maxkey);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
goto err;
|
|
}
|
|
if (btsp->bt_minkey != 0 && btsp->bt_minkey != DEFMINKEYPAGE) {
|
|
snprintf(buf, buflen,
|
|
"bt_minkey=%lu\n", (u_long)btsp->bt_minkey);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
goto err;
|
|
}
|
|
break;
|
|
case DB_HASH:
|
|
if ((ret = callback(handle, "type=hash\n")) != 0)
|
|
goto err;
|
|
if (pip != NULL) {
|
|
if (pip->h_ffactor != 0) {
|
|
snprintf(buf, buflen,
|
|
"h_ffactor=%lu\n", (u_long)pip->h_ffactor);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
goto err;
|
|
}
|
|
if (pip->h_nelem != 0) {
|
|
snprintf(buf, buflen,
|
|
"h_nelem=%lu\n", (u_long)pip->h_nelem);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
goto err;
|
|
}
|
|
break;
|
|
}
|
|
if ((ret = dbp->stat(dbp, &hsp, 0)) != 0) {
|
|
dbp->err(dbp, ret, "DB->stat");
|
|
goto err;
|
|
}
|
|
if (hsp->hash_ffactor != 0) {
|
|
snprintf(buf, buflen,
|
|
"h_ffactor=%lu\n", (u_long)hsp->hash_ffactor);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
goto err;
|
|
}
|
|
if (hsp->hash_nkeys != 0) {
|
|
snprintf(buf, buflen,
|
|
"h_nelem=%lu\n", (u_long)hsp->hash_nkeys);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
goto err;
|
|
}
|
|
break;
|
|
case DB_QUEUE:
|
|
if ((ret = callback(handle, "type=queue\n")) != 0)
|
|
goto err;
|
|
if (vdp != NULL) {
|
|
snprintf(buf,
|
|
buflen, "re_len=%lu\n", (u_long)vdp->re_len);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
goto err;
|
|
break;
|
|
}
|
|
if ((ret = dbp->stat(dbp, &qsp, 0)) != 0) {
|
|
dbp->err(dbp, ret, "DB->stat");
|
|
goto err;
|
|
}
|
|
snprintf(buf, buflen, "re_len=%lu\n", (u_long)qsp->qs_re_len);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
goto err;
|
|
if (qsp->qs_re_pad != 0 && qsp->qs_re_pad != ' ') {
|
|
snprintf(buf, buflen, "re_pad=%#x\n", qsp->qs_re_pad);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
goto err;
|
|
}
|
|
if (qsp->qs_extentsize != 0) {
|
|
snprintf(buf, buflen,
|
|
"extentsize=%lu\n", (u_long)qsp->qs_extentsize);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
goto err;
|
|
}
|
|
break;
|
|
case DB_RECNO:
|
|
if ((ret = callback(handle, "type=recno\n")) != 0)
|
|
goto err;
|
|
if (pip != NULL) {
|
|
if (F_ISSET(pip, VRFY_IS_RRECNO))
|
|
if ((ret =
|
|
callback(handle, "renumber=1\n")) != 0)
|
|
goto err;
|
|
if (pip->re_len > 0) {
|
|
snprintf(buf, buflen,
|
|
"re_len=%lu\n", (u_long)pip->re_len);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
goto err;
|
|
}
|
|
break;
|
|
}
|
|
if ((ret = dbp->stat(dbp, &btsp, 0)) != 0) {
|
|
dbp->err(dbp, ret, "DB->stat");
|
|
goto err;
|
|
}
|
|
if (F_ISSET(dbp, DB_AM_RENUMBER))
|
|
if ((ret = callback(handle, "renumber=1\n")) != 0)
|
|
goto err;
|
|
if (F_ISSET(dbp, DB_AM_FIXEDLEN)) {
|
|
snprintf(buf, buflen,
|
|
"re_len=%lu\n", (u_long)btsp->bt_re_len);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
goto err;
|
|
}
|
|
if (btsp->bt_re_pad != 0 && btsp->bt_re_pad != ' ') {
|
|
snprintf(buf, buflen, "re_pad=%#x\n", btsp->bt_re_pad);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
goto err;
|
|
}
|
|
break;
|
|
case DB_UNKNOWN:
|
|
DB_ASSERT(0); /* Impossible. */
|
|
__db_err(dbp->dbenv, "Impossible DB type in __db_prheader");
|
|
ret = EINVAL;
|
|
goto err;
|
|
}
|
|
|
|
if (pip != NULL) {
|
|
if (F_ISSET(pip, VRFY_HAS_DUPS))
|
|
if ((ret = callback(handle, "duplicates=1\n")) != 0)
|
|
goto err;
|
|
if (F_ISSET(pip, VRFY_HAS_DUPSORT))
|
|
if ((ret = callback(handle, "dupsort=1\n")) != 0)
|
|
goto err;
|
|
/* We should handle page size. XXX */
|
|
} else {
|
|
if (F_ISSET(dbp, DB_AM_CHKSUM))
|
|
if ((ret = callback(handle, "chksum=1\n")) != 0)
|
|
goto err;
|
|
if (F_ISSET(dbp, DB_AM_DUP))
|
|
if ((ret = callback(handle, "duplicates=1\n")) != 0)
|
|
goto err;
|
|
if (F_ISSET(dbp, DB_AM_DUPSORT))
|
|
if ((ret = callback(handle, "dupsort=1\n")) != 0)
|
|
goto err;
|
|
if (!F_ISSET(dbp, DB_AM_PGDEF)) {
|
|
snprintf(buf, buflen,
|
|
"db_pagesize=%lu\n", (u_long)dbp->pgsize);
|
|
if ((ret = callback(handle, buf)) != 0)
|
|
goto err;
|
|
}
|
|
}
|
|
|
|
if (keyflag && (ret = callback(handle, "keys=1\n")) != 0)
|
|
goto err;
|
|
|
|
ret = callback(handle, "HEADER=END\n");
|
|
|
|
err: if (pip != NULL &&
|
|
(t_ret = __db_vrfy_putpageinfo(dbenv, vdp, pip)) != 0 && ret == 0)
|
|
ret = t_ret;
|
|
if (btsp != NULL)
|
|
__os_ufree(dbenv, btsp);
|
|
if (hsp != NULL)
|
|
__os_ufree(dbenv, hsp);
|
|
if (qsp != NULL)
|
|
__os_ufree(dbenv, qsp);
|
|
if (buf != NULL)
|
|
__os_free(dbenv, buf);
|
|
|
|
return (ret);
|
|
}
|
|
|
|
/*
|
|
* __db_prfooter --
|
|
* Print the footer that marks the end of a DB dump. This is trivial,
|
|
* but for consistency's sake we don't want to put its literal contents
|
|
* in multiple places.
|
|
*
|
|
* PUBLIC: int __db_prfooter __P((void *, int (*)(void *, const void *)));
|
|
*/
|
|
int
|
|
__db_prfooter(handle, callback)
|
|
void *handle;
|
|
int (*callback) __P((void *, const void *));
|
|
{
|
|
return (callback(handle, "DATA=END\n"));
|
|
}
|