-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
-C Version\s3.7.1\srelease\scandidate
-D 2010-08-21T16:01:46
+C Update\sthe\s"showdb"\sdebug\sutility\sto\shandle\s64K\spage\sdatabase\sand\swith\nextra\soptions\sto\sdecode\sthe\sfreelist\sstructure.
+D 2010-08-23T15:26:50
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 543f91f24cd7fee774ecc0a61c19704c0c3e78fd
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F tool/shell3.test 4fad469e8003938426355afdf34155f08c587836
F tool/shell4.test 35f9c3d452b4e76d5013c63e1fd07478a62f14ce
F tool/shell5.test 62bfaf9267296da1b91e4b1c03e44e7b393f6a94
-F tool/showdb.c 01c20e8181941b714fe07f72c64a7560fee17ff9
+F tool/showdb.c c7a978cf525ef0f8bc2fd29cd52108dd1dfa605a
F tool/showjournal.c ec3b171be148656827c4949fbfb8ab4370822f87
F tool/showwal.c f09e5a80a293919290ec85a6a37c85a5ddcf37d9
F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 44de3cab9c89eb28485c0dc36d791b1c61d56b34
-R ba75d512677d6cf0802a70f734aafd6f
+P 3613b0695a5e990905ab146fadcab34dd04d5874
+R 058fa6e3ab648ae5ff66e22c57c21a88
U drh
-Z 9eb9cc7f3392e65cec0523ad38099f7c
+Z 4b496641e3aad55cb1970e3775c32e6e
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
-iD8DBQFMb/huoxKgR168RlERAp5nAJ9bQ/OZp/nGB/mbch5eawtJ3xzNqQCdH2LV
-awMpPL8qm3hJm5LCIu8Eivk=
-=ZYFd
+iD8DBQFMcpM9oxKgR168RlERAiQ4AKCNTq26d6guoArVL/8XVQDv9ujn6gCbB8sK
+0u6T4zf+ph77zjra1ytd08E=
+=CUDO
-----END PGP SIGNATURE-----
return 9;
}
+/*
+** Extract a big-endian 32-bit integer
+*/
+static unsigned int decodeInt32(const unsigned char *z){
+ return (z[0]<<24) + (z[1]<<16) + (z[2]<<8) + z[3];
+}
+
/* Report an out-of-memory error and die.
*/
static void out_of_memory(void){
}
}
+/*
+** Decode a freelist trunk page.
+*/
+static void decode_trunk_page(
+ int pgno, /* The page number */
+ int pagesize, /* Size of each page */
+ int detail, /* Show leaf pages if true */
+ int recursive /* Follow the trunk change if true */
+){
+ int n, i, k;
+ unsigned char *a;
+ while( pgno>0 ){
+ a = getContent((pgno-1)*pagesize, pagesize);
+ printf("Decode of freelist trunk page %d:\n", pgno);
+ print_decode_line(a, 0, 4, "Next freelist trunk page");
+ print_decode_line(a, 4, 4, "Number of entries on this page");
+ if( detail ){
+ n = (int)decodeInt32(&a[4]);
+ for(i=0; i<n; i++){
+ unsigned int x = decodeInt32(&a[8+4*i]);
+ char zIdx[10];
+ sprintf(zIdx, "[%d]", i);
+ printf(" %5s %7u", zIdx, x);
+ if( i%5==4 ) printf("\n");
+ }
+ if( i%5!=0 ) printf("\n");
+ }
+ if( !recursive ){
+ pgno = 0;
+ }else{
+ pgno = (int)decodeInt32(&a[0]);
+ }
+ free(a);
+ }
+}
+
+/*
+** Print a usage comment
+*/
+static void usage(const char *argv0){
+ fprintf(stderr, "Usage %s FILENAME ?args...?\n\n", argv0);
+ fprintf(stderr,
+ "args:\n"
+ " dbheader Show database header\n"
+ " NNN..MMM Show hex of pages NNN through MMM\n"
+ " NNN..end Show hex of pages NNN through end of file\n"
+ " NNNb Decode btree page NNN\n"
+ " NNNt Decode freelist trunk page NNN\n"
+ " NNNtd Show leave freelist pages on the decode\n"
+ " NNNtr Recurisvely decode freelist starting at NNN\n"
+ );
+}
+
int main(int argc, char **argv){
struct stat sbuf;
unsigned char zPgSz[2];
if( argc<2 ){
- fprintf(stderr,"Usage: %s FILENAME ?PAGE? ...\n", argv[0]);
+ usage(argv[0]);
exit(1);
}
db = open(argv[1], O_RDONLY);
zPgSz[1] = 0;
lseek(db, 16, SEEK_SET);
read(db, zPgSz, 2);
- pagesize = zPgSz[0]*256 + zPgSz[1];
+ pagesize = zPgSz[0]*256 + zPgSz[1]*65536;
if( pagesize==0 ) pagesize = 1024;
printf("Pagesize: %d\n", pagesize);
fstat(db, &sbuf);
decode_btree_page(a, iStart, hdrSize);
free(a);
continue;
+ }else if( zLeft && zLeft[0]=='t' ){
+ unsigned char *a;
+ int detail = 0;
+ int recursive = 0;
+ int i;
+ for(i=1; zLeft[i]; i++){
+ if( zLeft[i]=='r' ) recursive = 1;
+ if( zLeft[i]=='d' ) detail = 1;
+ }
+ decode_trunk_page(iStart, pagesize, detail, recursive);
+ continue;
}else{
iEnd = iStart;
}