]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add some tests (and 2 resulting bug fixes) to incr vacuum mode. (CVS 3885)
authordanielk1977 <danielk1977@noemail.net>
Sat, 28 Apr 2007 15:47:43 +0000 (15:47 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Sat, 28 Apr 2007 15:47:43 +0000 (15:47 +0000)
FossilOrigin-Name: 89b1b3f897bda1fffceb9cf72fa4d42b809ccb8e

manifest
manifest.uuid
src/btree.c
src/pager.c
test/autovacuum_ioerr2.test
test/incrvacuum.test
test/incrvacuum_ioerr.test [new file with mode: 0644]
test/quick.test
test/tester.tcl

index 561012ca3477e3fe7f84b3f85996d4cc926d6871..067ed2bd7c857e3cf3105b7dfe861e870c876863 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Break\sinterior-node\sand\sleaf-node\sreaders\sapart\sin\sloadSegment().\nPreviously,\sthe\scode\slooped\suntil\sthe\sblock\swas\sa\sleaf\snode\sas\nindicated\sby\sa\sleading\sNUL.\s\sNow\sthe\scode\sloops\suntil\sit\sfinds\sa\sblock\nin\sthe\srange\sof\sleaf\snodes\sfor\sthis\ssegment,\sthen\sreads\sit\susing\nLeavesReader.\s\sThis\swill\smake\sit\seasier\sto\straverse\sa\srange\sof\sleaves\nwhen\sdoing\sa\sprefix\ssearch.\s(CVS\s3884)
-D 2007-04-27T22:02:58
+C Add\ssome\stests\s(and\s2\sresulting\sbug\sfixes)\sto\sincr\svacuum\smode.\s(CVS\s3885)
+D 2007-04-28T15:47:44
 F Makefile.in 8cab54f7c9f5af8f22fd97ddf1ecfd1e1860de62
 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -59,7 +59,7 @@ F src/alter.c 2c79ec40f65e33deaf90ca493422c74586e481a3
 F src/analyze.c 4bbf5ddf9680587c6d4917e02e378b6037be3651
 F src/attach.c a16ada4a4654a0d126b8223ec9494ebb81bc5c3c
 F src/auth.c 902f4722661c796b97f007d9606bd7529c02597f
-F src/btree.c 1e9261de4b663992604f089e6dbad6807e140b84
+F src/btree.c 066ca57368d814ba8940d926a491f70c6866033f
 F src/btree.h 4c0b5855cef3e4e6627358aa69541d21a2015947
 F src/build.c 02e01ec7907c7d947ab3041fda0e81eaed05db42
 F src/callback.c 6414ed32d55859d0f65067aa5b88d2da27b3af9e
@@ -87,7 +87,7 @@ F src/os_unix.c 426b4c03c304ad78746d65d9ba101e0b72e18e23
 F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
 F src/os_win.c e94903c7dc1c0599c8ddce42efa0b6928068ddc5
 F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
-F src/pager.c cd2770b0f8bd1900b46121009336e7ad03fb274f
+F src/pager.c 48b1ebe8c9bcd8a9544ebef13c85547f28e8bb6b
 F src/pager.h d652ddf092d2318d00e41f8539760fe8e57c157c
 F src/parse.y a3940369e12c69c4968aa580cdc74cf73a664980
 F src/pragma.c 4fdefc03c3fd0ee87f8aad82bf80ba9bf1cdf416
@@ -154,7 +154,7 @@ F test/autoinc.test 60005a676e3e4e17dfa9dbd08aa0b76587ff97e3
 F test/autovacuum.test 4339e66003b9cf813dd667a83aed2dee27c4c36d
 F test/autovacuum_crash.test 05a63b8805b20cfba7ace82856ce4ccdda075a31
 F test/autovacuum_ioerr.test c46a76869cb6eddbbb40b419b2b6c4c001766b1f
-F test/autovacuum_ioerr2.test 2f8a3fb31f833fd0ca86ad4ad98913c73e807572
+F test/autovacuum_ioerr2.test dc189f323cf0546289b5a9bbda60bcb1fe52bd4b
 F test/avtrans.test b77740800de0d2cdcf394ef94d2d61225a1941d8
 F test/between.test 16b1776c6323faadb097a52d673e8e3d8be7d070
 F test/bigfile.test ebc9ce9216e08bead63734ab816d0f27858f3b80
@@ -238,7 +238,8 @@ F test/fts2m.test 4b30142ead6f3ed076e880a2a464064c5ad58c51
 F test/func.test 8a3bc8e8365dc0053c826923c0f738645f50f2f5
 F test/hook.test 7e7645fd9a033f79cce8fdff151e32715e7ec50a
 F test/in.test 369cb2aa1eab02296b4ec470732fe8c131260b1d
-F test/incrvacuum.test fc5e88ac32095fb65ea11b739bc4e310c4852ef4
+F test/incrvacuum.test a4c9022d7b26b10495616cc5a255f11afb683be8
+F test/incrvacuum_ioerr.test 0ebc382bcc2036ec58cf49cc5ffada45f75d907b
 F test/index.test e65df12bed94b2903ee89987115e1578687e9266
 F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6
 F test/index3.test f66718cd92ce1216819d47e6a156755e4b2c4ca1
@@ -298,7 +299,7 @@ F test/pragma.test fecb7085f58d9fb5172a5c0b63fd3b25c7bfb414
 F test/printf.test 483b9fe75ffae1fb27328bdce5560b452ba83577
 F test/progress.test 8b22b4974b0a95272566385f8cb8c341c7130df8 x
 F test/ptrchng.test 1c712dd6516e1377471744fa765e41c79a357da6
-F test/quick.test 8e7ffe36a1c920cdcce5d641646abde2dafd764b
+F test/quick.test afa4339d08800d8aa3625df6cc2f059cc505f4c3
 F test/quote.test 215897dbe8de1a6f701265836d6601cc6ed103e6
 F test/rdonly.test b34db316525440d3b42c32e83942c02c37d28ef0
 F test/reindex.test 38b138abe36bf9a08c791ed44d9f76cd6b97b78b
@@ -329,7 +330,7 @@ F test/table.test feea6a3eb08cf166f570255eea5447e42ef82498
 F test/tableapi.test 036575a98dcce7c92e9f39056839bbad8a715412
 F test/tclsqlite.test 51334389283c74bcbe28645a73159b17e239e9f3
 F test/temptable.test c36f3e5a94507abb64f7ba23deeb4e1a8a8c3821
-F test/tester.tcl effe3dae968afd8bb27c8792883788eeba821942
+F test/tester.tcl dcebe3c5bf15f3b4ba015b4b2237030c1e384941
 F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35
 F test/thread2.test 6d7b30102d600f51b4055ee3a5a19228799049fb
 F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b
@@ -464,7 +465,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P ff1f4e744728c8f55afae265246797b30fe98fb0
-R 99c2fc3fe139fed22b3873b01510508d
-U shess
-Z 5fe07eef28bba3b5b8361756bba83b2b
+P 9466367d65f43d58020e709428268dc2ff98aa35
+R 7cca5d0f43767198fb71376aeea99069
+U danielk1977
+Z 03907aab221cf0da66dda4d095ab65a6
index 28127576846426bb18592247a798347e2d65a538..a4bc6b26fd52692988a14447fdee69d252f2954a 100644 (file)
@@ -1 +1 @@
-9466367d65f43d58020e709428268dc2ff98aa35
\ No newline at end of file
+89b1b3f897bda1fffceb9cf72fa4d42b809ccb8e
\ No newline at end of file
index b3ceb5ac5fd1386a56ef2e32803dc5a400e2a997..7be48daded3349c1b3c011fb4d6ee286c2879de4 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.360 2007/04/27 07:05:44 danielk1977 Exp $
+** $Id: btree.c,v 1.361 2007/04/28 15:47:44 danielk1977 Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** For a detailed discussion of BTrees, refer to
@@ -2366,6 +2366,13 @@ static int incrVacuumStep(BtShared *pBt, Pgno nFin){
         return rc;
       }
 
+      /* If nFin is zero, this loop runs exactly once and page pLastPg
+      ** is swapped with the first free page pulled off the free list.
+      **
+      ** On the other hand, if nFin is greater than zero, then keep
+      ** looping until a free-page located within the first nFin pages
+      ** of the file is found.
+      */
       do {
         MemPage *pFreePg;
         rc = allocateBtreePage(pBt, &pFreePg, &iFreePg, 0, 0);
@@ -2376,7 +2383,11 @@ static int incrVacuumStep(BtShared *pBt, Pgno nFin){
         releasePage(pFreePg);
       }while( nFin!=0 && iFreePg>nFin );
       assert( iFreePg<iLastPg );
-
+      
+      rc = sqlite3PagerWrite(pLastPg->pDbPage);
+      if( rc!=SQLITE_OK ){
+        return rc;
+      } 
       rc = relocatePage(pBt, pLastPg, eType, iPtrPage, iFreePg);
       releasePage(pLastPg);
       if( rc!=SQLITE_OK ){
@@ -2431,8 +2442,6 @@ static int autoVacuumCommit(BtShared *pBt, Pgno *pnTrunc){
   if( !pBt->incrVacuum ){
     Pgno nFin = 0;
 
-
-
     if( pBt->nTrunc==0 ){
       Pgno nFree;
       Pgno nPtrmap;
index 032902499b932de57aee386a28a2cee496e6c782..228455a141c062a4b256fc83f0ce96c953a95058 100644 (file)
@@ -18,7 +18,7 @@
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
 **
-** @(#) $Id: pager.c,v 1.330 2007/04/26 12:11:28 drh Exp $
+** @(#) $Id: pager.c,v 1.331 2007/04/28 15:47:44 danielk1977 Exp $
 */
 #ifndef SQLITE_OMIT_DISKIO
 #include "sqliteInt.h"
@@ -3061,6 +3061,7 @@ int sqlite3PagerAcquire(
         sqlite3PagerUnref(pPg);
         return rc;
       }
+      pPg->needRead = 0;
     }
 
     /* Link the page into the page hash table */
@@ -4210,6 +4211,7 @@ int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno){
       PAGERID(pPager), pPg->pgno, pPg->needSync, pgno);
   IOTRACE(("MOVE %p %d %d\n", pPager, pPg->pgno, pgno))
 
+  pager_get_content(pPg);
   if( pPg->needSync ){
     needSyncPgno = pPg->pgno;
     assert( pPg->inJournal );
index 4dde422338a4b9dd0994b57581416435ac8987d3..3eb549d246a7e821f411eed5fad37e980ca6d918 100644 (file)
@@ -15,7 +15,7 @@
 # The tests in this file use special facilities that are only
 # available in the SQLite test fixture.
 #
-# $Id: autovacuum_ioerr2.test,v 1.5 2005/01/29 09:14:05 danielk1977 Exp $
+# $Id: autovacuum_ioerr2.test,v 1.6 2007/04/28 15:47:44 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -116,5 +116,18 @@ ifcapable subquery {
   }
 }
 
+do_ioerr_test autovacuum-ioerr2-1 -sqlprep {
+  PRAGMA auto_vacuum = 1;
+  CREATE TABLE abc(a);
+  INSERT INTO abc VALUES(randstr(1500,1500));
+} -sqlbody {
+  CREATE TABLE abc2(a);
+  BEGIN;
+  DELETE FROM abc;
+  INSERT INTO abc VALUES(randstr(1500,1500));
+  CREATE TABLE abc3(a);
+  COMMIT;
+}
+
 finish_test
 
index 912769858ed0890957205754cb913153c9826725..78c6d742ec683a3fffbc1629a18bc87038d7d1ef 100644 (file)
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the incremental vacuum feature.
 #
-# $Id: incrvacuum.test,v 1.3 2007/04/27 07:55:38 danielk1977 Exp $
+# Note: There are also some tests for incremental vacuum and IO 
+# errors in incrvacuum_ioerr.test.
+#
+# $Id: incrvacuum.test,v 1.4 2007/04/28 15:47:44 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
diff --git a/test/incrvacuum_ioerr.test b/test/incrvacuum_ioerr.test
new file mode 100644 (file)
index 0000000..8bdcda3
--- /dev/null
@@ -0,0 +1,90 @@
+# 2001 October 12
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.  The
+# focus of this file is testing for correct handling of I/O errors
+# such as writes failing because the disk is full.
+# 
+# The tests in this file use special facilities that are only
+# available in the SQLite test fixture.
+#
+# $Id: incrvacuum_ioerr.test,v 1.1 2007/04/28 15:47:45 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# If this build of the library does not support auto-vacuum, omit this
+# whole file.
+ifcapable {!autovacuum} {
+  finish_test
+  return
+}
+
+do_ioerr_test incrvacuum-ioerr-1 -cksum 1 -sqlprep {
+  PRAGMA auto_vacuum = 'incremental';
+  CREATE TABLE abc(a);
+  INSERT INTO abc VALUES(randstr(1500,1500));
+} -sqlbody {
+  BEGIN;
+  CREATE TABLE abc2(a);
+  DELETE FROM abc;
+  INCREMENTAL VACUUM;
+  COMMIT;
+}
+
+# do_ioerr_test incrvacuum-ioerr-3 -start 1 -cksum 1 -tclprep {
+#   db eval {
+#     PRAGMA auto_vacuum = 'full';
+#     PRAGMA cache_size = 10;
+#     BEGIN;
+#     CREATE TABLE abc(a, UNIQUE(a));
+#   }
+#   for {set ii 0} {$ii < 25} {incr ii} {
+#     db eval {INSERT INTO abc VALUES(randstr(1500,1500))}
+#   }
+#   db eval COMMIT
+# } -sqlbody {
+#   BEGIN;
+#   DELETE FROM abc WHERE (oid%3)==0;
+#   INSERT INTO abc SELECT a || '1234567890' FROM abc WHERE oid%2;
+#   CREATE INDEX abc_i ON abc(a);
+#   DELETE FROM abc WHERE (oid%2)==0;
+#   DROP INDEX abc_i;
+#   COMMIT;
+# }
+
+
+do_ioerr_test incrvacuum-ioerr-2 -start 1 -cksum 1 -tclprep {
+  db eval {
+    PRAGMA auto_vacuum = 'full';
+    PRAGMA cache_size = 10;
+    BEGIN;
+    CREATE TABLE abc(a, UNIQUE(a));
+  }
+  for {set ii 0} {$ii < 25} {incr ii} {
+    db eval {INSERT INTO abc VALUES(randstr(1500,1500))}
+  }
+  db eval COMMIT
+} -sqlbody {
+  BEGIN;
+  INCREMENTAL VACUUM;
+  DELETE FROM abc WHERE (oid%3)==0;
+  INCREMENTAL VACUUM;
+  INSERT INTO abc SELECT a || '1234567890' FROM abc WHERE oid%2;
+  INCREMENTAL VACUUM;
+  CREATE INDEX abc_i ON abc(a);
+  DELETE FROM abc WHERE (oid%2)==0;
+  INCREMENTAL VACUUM;
+  DROP INDEX abc_i;
+  INCREMENTAL VACUUM;
+  COMMIT;
+}
+finish_test
+
index 55db5cfdc7496ac5b63e68afe089c3b87affcd6f..44b9c6f9a8bdf2f4b1e64696ecf559d1164ac371 100644 (file)
@@ -6,7 +6,7 @@
 #***********************************************************************
 # This file runs all tests.
 #
-# $Id: quick.test,v 1.52 2007/04/16 17:07:55 drh Exp $
+# $Id: quick.test,v 1.53 2007/04/28 15:47:45 danielk1977 Exp $
 
 proc lshift {lvar} {
   upvar $lvar l
@@ -56,6 +56,7 @@ set EXCLUDE {
   speed1.test
   speed2.test
 
+  incrvacuum_ioerr.test
   autovacuum_crash.test
   btree8.test
   utf16.test
index 17f6b4d206c3a762df7ed049dac892e62a045343..aed7446719e6c3d1ad3decacf01c18632beb54a0 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements some common TCL routines used for regression
 # testing the SQLite library
 #
-# $Id: tester.tcl,v 1.79 2007/04/19 12:30:54 drh Exp $
+# $Id: tester.tcl,v 1.80 2007/04/28 15:47:45 danielk1977 Exp $
 
 # Make sure tclsqlite3 was compiled correctly.  Abort now with an
 # error message if not.
@@ -399,6 +399,7 @@ proc do_ioerr_test {testname args} {
 
   set ::go 1
   for {set n $::ioerropts(-start)} {$::go} {incr n} {
+set ::TN $n
     incr ::ioerropts(-count) -1
     if {$::ioerropts(-count)<0} break