SQLite

Check-in [61d72e1791]
Login

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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 61d72e17916bc043ce53c64e5ba7050a9bae554e
User & Date: drh 2015-04-15 15:29:05.938
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: f71053cf65 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: 61d72e1791 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: b8768f124e user: drh tags: trunk)
Changes
Unified Diff 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
** 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(







>




|
>







60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
** 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(
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
  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++){







|







979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
  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++){