]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
In the showdb.exe utility, for the "NNNbd" command, also show data fields
authordrh <drh@noemail.net>
Fri, 20 Jun 2014 01:32:42 +0000 (01:32 +0000)
committerdrh <drh@noemail.net>
Fri, 20 Jun 2014 01:32:42 +0000 (01:32 +0000)
in addition to header fields on each record decoded.  Improvements to
formatting.

FossilOrigin-Name: b451fe0cb92278deb7724e7995c1bd46ae83c119

manifest
manifest.uuid
tool/showdb.c

index d6ee27e4ac06b9ee359cc2a5d52df3f4b063de27..d8af3f1d0fc9ccfe25bb0b70bd0bb23d77f931d1 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sthe\sability\sto\sdecode\sthe\sheaders\sof\sindividual\scells,\sbyte-by-byte,\nin\sthe\s"showdb.exe"\sutility.
-D 2014-06-19T23:38:53.722
+C In\sthe\sshowdb.exe\sutility,\sfor\sthe\s"NNNbd"\scommand,\salso\sshow\sdata\sfields\nin\saddition\sto\sheader\sfields\son\seach\srecord\sdecoded.\s\sImprovements\sto\s\nformatting.
+D 2014-06-20T01:32:42.411
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -1158,7 +1158,7 @@ F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
 F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b
 F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a
 F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5
-F tool/showdb.c c080dea3addc8440191aef2c7cf222ee7959529c
+F tool/showdb.c eef4bd98ba995c6a9373cbc0e7b8a3201a658585
 F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02
 F tool/showwal.c 3f7f7da5ec0cba51b1449a75f700493377da57b5
 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe
@@ -1179,7 +1179,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 7b91b0581d169a353462d96120a2e0d4dcc8e8ae
-R 80dc9f5b1256cb0818cbd9270f47db96
+P 306b461d7c0643b6ac4df944759ecc9ce8581634
+R 1d1b4729d93a91658ee348794dbfb980
 U drh
-Z ec7d321d3c2511a642cbe0539a129858
+Z 8ea506b1401ff81840cba469aab2c6cc
index 204ffc59ee7337d16e596c68f8334fb54f09ac47..e90ca871c2f741aeffebf9ef22371ec47e0be46a 100644 (file)
@@ -1 +1 @@
-306b461d7c0643b6ac4df944759ecc9ce8581634
\ No newline at end of file
+b451fe0cb92278deb7724e7995c1bd46ae83c119
\ No newline at end of file
index d4e26f45c1c6ff06b533de733a53c9df0f83e007..d97838220a67cb54d27a6546145417daba0946d6 100644 (file)
@@ -383,9 +383,12 @@ static void decodeCell(
   unsigned char *x = a + ofst;
   unsigned char *end;
   unsigned char cType = a[0];
+  int nCol = 0;
+  int szCol[2000];
+  int ofstCol[2000];
+  int typeCol[2000];
 
-  printf("Decode cell[%d] on page %d offset %04x....\n",
-         iCell, pgno, szPgHdr+ofst);
+  printf("Cell[%d]:\n", iCell);
   if( cType<=5 ){
     leftChild = ((x[0]*256 + x[1])*256 + x[2])*256 + x[3];
     printBytes(a, x, 4);
@@ -396,7 +399,12 @@ static void decodeCell(
     i = decodeVarint(x, &nPayload);
     printBytes(a, x, i);
     nLocal = localPayload(nPayload, cType);
-    printf("bytes of payload: %d  (local: %d)\n", (int)nPayload, nLocal);
+    if( nLocal==nPayload ){
+      printf("payload-size: %d\n", (int)nPayload);
+    }else{
+      printf("payload-size: %d (%d local, %d overflow)\n",
+             (int)nPayload, nLocal, (int)(nPayload-nLocal));
+    }
     x += i;
   }else{
     nPayload = nLocal = 0;
@@ -411,16 +419,17 @@ static void decodeCell(
   if( nLocal>0 ){
     i = decodeVarint(x, &nHdr);
     printBytes(a, x, i);
-    printf("record header size: %d\n", (int)nHdr);
+    printf("record-header-size: %d\n", (int)nHdr);
     j = i;
-    k = 0;
+    nCol = 0;
+    k = nHdr;
     while( x+j<end && j<nHdr ){
        const char *zTypeName;
        int sz = 0;
        char zNm[30];
        i = decodeVarint(x+j, &iType);
        printBytes(a, x+j, i);
-       printf("column[%d] type code: %d - ", k++, (int)iType);
+       printf("typecode[%d]: %d - ", nCol, (int)iType);
        switch( iType ){
          case 0:  zTypeName = "NULL";    sz = 0;  break;
          case 1:  zTypeName = "int8";    sz = 1;  break;
@@ -442,16 +451,47 @@ static void decodeCell(
          }
        }
        printf("%s\n", zTypeName);
+       szCol[nCol] = sz;
+       ofstCol[nCol] = k;
+       typeCol[nCol] = (int)iType;
+       k += sz;
+       nCol++;
        j += i;
     }
+    for(i=0; i<nCol && ofstCol[i]+szCol[i]<=nLocal; i++){
+       int s = ofstCol[i];
+       i64 v;
+       const unsigned char *pData;
+       if( szCol[i]==0 ) continue;
+       printBytes(a, x+s, szCol[i]);
+       printf("data[%d]: ", i);
+       pData = x+s;
+       if( typeCol[i]<=7 ){
+         v = (signed char)pData[0];
+         for(k=1; k<szCol[i]; k++){
+           v = (v<<8) + pData[k];
+         }
+         if( typeCol[i]==7 ){
+           double r;
+           memcpy(&r, &v, sizeof(r));
+           printf("%#g\n", r);
+         }else{
+           printf("%lld\n", v);
+         }
+       }else{
+         printf("%d bytes of %s\n", szCol[i],
+                (typeCol[i]&1)==0 ? "BLOB" : "TEXT");
+       }
+       j = ofstCol[i] + szCol[i];
+    }
   }
   if( j<nLocal ){
     printBytes(a, x+j, 0);
-    printf("%d bytes of content\n", nLocal-j);
+    printf("... %d bytes of content ...\n", nLocal-j);
   }
   if( nLocal<nPayload ){
     printBytes(a, x+nLocal, 4);
-    printf("first overflow page: %d\n", decodeInt32(x+nLocal));
+    printf("overflow-page: %d\n", decodeInt32(x+nLocal));
   }
 }
 
@@ -500,23 +540,22 @@ static void decode_btree_page(
   }
   nCell = a[3]*256 + a[4];
   iCellPtr = (a[0]==2 || a[0]==5) ? 12 : 8;
-  if( cellToDecode==(-2) ){
-    printf("Decode of btree page %d:\n", pgno);
-    print_decode_line(a, 0, 1, zType);
-    print_decode_line(a, 1, 2, "Offset to first freeblock");
-    print_decode_line(a, 3, 2, "Number of cells on this page");
-    print_decode_line(a, 5, 2, "Offset to cell content area");
-    print_decode_line(a, 7, 1, "Fragmented byte count");
-    if( a[0]==2 || a[0]==5 ){
-      print_decode_line(a, 8, 4, "Right child");
-    }
-    if( nCell>0 ){
-      printf(" key: lx=left-child n=payload-size r=rowid\n");
-    }
-  }else if( cellToDecode>=nCell ){
+  if( cellToDecode>=nCell ){
     printf("Page %d has only %d cells\n", pgno, nCell);
     return;
   }
+  printf("Header on btree page %d:\n", pgno);
+  print_decode_line(a, 0, 1, zType);
+  print_decode_line(a, 1, 2, "Offset to first freeblock");
+  print_decode_line(a, 3, 2, "Number of cells on this page");
+  print_decode_line(a, 5, 2, "Offset to cell content area");
+  print_decode_line(a, 7, 1, "Fragmented byte count");
+  if( a[0]==2 || a[0]==5 ){
+    print_decode_line(a, 8, 4, "Right child");
+  }
+  if( cellToDecode==(-2) && nCell>0 ){
+    printf(" key: lx=left-child n=payload-size r=rowid\n");
+  }
   if( showMap ){
     zMap = malloc(pagesize);
     memset(zMap, '.', pagesize);
@@ -547,6 +586,7 @@ static void decode_btree_page(
     }
   }
   if( showMap ){
+    printf("Page map:  (H=header P=cell-index 1=page-1-header .=free-space)\n");
     for(i=0; i<pagesize; i+=64){
       printf(" %03x: %.64s\n", i, &zMap[i]);
     }