]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add sqlite3_log() diagnostic messages for a specific type of corruption
authordrh <drh@noemail.net>
Thu, 24 Apr 2014 13:20:33 +0000 (13:20 +0000)
committerdrh <drh@noemail.net>
Thu, 24 Apr 2014 13:20:33 +0000 (13:20 +0000)
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.

FossilOrigin-Name: 34155c406c7135accdc25e4828cb28137d3840fb

manifest
manifest.uuid
src/btree.c
src/pager.c
src/pager.h
src/printf.c

index 4fa7069d09d8ab3c51e8572b94ff71fa1fb8c588..361c677d21ce75019748dc40c7b5da23765cbd28 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Version\s3.7.8\srelease\scandidate
-D 2011-09-19T14:49:19.255
+C Add\ssqlite3_log()\sdiagnostic\smessages\sfor\sa\sspecific\stype\sof\scorruption\nwhere\sthe\sfile\ssize\sis\sreported\sto\sbe\stoo\ssmall\srelative\sto\sthe\ssize\sin\nthe\sheader.\s\sThis\sbranch\sis\sintended\sto\shelp\sdebug\sa\sspecific\sproblem\nreported\sfrom\sthe\swild\sand\sis\snot\sfor\sgeneral\suse.
+D 2014-04-24T13:20:33.894
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in d314143fa6be24828021d3f583ad37d9afdce505
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -124,7 +124,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
 F src/backup.c 28a4fe55327ff708bfaf9d4326d02686f7a553c3
 F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef
 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
-F src/btree.c 77b09c69d4849a90361e6fe5db36d167f20600c0
+F src/btree.c 7339c511e4c356611ab059dd12980d9931dc5d48
 F src/btree.h f5d775cd6cfc7ac32a2535b70e8d2af48ef5f2ce
 F src/btreeInt.h 67978c014fa4f7cc874032dd3aacadd8db656bc3
 F src/build.c 851e81f26a75abbb98bd99a7c5f10e8670d867bb
@@ -167,15 +167,15 @@ F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
 F src/os_unix.c 10e0c4dcdbec8d4189890fdf3e71b32efae194e3
 F src/os_win.c 0fc0f46c94b0385a940b0ee32992a833019a5985
-F src/pager.c 15d10371e2d560b68870a9ccec022ad8f01e70a2
-F src/pager.h 3f8c783de1d4706b40b1ac15b64f5f896bcc78d1
+F src/pager.c ddf6e9950ccf70e2b7381d45120c14af910770b6
+F src/pager.h 996123976d473220d2a9c3e8f8609e9cce1c87ee
 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58
 F src/pcache.c 49e718c095810c6b3334e3a6d89970aceaddefce
 F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050
 F src/pcache1.c c8982f7048a70b7fd37975a8f6c84d6bc294175a
 F src/pragma.c ebcd20f1e654f5cb3aeef864ed69c4697719fbaa
 F src/prepare.c e64261559a3187698a3e7e6c8b001a4f4f98dab4
-F src/printf.c 585a36b6a963df832cfb69505afa3a34ed5ef8a1
+F src/printf.c eca1a6289fa6e2ea71a45174d5c8bc862e5fb0fb
 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
 F src/resolve.c 36368f44569208fa074e61f4dd0b6c4fb60ca2b4
 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
@@ -963,7 +963,10 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5
 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
 F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2
-P db019465036171fcad31181bec7d6ac185f50430
-R 0a2782a80f1b08369498ecce1d7a7aa8
+P 3e0da808d2f5b4d12046e05980ca04578f581177
+R d5f0790d7c68cdafa07773bb8ff37593
+T *branch * filesize-debug
+T *sym-filesize-debug *
+T -sym-trunk *
 U drh
-Z 5f8dabab2a44903caad40fc4aceed901
+Z 1f0fd56c3eff1640d4907b3dac4ae63d
index 6cc03efd832ff5c5030c40759e5e1e754ff0d799..50a6d54f926fb76be9b5799b3e197e93a8976abe 100644 (file)
@@ -1 +1 @@
-3e0da808d2f5b4d12046e05980ca04578f581177
\ No newline at end of file
+34155c406c7135accdc25e4828cb28137d3840fb
\ No newline at end of file
index 7e6e02f144772ee3e2aa330942576675d680cfcb..5dec3410e41a4d18bc2270f96b1d8e2b13a23faa 100644 (file)
@@ -2393,6 +2393,8 @@ static int lockBtree(BtShared *pBt){
       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;
     }
index f8d3ba998996213ff38c54b8c6261cc2813aa867..b80da6cb2935041244cfd361072cf8f7206760ac 100644 (file)
@@ -3092,6 +3092,25 @@ static int pagerPagecount(Pager *pPager, Pgno *pnPage){
   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
index eab7ddaf80bb44c3a89c1b7123a8691be19b64fb..a1b781b021d3e8e09e06750845ac53fb791d4f65 100644 (file)
@@ -155,6 +155,7 @@ 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);
index 2a3dd81d7d2603a072d5074973004ab48123bc7f..f1f3f7c60f3c100e9ccb19046cbc163e7d5493f4 100644 (file)
@@ -189,6 +189,7 @@ static void appendSpace(StrAccum *pAccum, int N){
 ** 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