/ Check-in [61d72e17]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Enhance the showdb utility program so that it can read the last partial page of a truncated database file.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 61d72e17916bc043ce53c64e5ba7050a9bae554e
User & Date: drh 2015-04-15 15:29:05
Context
2015-04-15
17:26
Prevent the fetchPayload() routine from reporting a cell size that extends off the end of the page on a pathologically corrupted database file. check-in: f71053cf user: drh tags: trunk
15:29
Enhance the showdb utility program so that it can read the last partial page of a truncated database file. check-in: 61d72e17 user: drh tags: trunk
14:52
Add the --msvc command-line option to the releasetest.tcl script. This is only a partial merge from the winTest branch as the OS_TRACE changes are omitted. check-in: b8768f12 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tool/showdb.c.

60
61
62
63
64
65
66

67
68
69
70
71

72
73
74
75
76
77
78
...
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
** Read content from the file.
**
** Space to hold the content is obtained from malloc() and needs to be
** freed by the caller.
*/
static unsigned char *getContent(int ofst, int nByte){
  unsigned char *aData;

  aData = malloc(nByte+32);
  if( aData==0 ) out_of_memory();
  memset(aData, 0, nByte+32);
  lseek(db, ofst, SEEK_SET);
  if( read(db, aData, nByte)<nByte ) memset(aData, 0, nByte);

  return aData;
}

/*
** Print a range of bytes as hex and as ascii.
*/
static unsigned char *print_byte_range(
................................................................................
  zPgSz[1] = 0;
  lseek(db, 16, SEEK_SET);
  if( read(db, zPgSz, 2)<2 ) memset(zPgSz, 0, 2);
  pagesize = zPgSz[0]*256 + zPgSz[1]*65536;
  if( pagesize==0 ) pagesize = 1024;
  printf("Pagesize: %d\n", pagesize);
  fstat(db, &sbuf);
  mxPage = sbuf.st_size/pagesize;
  printf("Available pages: 1..%d\n", mxPage);
  if( argc==2 ){
    int i;
    for(i=1; i<=mxPage; i++) print_page(i);
  }else{
    int i;
    for(i=2; i<argc; i++){







>




|
>







 







|







60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
...
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
** Read content from the file.
**
** Space to hold the content is obtained from malloc() and needs to be
** freed by the caller.
*/
static unsigned char *getContent(int ofst, int nByte){
  unsigned char *aData;
  int got;
  aData = malloc(nByte+32);
  if( aData==0 ) out_of_memory();
  memset(aData, 0, nByte+32);
  lseek(db, ofst, SEEK_SET);
  got = read(db, aData, nByte);
  if( got>0 && got<nByte ) memset(aData+got, 0, nByte-got);
  return aData;
}

/*
** Print a range of bytes as hex and as ascii.
*/
static unsigned char *print_byte_range(
................................................................................
  zPgSz[1] = 0;
  lseek(db, 16, SEEK_SET);
  if( read(db, zPgSz, 2)<2 ) memset(zPgSz, 0, 2);
  pagesize = zPgSz[0]*256 + zPgSz[1]*65536;
  if( pagesize==0 ) pagesize = 1024;
  printf("Pagesize: %d\n", pagesize);
  fstat(db, &sbuf);
  mxPage = (sbuf.st_size+pagesize-1)/pagesize;
  printf("Available pages: 1..%d\n", mxPage);
  if( argc==2 ){
    int i;
    for(i=1; i<=mxPage; i++) print_page(i);
  }else{
    int i;
    for(i=2; i<argc; i++){