SQLite

Check-in [2bda9dc41c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:In the "pgidx" report from "showdb", also show the number of rows on each database btree page.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2bda9dc41c07092ae37d0c6001c1271e0622bfff7151201fc2bb4c95422c087b
User & Date: drh 2019-04-17 13:23:28.341
Context
2019-04-17
13:58
Fix a typo in the CLI help output for the ".dump" command. (check-in: 57638248de user: drh tags: trunk)
13:23
In the "pgidx" report from "showdb", also show the number of rows on each database btree page. (check-in: 2bda9dc41c user: drh tags: trunk)
12:29
In the "pgidx" command of the showdb utility, try to identify orphaned pages and show when pages have been zeroed out. (check-in: eed701ef91 user: drh tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to tool/showdb.c.
857
858
859
860
861
862
863

864
865
866
867
868
869
870
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871







+







  const char *zName     /* Name of the table */
){
  unsigned char *a;
  const char *zType = "corrupt node";
  int nCell;
  int i;
  int hdr = pgno==1 ? 100 : 0;
  char zEntry[30];

  if( pgno<=0 || pgno>g.mxPage ) return;
  a = fileRead((pgno-1)*g.pagesize, g.pagesize);
  switch( a[hdr] ){
    case 0: {
      if( allZero(a, g.pagesize) ){
        zType = "zeroed page";
880
881
882
883
884
885
886






887
888
889


890
891

892
893

894
895
896
897
898
899
900
901
902
881
882
883
884
885
886
887
888
889
890
891
892
893
894


895
896
897

898
899

900
901

902
903
904
905
906
907
908







+
+
+
+
+
+

-
-
+
+

-
+

-
+

-







    case 10: zType = "leaf of index";           break;
    case 13: zType = "leaf of table";           break;
    default: {
      if( parent<0 ) return;
      zType = "corrupt node";
    }
  }
  nCell = a[hdr+3]*256 + a[hdr+4];
  if( nCell==1 ){
    sqlite3_snprintf(sizeof(zEntry),zEntry,"1 row");
  }else{
    sqlite3_snprintf(sizeof(zEntry),zEntry,"%d rows", nCell);
  }
  if( parent>0 ){
    page_usage_msg(pgno, "%s [%s], child %d of page %d",
                   zType, zName, idx, parent);
    page_usage_msg(pgno, "%s [%s], child %d of page %d, %s",
                   zType, zName, idx, parent, zEntry);
  }else if( parent==0 ){
    page_usage_msg(pgno, "root %s [%s]", zType, zName);
    page_usage_msg(pgno, "root %s [%s], %s", zType, zName, zEntry);
  }else{
    page_usage_msg(pgno, "orphaned %s", zType);
    page_usage_msg(pgno, "orphaned %s, %s", zType, zEntry);
  }
  nCell = a[hdr+3]*256 + a[hdr+4];
  if( a[hdr]==2 || a[hdr]==5 ){
    int cellstart = hdr+12;
    unsigned int child;
    for(i=0; i<nCell; i++){
      int ofst;

      ofst = cellstart + i*2;