-C Fix\sthe\sshowdb\sutility\sso\sthat\sit\sdisplays\sthe\scorrect\ssecondary\susage\sof\na\spage\swhen\sreporting\son\san\serror\sof\sa\spage\sbeing\sused\smore\sthan\sonce.
-D 2013-02-19T20:25:16.107
+C Enhance\sthe\sshowdb\stool\swith\soptions\sto\sshow\sPTRMAP\susage\sand\scontent.
+D 2013-02-19T22:26:51.195
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a
F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5
-F tool/showdb.c 2292b901840eb0e3390af9e8115d54dfee7613a0
+F tool/showdb.c 16960a5ce59d8b1d70dc3bdc51e2c0fe7bb91359
F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02
F tool/showwal.c 3f7f7da5ec0cba51b1449a75f700493377da57b5
F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
-P d14263a719101d9c70054f2fc37e7788f73aab28
-R c7d3b3e1fb8a10f0748991954af9d6f6
+P 4507f0b3d409cd14bb2b9c29c92c76aa3ccb22b6
+R b76888af58f22e925445fcabab8c63d9
U drh
-Z 8fc5bc0346e01701458f5c2865bfe0c3
+Z 14b66e62b1a3bf33a2d26df6fe5962d7
}
}
+/*
+** Determine pages used as PTRMAP pages
+*/
+static void page_usage_ptrmap(unsigned char *a){
+ if( a[55] ){
+ int usable = pagesize - a[20];
+ int pgno = 2;
+ int perPage = usable/5;
+ while( pgno<=mxPage ){
+ page_usage_msg(pgno, "PTRMAP page covering %d..%d",
+ pgno+1, pgno+perPage);
+ pgno += perPage + 1;
+ }
+ }
+}
+
/*
** Try to figure out how every page in the database file is being used.
*/
/* Discover the usage of each page */
a = getContent(0, 100);
page_usage_freelist(decodeInt32(a+32));
+ page_usage_ptrmap(a);
free(a);
page_usage_btree(1, 0, 0, "sqlite_master");
sqlite3_exec(db, "PRAGMA writable_schema=ON", 0, 0, 0);
zPageUse = 0;
}
+/*
+** Try to figure out how every page in the database file is being used.
+*/
+static void ptrmap_coverage_report(const char *zDbName){
+ unsigned int pgno;
+ unsigned char *aHdr;
+ unsigned char *a;
+ int usable;
+ int perPage;
+ unsigned int i;
+
+ /* Avoid the pathological case */
+ if( mxPage<1 ){
+ printf("empty database\n");
+ return;
+ }
+
+ /* Make sure PTRMAPs are used in this database */
+ aHdr = getContent(0, 100);
+ if( aHdr[55]==0 ){
+ printf("database does not use PTRMAP pages\n");
+ return;
+ }
+ usable = pagesize - aHdr[20];
+ perPage = usable/5;
+ free(aHdr);
+ printf("%5d: root of sqlite_master\n", 1);
+ for(pgno=2; pgno<=mxPage; pgno += perPage+1){
+ printf("%5d: PTRMAP page covering %d..%d\n", pgno,
+ pgno+1, pgno+perPage);
+ a = getContent((pgno-1)*pagesize, usable);
+ for(i=0; i+5<=usable && pgno+1+i/5<=mxPage; i+=5){
+ const char *zType = "???";
+ unsigned int iFrom = decodeInt32(&a[i+1]);
+ switch( a[i] ){
+ case 1: zType = "b-tree root page"; break;
+ case 2: zType = "freelist page"; break;
+ case 3: zType = "first page of overflow"; break;
+ case 4: zType = "later page of overflow"; break;
+ case 5: zType = "b-tree non-root page"; break;
+ }
+ printf("%5d: %s, parent=%u\n", pgno+1+i/5, zType, iFrom);
+ }
+ free(a);
+ }
+}
+
/*
** Print a usage comment
*/
"args:\n"
" dbheader Show database header\n"
" pgidx Index of how each page is used\n"
+ " ptrmap Show all PTRMAP page content\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"
page_usage_report(argv[1]);
continue;
}
+ if( strcmp(argv[i], "ptrmap")==0 ){
+ ptrmap_coverage_report(argv[1]);
+ continue;
+ }
+ if( strcmp(argv[i], "help")==0 ){
+ usage(argv[0]);
+ continue;
+ }
if( !isdigit(argv[i][0]) ){
fprintf(stderr, "%s: unknown option: [%s]\n", argv[0], argv[i]);
continue;