]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a bug whereby the database file was not always being extended to its original...
authordanielk1977 <danielk1977@noemail.net>
Tue, 6 May 2008 18:13:26 +0000 (18:13 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Tue, 6 May 2008 18:13:26 +0000 (18:13 +0000)
FossilOrigin-Name: 4a1ae9d0320de1013a3b5f24ebdd25fe9fdab424

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

index ec57091d4ac401ac8f9d19d2e33f95fa5d9b08c5..e2dc1d1ef1346cba06ee9b0d58efa63b0ad713b4 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sdefines\sfor\s_FILE_OFFSET_BITS\sand\s_LARGE_FILES\sif\sneeded\sfor\slarge\sfile\ssupport.\r\nTicket\s#3094.\s(CVS\s5088)
-D 2008-05-06T02:28:06
+C Fix\sa\sbug\swhereby\sthe\sdatabase\sfile\swas\snot\salways\sbeing\sextended\sto\sits\soriginal\ssize\swhen\srolling\sback\san\sincremental-vacuum\soperation.\s(CVS\s5089)
+D 2008-05-06T18:13:26
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
 F Makefile.in 25b3282a4ac39388632c2fb0e044ff494d490952
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -122,7 +122,7 @@ F src/os_common.h e8b748b2f2ecc8a498e50bfe5d8721f189c19d2a
 F src/os_os2.c 41015b3fa91568761eb10cbf6ca27a0624ba0bda
 F src/os_unix.c a810e2aefdaddacf479407f76f8f4ca381d231b2
 F src/os_win.c 3a60bddd07ea6f8adb2314dd5996ac97b988f403
-F src/pager.c 5ac6728cf575afd87f8c5afe88bb768d3a641e34
+F src/pager.c 22a5a810a3eadf8fe84c3de479def9c0dadc5ff8
 F src/pager.h 4f051fd856de6fd3c19aef5f82eace54122b9173
 F src/parse.y fc4bd35c6088901f7c8daead26c6fb11c87d22e7
 F src/pragma.c 2e4bb2e76e48a32750529fdc4bfe86ac5f54e01b
@@ -329,7 +329,7 @@ F test/incrblob.test 4455fffd08b2f9418a9257e18b135d72273eff3e
 F test/incrblob_err.test 5273097dc7c97f9b7008423a6ffd5c80d21923cb
 F test/incrvacuum.test 1a2b0bddc76629afeb41e3d8ea3e4563982d16b9
 F test/incrvacuum2.test a958e378c193c4012cb3787804d863487f1dfad1
-F test/incrvacuum_ioerr.test cb331403b8dea3c5bae6163861ff25037b0df56a
+F test/incrvacuum_ioerr.test 34297e36ef3399933064ee551ad55ba5d70c3a15
 F test/index.test cbf301cdb2da43e4eac636c3400c2439af1834ad
 F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6
 F test/index3.test 727d55dceb9a4ec36675057bb5becfc265e28ca6
@@ -633,7 +633,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 2b1e455c46a184311a3a2e83b4f9345d2e34f497
-R aeee347795b87311a03bea5b7b9f7cfb
-U mlcreech
-Z 9fe7bc0a77d0030fd1330ee7f5b6aea5
+P 729e2f06ba4030cc771fc876ddfd41866b8c0d93
+R 397af0a306f96b692c322e18ab9ae1dc
+U danielk1977
+Z 0d3268afef5fc245ffa4cec2f875eaa5
index e62c3fcd0d6a704606801178dad5fb66cd082576..cbea2858798abfe1c1ea2c63361dec3048379a6e 100644 (file)
@@ -1 +1 @@
-729e2f06ba4030cc771fc876ddfd41866b8c0d93
\ No newline at end of file
+4a1ae9d0320de1013a3b5f24ebdd25fe9fdab424
\ No newline at end of file
index fca3d3bc9e5666501056d34ae11f92cc7fbd45a7..dd691c2eebc3b0f098cf277eaadf2f12b3e5f338 100644 (file)
@@ -18,7 +18,7 @@
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
 **
-** @(#) $Id: pager.c,v 1.439 2008/05/05 16:23:55 danielk1977 Exp $
+** @(#) $Id: pager.c,v 1.440 2008/05/06 18:13:26 danielk1977 Exp $
 */
 #ifndef SQLITE_OMIT_DISKIO
 #include "sqliteInt.h"
@@ -1695,7 +1695,8 @@ static void pager_truncate_cache(Pager *pPager);
 ** in cache, then an INSERT or UPDATE does a statement rollback.  Some
 ** operating system implementations can get confused if you try to
 ** truncate a file to some size that is larger than it currently is,
-** so detect this case and do not do the truncation.
+** so detect this case and write a single zero byte to the end of the new
+** file instead.
 */
 static int pager_truncate(Pager *pPager, int nPage){
   int rc = SQLITE_OK;
@@ -1703,8 +1704,12 @@ static int pager_truncate(Pager *pPager, int nPage){
     i64 currentSize, newSize;
     rc = sqlite3OsFileSize(pPager->fd, &currentSize);
     newSize = pPager->pageSize*(i64)nPage;
-    if( rc==SQLITE_OK && currentSize>newSize ){
-      rc = sqlite3OsTruncate(pPager->fd, newSize);
+    if( rc==SQLITE_OK && currentSize!=newSize ){
+      if( currentSize>newSize ){
+        rc = sqlite3OsTruncate(pPager->fd, newSize);
+      }else{
+        rc = sqlite3OsWrite(pPager->fd, "", 1, newSize-1);
+      }
     }
   }
   if( rc==SQLITE_OK ){
index 9ee9e382573eeb1edecf39df6552a367fa6d909d..fdc38670819f913ac9fad62661156b96897e7af9 100644 (file)
@@ -15,7 +15,7 @@
 # The tests in this file use special facilities that are only
 # available in the SQLite test fixture.
 #
-# $Id: incrvacuum_ioerr.test,v 1.2 2007/05/04 18:30:41 drh Exp $
+# $Id: incrvacuum_ioerr.test,v 1.3 2008/05/06 18:13:26 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -37,7 +37,7 @@ do_ioerr_test incrvacuum-ioerr-1 -cksum 1 -sqlprep {
   DELETE FROM abc;
   PRAGMA incremental_vacuum;
   COMMIT;
-}
+} 
 
 # do_ioerr_test incrvacuum-ioerr-3 -start 1 -cksum 1 -tclprep {
 #   db eval {
@@ -60,7 +60,6 @@ do_ioerr_test incrvacuum-ioerr-1 -cksum 1 -sqlprep {
 #   COMMIT;
 # }
 
-
 do_ioerr_test incrvacuum-ioerr-2 -start 1 -cksum 1 -tclprep {
   db eval {
     PRAGMA auto_vacuum = 'full';
@@ -86,4 +85,24 @@ do_ioerr_test incrvacuum-ioerr-2 -start 1 -cksum 1 -tclprep {
   PRAGMA incremental_vacuum;
   COMMIT;
 }
+
+do_ioerr_test incrvacuum-ioerr-3 -start 1 -cksum 1 -tclprep {
+  db eval {
+    PRAGMA auto_vacuum = 'incremental';
+    BEGIN;
+    CREATE TABLE a(i integer, b blob);
+    INSERT INTO a VALUES(1, randstr(1500,1500));
+    INSERT INTO a VALUES(2, randstr(1500,1500));
+  }
+  db eval COMMIT
+  db eval {DELETE FROM a WHERE oid}
+} -sqlbody {
+  PRAGMA incremental_vacuum(5);
+} -cleanup {
+  sqlite3 db test.db
+  integrity_check incrvacuum-ioerr-2.$n.integritycheck
+  db close
+}
+
+
 finish_test