]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Improve coverage of pager.c and fix an IO error handling bug found in the process...
authordanielk1977 <danielk1977@noemail.net>
Mon, 23 Jan 2006 13:09:45 +0000 (13:09 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Mon, 23 Jan 2006 13:09:45 +0000 (13:09 +0000)
FossilOrigin-Name: 6ec8e6b7856a0b394b8497ab9166b882f98124ba

manifest
manifest.uuid
src/pager.c
src/vdbe.c
test/pager.test
test/shared_err.test

index 3c1afefe7c121f7bed20ce7407fe9456afb92ba0..085e4c225b3e5c4c866de15a982d50ddd90a2925 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sadditional\scompiler\swarnings.\s\sTickets\s#1615,\s#1616,\s#1627\s(CVS\s2994)
-D 2006-01-23T13:00:36
+C Improve\scoverage\sof\spager.c\sand\sfix\san\sIO\serror\shandling\sbug\sfound\sin\sthe\sprocess.\s(CVS\s2995)
+D 2006-01-23T13:09:46
 F Makefile.in ab3ffd8d469cef4477257169b82810030a6bb967
 F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -59,7 +59,7 @@ F src/os_unix.c 38a55e51fb2c6f32c0ce86d274f5787f6c3668ed
 F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
 F src/os_win.c 98e4e38db7d4a00647b2bb1c60d28b7ca5034c03
 F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
-F src/pager.c 0f1565938ca972490ff72a8dc0a90d3a1d563883
+F src/pager.c 184a3045ff5243458f2fff41f0b8d2524da39660
 F src/pager.h e0acb095b3ad0bca48f2ab00c87346665643f64f
 F src/parse.y 83df51fea35f68f7e07384d75dce83d1ed30434c
 F src/pragma.c 4496cc77dc35824e1c978c3d1413b8a5a4c777d3
@@ -87,7 +87,7 @@ F src/update.c 14be4ba2f438919b4217085c02feff569e6cf1f2
 F src/utf.c 5ab8ca05d4e9ec81174b010f01ab12a232f0087d
 F src/util.c 8c2e824e0bab3e5d1673213235e5dc0bdec441d4
 F src/vacuum.c 3865673cc66acd0717ecd517f6b8fdb2a5e7924b
-F src/vdbe.c e04bf3035a7dc547e80ba1130a716a7e8c9f7c93
+F src/vdbe.c 1b50083eb941eab37ffa220fdc47cf0965a7f176
 F src/vdbe.h 8729a4ee16ff9aeab2af9667df3cf300ff978e13
 F src/vdbeInt.h eb3f86ab08ef11635bc78eb88c3ff13f923c233b
 F src/vdbeapi.c dcb2636f49b4807e34960d52a2fc257b3a751140
@@ -204,7 +204,7 @@ F test/misc5.test cff0e9ff3a79c5116d5bce077a0bacf9bb300324
 F test/misuse.test 30b3a458e5a70c31e74c291937b6c82204c59f33
 F test/notnull.test 44d600f916b770def8b095a9962dbe3be5a70d82
 F test/null.test 9503e1f63e959544c006d9f01709c5b5eab67d54
-F test/pager.test 1579e8f07291ae8e24db62ffade5c101c3e76597
+F test/pager.test cc1f516a87440487e83f480de9e942518b3e3fc1
 F test/pager2.test 49c0f57c7da0b060f0486b85fdd074025caa694e
 F test/pager3.test 2323bf27fd5bd887b580247e5bce500ceee994b4
 F test/pagesize.test 05c74ea49f790734ec1e9ab765d9bf1cce79b8f2
@@ -228,7 +228,7 @@ F test/select7.test 1bf795b948c133a15a2a5e99d3270e652ec58ce6
 F test/server1.test e328b8e641ba8fe9273132cfef497383185dc1f5
 F test/shared.test 8f8bc93c23b45ec63e1b11b8f3d8d018af47a58b
 F test/shared2.test 909fc0f0277684ed29cc1b36c8e159188aec7f28
-F test/shared_err.test ceb93bac112bcb1a6e57f5da56feae953148a543
+F test/shared_err.test 245a87e980db0042da81279fd615e70edffc20b6
 F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5
 F test/subquery.test ae324ee928c5fb463a3ce08a8860d6e7f1ca5797
 F test/subselect.test 2d13fb7f450db3595adcdd24079a0dd1d2d6abc2
@@ -344,7 +344,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P f58bbdc0ac6e618686c598aaafb3a41b972e078e
-R 0db26160e071e13e253b47ccdbdc4fe3
-U drh
-Z bfce48ac39b5c5b64554076983aa10ce
+P 6385628edd79187dff1687815d0101c31248e54f
+R 80ef760a1dd0cc6379cc9e976317f3a0
+U danielk1977
+Z 3aafcdd526d06e6968e5956fe796cd4a
index 826610e05eea0ef6d25fc774dbe42973142988b2..b181e1876855ea99eb14fac348dc72caf2079c9d 100644 (file)
@@ -1 +1 @@
-6385628edd79187dff1687815d0101c31248e54f
\ No newline at end of file
+6ec8e6b7856a0b394b8497ab9166b882f98124ba
\ No newline at end of file
index 7fc5ef05fc70abc073b5c74ea7c9ec35ce953ea2..08e9b4a31a99099b63ecf0cadf08d943bf029096 100644 (file)
@@ -18,7 +18,7 @@
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
 **
-** @(#) $Id: pager.c,v 1.249 2006/01/21 12:08:54 danielk1977 Exp $
+** @(#) $Id: pager.c,v 1.250 2006/01/23 13:09:46 danielk1977 Exp $
 */
 #ifndef SQLITE_OMIT_DISKIO
 #include "sqliteInt.h"
@@ -2642,7 +2642,7 @@ int sqlite3pager_get(Pager *pPager, Pgno pgno, void **ppPage){
     }else{
       rc = pager_recycle(pPager, 1, &pPg);
       if( rc!=SQLITE_OK ){
-        return pager_error(pPager, rc);
+        return rc;
       }
       assert(pPg) ;
     }
@@ -2665,14 +2665,8 @@ int sqlite3pager_get(Pager *pPager, Pgno pgno, void **ppPage){
     pPg->dirty = 0;
     pPg->nRef = 1;
     REFINFO(pPg);
+
     pPager->nRef++;
-    h = pager_hash(pgno);
-    pPg->pNextHash = pPager->aHash[h];
-    pPager->aHash[h] = pPg;
-    if( pPg->pNextHash ){
-      assert( pPg->pNextHash->pPrevHash==0 );
-      pPg->pNextHash->pPrevHash = pPg;
-    }
     if( pPager->nExtra>0 ){
       memset(PGHDR_TO_EXTRA(pPg, pPager), 0, pPager->nExtra);
     }
@@ -2681,6 +2675,10 @@ int sqlite3pager_get(Pager *pPager, Pgno pgno, void **ppPage){
       rc = pPager->errCode;
       return rc;
     }
+
+    /* Populate the page with data, either by reading from the database
+    ** file, or by setting the entire page to zero.
+    */
     if( sqlite3pager_pagecount(pPager)<(int)pgno ){
       memset(PGHDR_TO_DATA(pPg), 0, pPager->pageSize);
     }else{
@@ -2712,6 +2710,16 @@ int sqlite3pager_get(Pager *pPager, Pgno pgno, void **ppPage){
         TEST_INCR(pPager->nRead);
       }
     }
+
+    /* Link the page into the page hash table */
+    h = pager_hash(pgno);
+    pPg->pNextHash = pPager->aHash[h];
+    pPager->aHash[h] = pPg;
+    if( pPg->pNextHash ){
+      assert( pPg->pNextHash->pPrevHash==0 );
+      pPg->pNextHash->pPrevHash = pPg;
+    }
+
 #ifdef SQLITE_CHECK_PAGES
     pPg->pageHash = pager_pagehash(pPg);
 #endif
@@ -3036,12 +3044,6 @@ int sqlite3pager_write(void *pData){
           ** transaction will be rolled back by the layer above.
           */
           if( rc!=SQLITE_OK ){
-#if 0
-            sqlite3pager_rollback(pPager);
-            if( !pPager->errCode ){
-              pager_error(pPager, SQLITE_FULL);
-            }
-#endif
             return rc;
           }
 
@@ -3088,10 +3090,6 @@ int sqlite3pager_write(void *pData){
         TRACE3("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno);
         CODEC(pPager, pData, pPg->pgno, 0);
         if( rc!=SQLITE_OK ){
-          sqlite3pager_rollback(pPager);
-          if( !pPager->errCode ){
-            pager_error(pPager, SQLITE_FULL);
-          }
           return rc;
         }
         pPager->stmtNRec++;
@@ -3386,11 +3384,6 @@ int sqlite3pager_rollback(Pager *pPager){
   }else{
     rc = pager_playback(pPager);
   }
-#if 0
-  if( rc!=SQLITE_OK ){
-    rc = SQLITE_CORRUPT_BKPT;
-  }
-#endif
   pPager->dbSize = -1;
 
   /* If an error occurs during a ROLLBACK, we can no longer trust the pager
index 5c5cf04948f147a076fdd7edb24a08c90ec38937..0f24fb68ec1f83be4da3f8a490a809b722b694d8 100644 (file)
@@ -43,7 +43,7 @@
 ** in this file for details.  If in doubt, do not deviate from existing
 ** commenting and indentation practices when changing or adding code.
 **
-** $Id: vdbe.c,v 1.535 2006/01/23 00:04:55 drh Exp $
+** $Id: vdbe.c,v 1.536 2006/01/23 13:09:46 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -3705,9 +3705,9 @@ case OP_IdxDelete: {        /* no-push */
   assert( i>=0 && i<p->nCursor );
   assert( p->apCsr[i]!=0 );
   if( (pCrsr = (pC = p->apCsr[i])->pCursor)!=0 ){
-    int rx, res;
-    rx = sqlite3BtreeMoveto(pCrsr, pTos->z, pTos->n, &res);
-    if( rx==SQLITE_OK && res==0 ){
+    int res;
+    rc = sqlite3BtreeMoveto(pCrsr, pTos->z, pTos->n, &res);
+    if( rc==SQLITE_OK && res==0 ){
       rc = sqlite3BtreeDelete(pCrsr);
     }
     assert( pC->deferredMoveto==0 );
index a7331675d77e8c3160aeb8c1c50e7bad4909fa78..c3a369a120b305d1147e86e154ce33087a430708 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this script is page cache subsystem.
 #
-# $Id: pager.test,v 1.23 2005/01/22 03:39:39 danielk1977 Exp $
+# $Id: pager.test,v 1.24 2006/01/23 13:09:47 danielk1977 Exp $
 
 
 set testdir [file dirname $argv0]
@@ -518,8 +518,28 @@ do_test pager-6.3 {
   }
 } {{CREATE TABLE abc(a, b, c)}}
 
-do_test pager-6.4 {
+do_test pager-6.4.1 {
+  execsql {
+    BEGIN;
+    SELECT sql FROM sqlite_master;
+  }
+  copy_file test2.db-journal test.db-journal;
+  sqlite3 db3 test.db
+  catchsql {
+    BEGIN;
+    SELECT sql FROM sqlite_master;
+  } db3;
+} {1 {database is locked}}
+do_test pager-6.4.2 {
+  file delete -force test.db-journal
+  catchsql {
+    SELECT sql FROM sqlite_master;
+  } db3;
+} {0 {{CREATE TABLE abc(a, b, c)}}}
+
+do_test pager-6.5 {
   db2 close
+  db3 close
 } {}
 }
 finish_test
index 296c743bbab3ed11911676b24542f473058b506c..3f954c6824a5512bafc0daebede5006ab860011d 100644 (file)
@@ -13,7 +13,7 @@
 # cache context. What happens to connection B if one connection A encounters
 # an IO-error whilst reading or writing the file-system?
 #
-# $Id: shared_err.test,v 1.4 2006/01/23 05:50:58 danielk1977 Exp $
+# $Id: shared_err.test,v 1.5 2006/01/23 13:09:47 danielk1977 Exp $
 
 proc skip {args} {}
 
@@ -250,7 +250,10 @@ do_ioerr_test shared_ioerr-3 -tclprep {
 
 } -tclbody {
   execsql {
+    BEGIN;
     INSERT INTO t1 VALUES('201.201.201.201.201', NULL);
+    UPDATE t1 SET a = '202.202.202.202.202' WHERE a LIKE '201%';
+    COMMIT;
   }
 } -cleanup {
   do_test shared_ioerr-3.$n.cleanup.1 {