SQLite

Check-in [34155c406c]
Login

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

Overview
Comment:Add sqlite3_log() diagnostic messages for a specific type of corruption where the file size is reported to be too small relative to the size in the header. This branch is intended to help debug a specific problem reported from the wild and is not for general use.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | filesize-debug
Files: files | file ages | folders
SHA1: 34155c406c7135accdc25e4828cb28137d3840fb
User & Date: drh 2014-04-24 13:20:33.894
Context
2014-06-17
18:43
Experimental changes to use GetFileInformationByHandle instead of GetFileSize in the Win32 VFS. (Closed-Leaf check-in: d22c814297 user: mistachkin tags: filesize-debug)
2014-04-24
13:20
Add sqlite3_log() diagnostic messages for a specific type of corruption where the file size is reported to be too small relative to the size in the header. This branch is intended to help debug a specific problem reported from the wild and is not for general use. (check-in: 34155c406c user: drh tags: filesize-debug)
2011-09-19
18:00
Version 3.7.8 (check-in: 3e0da808d2 user: drh tags: trunk, release, version-3.7.8)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/btree.c.
2389
2390
2391
2392
2393
2394
2395


2396
2397
2398
2399
2400
2401
2402
      pBt->pageSize = pageSize;
      freeTempSpace(pBt);
      rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,
                                   pageSize-usableSize);
      return rc;
    }
    if( (pBt->db->flags & SQLITE_RecoveryMode)==0 && nPage>nPageFile ){


      rc = SQLITE_CORRUPT_BKPT;
      goto page1_init_failed;
    }
    if( usableSize<480 ){
      goto page1_init_failed;
    }
    pBt->pageSize = pageSize;







>
>







2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
      pBt->pageSize = pageSize;
      freeTempSpace(pBt);
      rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,
                                   pageSize-usableSize);
      return rc;
    }
    if( (pBt->db->flags & SQLITE_RecoveryMode)==0 && nPage>nPageFile ){
      sqlite3_log(SQLITE_CORRUPT, "nPage=%d nPageFile=%d", nPage, nPageFile);
      sqlite3PagerLogDiagnostics(pBt->pPager);
      rc = SQLITE_CORRUPT_BKPT;
      goto page1_init_failed;
    }
    if( usableSize<480 ){
      goto page1_init_failed;
    }
    pBt->pageSize = pageSize;
Changes to src/pager.c.
3087
3088
3089
3090
3091
3092
3093



















3094
3095
3096
3097
3098
3099
3100
  if( nPage>pPager->mxPgno ){
    pPager->mxPgno = (Pgno)nPage;
  }

  *pnPage = nPage;
  return SQLITE_OK;
}




















#ifndef SQLITE_OMIT_WAL
/*
** Check if the *-wal file that corresponds to the database opened by pPager
** exists if the database is not empy, or verify that the *-wal file does
** not exist (by deleting it) if the database file is empty.
**







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
  if( nPage>pPager->mxPgno ){
    pPager->mxPgno = (Pgno)nPage;
  }

  *pnPage = nPage;
  return SQLITE_OK;
}

/* Log diagnostic information about the pager */
void sqlite3PagerLogDiagnostics(Pager *pPager){
  int rc;
  i64 n;
  sqlite3_log(SQLITE_INTERNAL, "Pager filename=[%s]", pPager->zFilename);
  sqlite3_log(SQLITE_INTERNAL, "Pager journal=[%s]", pPager->zJournal);
  sqlite3_log(SQLITE_INTERNAL,
    "Pager diagnostics: pWal=%p isOpen=%d pageSize=%d dbSize=%d eState=%d",
    pPager->pWal, isOpen(pPager->fd)!=0,
    pPager->pageSize, pPager->dbSize, pPager->eState
  );
  if( isOpen(pPager->fd) ){
    n = 0;
    rc = sqlite3OsFileSize(pPager->fd, &n);
    sqlite3_log(SQLITE_INTERNAL, "Pager OsFileSize: %lld (%d)", n, rc);
  }
}


#ifndef SQLITE_OMIT_WAL
/*
** Check if the *-wal file that corresponds to the database opened by pPager
** exists if the database is not empy, or verify that the *-wal file does
** not exist (by deleting it) if the database file is empty.
**
Changes to src/pager.h.
151
152
153
154
155
156
157

158
159
160
161
162
163
164
const char *sqlite3PagerFilename(Pager*);
const sqlite3_vfs *sqlite3PagerVfs(Pager*);
sqlite3_file *sqlite3PagerFile(Pager*);
const char *sqlite3PagerJournalname(Pager*);
int sqlite3PagerNosync(Pager*);
void *sqlite3PagerTempSpace(Pager*);
int sqlite3PagerIsMemdb(Pager*);


/* Functions used to truncate the database file. */
void sqlite3PagerTruncateImage(Pager*,Pgno);

#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL)
void *sqlite3PagerCodec(DbPage *);
#endif







>







151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
const char *sqlite3PagerFilename(Pager*);
const sqlite3_vfs *sqlite3PagerVfs(Pager*);
sqlite3_file *sqlite3PagerFile(Pager*);
const char *sqlite3PagerJournalname(Pager*);
int sqlite3PagerNosync(Pager*);
void *sqlite3PagerTempSpace(Pager*);
int sqlite3PagerIsMemdb(Pager*);
void sqlite3PagerLogDiagnostics(Pager*);

/* Functions used to truncate the database file. */
void sqlite3PagerTruncateImage(Pager*,Pgno);

#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL)
void *sqlite3PagerCodec(DbPage *);
#endif
Changes to src/printf.c.
185
186
187
188
189
190
191

192
193
194
195
196
197
198
  }
}

/*
** On machines with a small stack size, you can redefine the
** SQLITE_PRINT_BUF_SIZE to be less than 350.
*/

#ifndef SQLITE_PRINT_BUF_SIZE
# if defined(SQLITE_SMALL_STACK)
#   define SQLITE_PRINT_BUF_SIZE 50
# else
#   define SQLITE_PRINT_BUF_SIZE 350
# endif
#endif







>







185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
  }
}

/*
** On machines with a small stack size, you can redefine the
** SQLITE_PRINT_BUF_SIZE to be less than 350.
*/
#define SQLITE_PRINT_BUF_SIZE 2000
#ifndef SQLITE_PRINT_BUF_SIZE
# if defined(SQLITE_SMALL_STACK)
#   define SQLITE_PRINT_BUF_SIZE 50
# else
#   define SQLITE_PRINT_BUF_SIZE 350
# endif
#endif