]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a bug in the logic for journaling pages when the device sector-size is greater...
authordanielk1977 <danielk1977@noemail.net>
Wed, 22 Aug 2007 18:54:32 +0000 (18:54 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Wed, 22 Aug 2007 18:54:32 +0000 (18:54 +0000)
FossilOrigin-Name: b6399dff1370449912391cc5925bdc468b5dade0

manifest
manifest.uuid
src/pager.c

index 8718685b395987b33b417635c09b7662eaa0a968..ceb3833f9c1b87c97f1dc1888a28f5dcf87301eb 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Get\sthe\squick.test\sscript\srunning\swith\sSQLITE_THREADSAFE\senabled.\s(CVS\s4269)
-D 2007-08-22T11:41:18
+C Fix\sa\sbug\sin\sthe\slogic\sfor\sjournaling\spages\swhen\sthe\sdevice\ssector-size\sis\sgreater\sthan\sthe\spage\ssize.\s(CVS\s4270)
+D 2007-08-22T18:54:33
 F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe
 F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -115,7 +115,7 @@ F src/os_unix.c 7aad42b1ee70d68034a4ac45fa822edccdc3d9e6
 F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
 F src/os_win.c 29c0e19c1072679a4c7818c49fab2f35d2ad7747
 F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
-F src/pager.c 3568c1c557b2ff8faf054732abd32bc640116684
+F src/pager.c 029a441236e9f504e25a3e2d2944afeae48c297c
 F src/pager.h 53087c6fb9db01aed17c7fd044662a27507e89b8
 F src/parse.y 2d2ce439dc6184621fb0b86f4fc5aca7f391a590
 F src/pragma.c 9b989506a1b7c8aecd6befb8235e2f57a4aba7e5
@@ -559,7 +559,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 581fadfe31757e3fb97b12f93c1e3c085e4b6009
-R 04edf60a36c6b67ded0e1d8395cfcdd2
-U drh
-Z 751a55fa40ff7163f0ed16353fbe540e
+P 1f28b7e47bba221c14a10a37e7425c9975bb2312
+R cf0de8a627c4e3c426ffb917c87f2598
+U danielk1977
+Z fbf5424b267fecb1d05194b85e3145a4
index 420d583237616282d50c23da4256b143eb789ce1..199325d000e212cc1979c2f877082da61a7b8890 100644 (file)
@@ -1 +1 @@
-1f28b7e47bba221c14a10a37e7425c9975bb2312
\ No newline at end of file
+b6399dff1370449912391cc5925bdc468b5dade0
\ No newline at end of file
index 8384ed768e98171ea130eaf8017c815a182582cc..b0fbcffb544aa7a0a3692cb7449b0f7895c09be7 100644 (file)
@@ -18,7 +18,7 @@
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
 **
-** @(#) $Id: pager.c,v 1.366 2007/08/22 11:22:04 danielk1977 Exp $
+** @(#) $Id: pager.c,v 1.367 2007/08/22 18:54:33 danielk1977 Exp $
 */
 #ifndef SQLITE_OMIT_DISKIO
 #include "sqliteInt.h"
@@ -1928,7 +1928,7 @@ int sqlite3PagerOpen(
     return ((rc==SQLITE_OK)?SQLITE_NOMEM:rc);
   }
 
-  PAGERTRACE3("OPEN %d %s\n", FILEHANDLEID(fd), zFullPathname);
+  PAGERTRACE3("OPEN %d %s\n", FILEHANDLEID(pPager->fd), zFullPathname);
   IOTRACE(("OPEN %p %s\n", pPager, zFullPathname))
 
   /* Fill in Pager.zDirectory[] */
@@ -3753,6 +3753,7 @@ static int pager_write(PgHdr *pPg){
         }else{
           u32 cksum, saved;
           char *pData2, *pEnd;
+
           /* We should never write to the journal file the page that
           ** contains the database locks.  The following assert verifies
           ** that we do not. */
@@ -3870,6 +3871,7 @@ int sqlite3PagerWrite(DbPage *pDbPage){
     Pgno pg1;                 /* First page of the sector pPg is located on. */
     int nPage;                /* Number of pages starting at pg1 to journal */
     int ii;
+    int needSync = 0;
 
     /* Set the doNotSync flag to 1. This is because we cannot allow a journal
     ** header to be written between the pages journaled by this function.
@@ -3897,18 +3899,39 @@ int sqlite3PagerWrite(DbPage *pDbPage){
 
     for(ii=0; ii<nPage && rc==SQLITE_OK; ii++){
       Pgno pg = pg1+ii;
+      PgHdr *pPage;
       if( !pPager->aInJournal || pg==pPg->pgno || 
           pg>pPager->origDbSize || !(pPager->aInJournal[pg/8]&(1<<(pg&7)))
       ) {
         if( pg!=PAGER_MJ_PGNO(pPager) ){
-          PgHdr *pPage;
           rc = sqlite3PagerGet(pPager, pg, &pPage);
           if( rc==SQLITE_OK ){
             rc = pager_write(pPage);
+            if( pPage->needSync ){
+              needSync = 1;
+            }
             sqlite3PagerUnref(pPage);
           }
         }
+      }else if( (pPage = pager_lookup(pPager, pg)) ){
+        if( pPage->needSync ){
+          needSync = 1;
+        }
+      }
+    }
+
+    /* If the PgHdr.needSync flag is set for any of the nPage pages 
+    ** starting at pg1, then it needs to be set for all of them. Because
+    ** writing to any of these nPage pages may damage the others, the
+    ** journal file must contain sync()ed copies of all of them
+    ** before any of them can be written out to the database file.
+    */
+    if( needSync ){
+      for(ii=0; ii<nPage && needSync; ii++){
+        PgHdr *pPage = pager_lookup(pPager, pg1+ii);
+        if( pPage ) pPage->needSync = 1;
       }
+      assert(pPager->needSync);
     }
 
     assert( pPager->doNotSync==1 );