]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Preliminary fix for ticket #599. More testing and analysis needed. (CVS 1208)
authordrh <drh@noemail.net>
Sun, 8 Feb 2004 00:40:52 +0000 (00:40 +0000)
committerdrh <drh@noemail.net>
Sun, 8 Feb 2004 00:40:52 +0000 (00:40 +0000)
FossilOrigin-Name: dc5be2c82b591a385adf02863d89e113272e2ebd

manifest
manifest.uuid
src/pager.c
tool/showjournal.c

index 727e589a45552a4601919d79d4f6577b0791de64..bdab6c2eea0938225a2cae8ab2dfff4d5e8e2fa5 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\sundocumented\sextensions\sfrom\ssqlite_mprintf()\sand\sfriends\sin\sorder\sto\nmake\sit\sabout\s10%\ssmaller.\s(CVS\s1207)
-D 2004-02-02T12:29:25
+C Preliminary\sfix\sfor\sticket\s#599.\s\sMore\stesting\sand\sanalysis\sneeded.\s(CVS\s1208)
+D 2004-02-08T00:40:52
 F Makefile.in 0515ff9218ad8d5a8f6220f0494b8ef94c67013b
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -40,7 +40,7 @@ F src/main.c 808ea1bda0798f4a714479aee8289d65f04cf29b
 F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565
 F src/os.c 681ec36217bc7c795d55d9a63ff79a8614ddee8c
 F src/os.h 8d02b622153d2df442da1ec37cdd6b1bd9804a25
-F src/pager.c 289328d8efba620eae99f6c2f6062710838a3eb4
+F src/pager.c 7872537f9f47339b2a1098a54101d7f4e4c25364
 F src/pager.h 5da62c83443f26b1792cfd72c96c422f91aadd31
 F src/parse.y 7a121554c0c0c0150a77ab05417b01fa44813ac4
 F src/pragma.c 89d62c31c6f0a43376fe8d20549b87a6d30c467a
@@ -153,7 +153,7 @@ F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x
 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
 F tool/report1.txt 9eae07f26a8fc53889b45fc833a66a33daa22816
 F tool/showdb.c 3559eac5a3b46e9b558d50856946b25e77633236
-F tool/showjournal.c 9a37d7b05de0591e3102aaf774d01fbc0d053a8b
+F tool/showjournal.c ec3b171be148656827c4949fbfb8ab4370822f87
 F tool/space_used.tcl f714c41a59e326b8b9042f415b628b561bafa06b
 F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
@@ -182,7 +182,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
 F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
 F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P 3c796de8d1af55944f396f08feaa9e69c1652896
-R eeb1a65670905e806f11ab1b63f5e8e7
+P 0b3f552b986fd89c48c350b0746be93b9d276ecc
+R 753fd39b58050d194e71064713a576ce
 U drh
-Z f7f5c0bf32582b04f90ec08e5433a558
+Z 12eaf8d85a0609bf96a6d19c712cf69b
index 6d0289d0d427305eae6d91bdad8a31994df8b921..af1e994767eb25eb3b8d1907d4129f0d9c51b815 100644 (file)
@@ -1 +1 @@
-0b3f552b986fd89c48c350b0746be93b9d276ecc
\ No newline at end of file
+dc5be2c82b591a385adf02863d89e113272e2ebd
\ No newline at end of file
index 605dc0d320b1e412827525973a7e6f46db896df6..589a885f000d0540ebad0f60a14d8cc4faf4f7aa 100644 (file)
@@ -18,7 +18,7 @@
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
 **
-** @(#) $Id: pager.c,v 1.92 2004/01/07 02:52:08 drh Exp $
+** @(#) $Id: pager.c,v 1.93 2004/02/08 00:40:52 drh Exp $
 */
 #include "os.h"         /* Must be first to enable large file support */
 #include "sqliteInt.h"
@@ -571,6 +571,10 @@ static int pager_playback(Pager *pPager, int useJournalSize){
   if( rc!=SQLITE_OK ){
     goto end_playback;
   }
+
+  /* If the journal file is too small to contain a complete header,
+  ** then ignore the journal completely.
+  */
   if( szJ < sizeof(aMagic)+sizeof(Pgno) ){
     goto end_playback;
   }
@@ -594,6 +598,15 @@ static int pager_playback(Pager *pPager, int useJournalSize){
     goto end_playback;
   }
   if( format>=JOURNAL_FORMAT_3 ){
+    if( szJ < sizeof(aMagic) + 3*sizeof(u32) ){
+      /* Ignore the journal if it is too small to contain a complete
+      ** header.  We already did this test once above, but at the prior
+      ** test, we did not know the journal format and so we had to assume
+      ** the smallest possible header.  Now we know the header is bigger
+      ** than that so we test again.
+      */
+      goto end_playback;
+    }
     rc = read32bits(format, &pPager->jfd, (u32*)&nRec);
     if( rc ) goto end_playback;
     rc = read32bits(format, &pPager->jfd, &pPager->cksumInit);
@@ -630,7 +643,7 @@ static int pager_playback(Pager *pPager, int useJournalSize){
 
   /* Pages that have been written to the journal but never synced
   ** where not restored by the loop above.  We have to restore those
-  ** pages by reading the back from the original database.
+  ** pages by reading them back from the original database.
   */
   if( rc==SQLITE_OK ){
     PgHdr *pPg;
@@ -1896,7 +1909,8 @@ int sqlitepager_commit(Pager *pPager){
     return rc;
   }
   assert( pPager->journalOpen );
-  if( pPager->needSync && sqliteOsSync(&pPager->jfd)!=SQLITE_OK ){
+  rc = syncAllPages(pPager);
+  if( rc!=SQLITE_OK ){
     goto commit_abort;
   }
   pPg = pager_get_all_dirty_pages(pPager);
index 5621f5b82c3fa269e6862dabbfc9a0b3e064e373..ec93c9190522c3ac3df73b59e7edbb61fd023f20 100644 (file)
@@ -43,7 +43,8 @@ int main(int argc, char **argv){
   struct stat sbuf;
   unsigned int u;
   int rc;
-  char zBuf[100];
+  unsigned char zBuf[10];
+  unsigned char zBuf2[sizeof(u)];
   if( argc!=2 ){
     fprintf(stderr,"Usage: %s FILENAME\n", argv[0]);
     exit(1);
@@ -54,10 +55,22 @@ int main(int argc, char **argv){
     exit(1);
   }
   read(db, zBuf, 8);
-  read(db, &u, sizeof(u));
+  if( zBuf[7]==0xd6 ){
+    read(db, &u, sizeof(u));
+    printf("Records in Journal: %u\n", u);
+    read(db, &u, sizeof(u));
+    printf("Magic Number: 0x%08x\n", u);
+  }
+  read(db, zBuf2, sizeof(zBuf2));
+  u = zBuf2[0]<<24 | zBuf2[1]<<16 | zBuf2[2]<<8 | zBuf2[3];
   printf("Database Size: %u\n", u);
-  while( read(db, &u, sizeof(u))==sizeof(u) ){
+  while( read(db, zBuf2, sizeof(zBuf2))==sizeof(zBuf2) ){
+    u = zBuf2[0]<<24 | zBuf2[1]<<16 | zBuf2[2]<<8 | zBuf2[3];
     print_page(u);
+    if( zBuf[7]==0xd6 ){
+      read(db, &u, sizeof(u));
+      printf("Checksum: 0x%08x\n", u);
+    }
   }
   close(db);
 }