]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix more bugs. The new rollback journal implementation now passes all
authordrh <drh@noemail.net>
Sun, 16 Feb 2003 19:13:36 +0000 (19:13 +0000)
committerdrh <drh@noemail.net>
Sun, 16 Feb 2003 19:13:36 +0000 (19:13 +0000)
regression tests under Linux. (CVS 867)

FossilOrigin-Name: d10adc1c5727d76320d5919be55e86d030e9c8bc

manifest
manifest.uuid
src/pager.c
src/test1.c
test/pager.test

index 1d95a7208c91982518356d80e7e328500ea1cac2..5edbc8d861f4fc8e067dcb6cd3e757690b313838 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sthe\spager\sso\sthat\scorrect\srollbacks\soccur\swhen\ssynchronous\sis\sturned\soff.\r\nThis\scheck-in\salso\sincluded\sunrelated\sdocumentation\supdates.\s(CVS\s866)
-D 2003-02-15T23:09:17
+C Fix\smore\sbugs.\s\sThe\snew\srollback\sjournal\simplementation\snow\spasses\sall\nregression\stests\sunder\sLinux.\s(CVS\s867)
+D 2003-02-16T19:13:37
 F Makefile.in 6606854b1512f185b8e8c779b8d7fc2750463d64
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -33,7 +33,7 @@ F src/main.c f88dfe09ed79588899cb4013836dd940f73a17fa
 F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565
 F src/os.c ed27e178e0c4b71f2807da81b8851f0fadc50778
 F src/os.h afa3e096213bad86845f8bdca81a9e917505e401
-F src/pager.c bffccf853a20032d89b592572309ea8a15a7f3ed
+F src/pager.c 47509f6b2dbf1cba46e52602c1dacf04f9d66e10
 F src/pager.h e5b8e301a732007766dc04880c764d7ee1aa34dd
 F src/parse.y cdaed5009423d851708848bd279147c268e6022e
 F src/printf.c f8fd911a8738f9b2eb07aca2870473d34707055d
@@ -45,7 +45,7 @@ F src/sqlite.h.in 6f648803f2ffb9beb35cb1cfa42b323d55519171
 F src/sqliteInt.h 2ae2c24fde8f7bb8040db964223d6e551e979358
 F src/table.c eed2098c9b577aa17f8abe89313a9c4413f57d63
 F src/tclsqlite.c 8167d40fd34036701e07492d07a6f9e5c4015241
-F src/test1.c eb05abd3ec6822f800476c04aed4db112690b144
+F src/test1.c 99add9d634a4e67790d71da02c12a83c69384697
 F src/test2.c 5014337d8576b731cce5b5a14bec4f0daf432700
 F src/test3.c c12ea7f1c3fbbd58904e81e6cb10ad424e6fc728
 F src/threadtest.c d641a5219e718e18a1a80a50eb9bb549f451f42e
@@ -89,7 +89,7 @@ F test/misc1.test 2876987a723b4053db081069007cd6aadf80b62b
 F test/misuse.test a3aa2b18a97e4c409a1fcaff5151a4dd804a0162
 F test/notnull.test 7a08117a71e74b0321aaa937dbeb41a09d6eb1d0
 F test/null.test 5c2b57307e4b6178aae825eb65ddbee01e76b0fd
-F test/pager.test d3a2e2f00999f97e056822a39d5ee2fad18bf12c
+F test/pager.test dd31da9bee94a82e2e87e58cf286cfe809f8fc5f
 F test/pragma.test d45d130f532bfe86ebd5ba74862d88b36ded8998
 F test/printf.test a29b8afa24edb4411adfe473b12ac32c84098fce
 F test/quick.test b372c8dad4fa1554747e90683fc72e59c0c98502
@@ -155,7 +155,7 @@ F www/speed.tcl 4d463e2aea41f688ed320a937f93ff885be918c3
 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P dc53d92141c931fb133149355c3a1ea64030e676
-R 571b9c5813a6dfc27b61cc9c2ebc6b12
+P 3ef0ad8a4f2696a58aff9d812f90038c2c63f3fc
+R cc7da005c4e40adf620f5417209a13cc
 U drh
-Z b201cdfd990195584437ce2ba1bc7248
+Z 54bed9eac4c6092a2059a4c6f2fdfdc6
index 3c9eee23a5184eb7c3c5a0c6df232ffaf5ee7021..f01a13d7e5dcee4e0e00134ad1279c5e7fe96880 100644 (file)
@@ -1 +1 @@
-3ef0ad8a4f2696a58aff9d812f90038c2c63f3fc
\ No newline at end of file
+d10adc1c5727d76320d5919be55e86d030e9c8bc
\ No newline at end of file
index afe03a855cf8c0a9c810e8813a354ec4b73b251f..bd191d6e1d68f7e7cdc093f525c3ba4bda97c46e 100644 (file)
@@ -18,7 +18,7 @@
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
 **
-** @(#) $Id: pager.c,v 1.77 2003/02/15 23:09:17 drh Exp $
+** @(#) $Id: pager.c,v 1.78 2003/02/16 19:13:37 drh Exp $
 */
 #include "os.h"         /* Must be first to enable large file support */
 #include "sqliteInt.h"
@@ -484,9 +484,9 @@ static int pager_playback_one_page(Pager *pPager, OsFile *jfd, int format){
   u32 cksum;
 
   rc = read32bits(format, jfd, &pgRec.pgno);
-  if( rc!=SQLITE_OK ) return SQLITE_DONE;
+  if( rc!=SQLITE_OK ) return rc;
   rc = sqliteOsRead(jfd, &pgRec.aData, sizeof(pgRec.aData));
-  if( rc!=SQLITE_OK ) return SQLITE_DONE;
+  if( rc!=SQLITE_OK ) return rc;
 
   /* Sanity checking on the page.  This is more important that I originally
   ** thought.  If a power failure occurs while the journal is being written,
@@ -501,7 +501,7 @@ static int pager_playback_one_page(Pager *pPager, OsFile *jfd, int format){
   }
   if( format>=JOURNAL_FORMAT_3 ){
     rc = read32bits(format, jfd, &cksum);
-    if( rc ) return SQLITE_DONE;
+    if( rc ) return rc;
     if( pager_cksum(pPager, pgRec.pgno, pgRec.aData)!=cksum ){
       return SQLITE_DONE;
     }
@@ -511,11 +511,9 @@ static int pager_playback_one_page(Pager *pPager, OsFile *jfd, int format){
   ** at the same time, if there is one.
   */
   pPg = pager_lookup(pPager, pgRec.pgno);
-  if( pPg==0 || pPg->needSync==0 ){
-    TRACE2("PLAYBACK %d\n", pgRec.pgno);
-    sqliteOsSeek(&pPager->fd, (pgRec.pgno-1)*(off_t)SQLITE_PAGE_SIZE);
-    rc = sqliteOsWrite(&pPager->fd, pgRec.aData, SQLITE_PAGE_SIZE);
-  }
+  TRACE2("PLAYBACK %d\n", pgRec.pgno);
+  sqliteOsSeek(&pPager->fd, (pgRec.pgno-1)*(off_t)SQLITE_PAGE_SIZE);
+  rc = sqliteOsWrite(&pPager->fd, pgRec.aData, SQLITE_PAGE_SIZE);
   if( pPg ){
     if( pPg->nRef==0 ||
         memcmp(PGHDR_TO_DATA(pPg), pgRec.aData, SQLITE_PAGE_SIZE)==0
@@ -556,7 +554,7 @@ static int pager_playback_one_page(Pager *pPager, OsFile *jfd, int format){
 ** pPager->errMask and SQLITE_CORRUPT is returned.  If it all
 ** works, then this routine returns SQLITE_OK.
 */
-static int pager_playback(Pager *pPager){
+static int pager_playback(Pager *pPager, int useJournalSize){
   off_t szJ;               /* Size of the journal file in bytes */
   int nRec;                /* Number of Records in the journal */
   int i;                   /* Loop counter */
@@ -601,7 +599,7 @@ static int pager_playback(Pager *pPager){
     if( rc ) goto end_playback;
     rc = read32bits(format, &pPager->jfd, &pPager->cksumInit);
     if( rc ) goto end_playback;
-    if( nRec==0xffffffff ){
+    if( nRec==0xffffffff || useJournalSize ){
       nRec = (szJ - JOURNAL_HDR_SZ(3))/JOURNAL_PG_SZ(3);
     }
   }else{
@@ -1066,7 +1064,8 @@ static int syncAllPages(Pager *pPager){
           if( rc!=0 ) return rc;
         }
         sqliteOsSeek(&pPager->jfd, sizeof(aJournalMagic1));
-        write32bits(&pPager->jfd, pPager->nRec);
+        rc = write32bits(&pPager->jfd, pPager->nRec);
+        if( rc ) return rc;
         szJ = JOURNAL_HDR_SZ(journal_format) +
                  pPager->nRec*JOURNAL_PG_SZ(journal_format);
         sqliteOsSeek(&pPager->jfd, szJ);
@@ -1225,7 +1224,7 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){
        /* Playback and delete the journal.  Drop the database write
        ** lock and reacquire the read lock.
        */
-       rc = pager_playback(pPager);
+       rc = pager_playback(pPager, 0);
        if( rc!=SQLITE_OK ){
          return rc;
        }
@@ -1661,12 +1660,12 @@ int sqlitepager_write(void *pData){
       if( journal_format>=JOURNAL_FORMAT_3 ){
         *(u32*)PGHDR_TO_EXTRA(pPg) = saved;
       }
-      pPager->nRec++;
       if( rc!=SQLITE_OK ){
         sqlitepager_rollback(pPager);
         pPager->errMask |= PAGER_ERR_FULL;
         return rc;
       }
+      pPager->nRec++;
       assert( pPager->aInJournal!=0 );
       pPager->aInJournal[pPg->pgno/8] |= 1<<(pPg->pgno&7);
       pPg->needSync = !pPager->noSync;
@@ -1881,14 +1880,14 @@ int sqlitepager_rollback(Pager *pPager){
 
   if( pPager->errMask!=0 && pPager->errMask!=PAGER_ERR_FULL ){
     if( pPager->state>=SQLITE_WRITELOCK ){
-      pager_playback(pPager);
+      pager_playback(pPager, 1);
     }
     return pager_errcode(pPager);
   }
   if( pPager->state!=SQLITE_WRITELOCK ){
     return SQLITE_OK;
   }
-  rc = pager_playback(pPager);
+  rc = pager_playback(pPager, 1);
   if( rc!=SQLITE_OK ){
     rc = SQLITE_CORRUPT;
     pPager->errMask |= PAGER_ERR_CORRUPT;
index 9a0c7cdefcd3df2257ba801aa79a536afbbf984a..232259fcfc980a6be29532f37f990f8439f6f651 100644 (file)
@@ -13,7 +13,7 @@
 ** is not included in the SQLite library.  It is used for automated
 ** testing of the SQLite library.
 **
-** $Id: test1.c,v 1.20 2003/01/29 22:58:26 drh Exp $
+** $Id: test1.c,v 1.21 2003/02/16 19:13:37 drh Exp $
 */
 #include "sqliteInt.h"
 #include "tcl.h"
@@ -826,6 +826,28 @@ static int test_finalize(
   return TCL_OK;
 }
 
+/*
+** Usage:    breakpoint
+**
+** This routine exists for one purpose - to provide a place to put a
+** breakpoint with GDB that can be triggered using TCL code.  The use
+** for this is when a particular test fails on (say) the 1485th iteration.
+** In the TCL test script, we can add code like this:
+**
+**     if {$i==1485} breakpoint
+**
+** Then run testfixture in the debugger and wait for the breakpoint to
+** fire.  Then additional breakpoints can be set to trace down the bug.
+*/
+static int test_breakpoint(
+  void *NotUsed,
+  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
+  int argc,              /* Number of arguments */
+  char **argv            /* Text of each argument */
+){
+  return TCL_OK;         /* Do nothing */
+}
+
 /*
 ** Register commands with the TCL interpreter.
 */
@@ -858,6 +880,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
      { "sqlite_compile",                 (Tcl_CmdProc*)test_compile          },
      { "sqlite_step",                    (Tcl_CmdProc*)test_step             },
      { "sqlite_finalize",                (Tcl_CmdProc*)test_finalize         },
+     { "breakpoint",                     (Tcl_CmdProc*)test_breakpoint       },
   };
   int i;
 
index 08cef675e0f13999abcd412d1a80fdee8f30bee9..6704ed32536d8660fc36326b79a6fcef09a8c98e 100644 (file)
 # This file implements regression tests for SQLite library.  The
 # focus of this script is page cache subsystem.
 #
-# $Id: pager.test,v 1.12 2003/01/11 14:19:52 drh Exp $
+# $Id: pager.test,v 1.13 2003/02/16 19:13:37 drh Exp $
 
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
 
 if {[info commands pager_open]!=""} {
+db close
 
 # Basic sanity check.  Open and close a pager.
 #
@@ -174,6 +175,8 @@ do_test pager-2.28 {
   lappend v $msg
 } {0 {}}
 do_test pager-2.29 {
+  page_unref $::g1
+  set ::g1 [page_get $::p1 1]
   page_read $::g1
 } {Page-One}
 do_test pager-2.99 {