]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
If a call to sqlite3rbu_close() on an rbu handle opened by sqlite3rbu_vacuum() return... rbu-vacuum
authordan <dan@noemail.net>
Thu, 21 Apr 2016 16:44:38 +0000 (16:44 +0000)
committerdan <dan@noemail.net>
Thu, 21 Apr 2016 16:44:38 +0000 (16:44 +0000)
FossilOrigin-Name: 6e4ac704f51bdd1e0b16814f6a45ab29f26400ee

ext/rbu/rbuvacuum.test
ext/rbu/sqlite3rbu.c
ext/rbu/sqlite3rbu.h
manifest
manifest.uuid

index c67162c56729e59719f16559e45542b1433c0da7..96a37d1f712051484eff6e5be682143bbc73c68a 100644 (file)
@@ -19,7 +19,6 @@ set ::testprefix rbuvacuum
 
 proc do_rbu_vacuum_test {tn step} {
   uplevel [list do_test $tn.1 {
-    forcedelete state.db
     if {$step==0} { sqlite3rbu_vacuum rbu test.db state.db }
     while 1 {
       if {$step==1} { sqlite3rbu_vacuum rbu test.db state.db }
@@ -275,7 +274,6 @@ do_execsql_test 2.1.0 {
   INSERT INTO t1 VALUES(9, 10);
 } wal
 do_test 2.1.1 {
-  forcedelete state.db
   sqlite3rbu_vacuum rbu test.db state.db
   rbu step
 } {SQLITE_ERROR}
@@ -294,7 +292,6 @@ do_execsql_test 2.2.0 {
 }
 db_save_and_close
 for {set i 1} 1 {incr i} {
-  forcedelete state.db
   db_restore_and_reopen
 
   sqlite3rbu_vacuum rbu test.db state.db
index 04dc9944d722a3a9cadf63006ddcbca5c3bd5fd4..e7e4ddef58558bf964cfa5951fdf6844c59af2c8 100644 (file)
@@ -3685,6 +3685,16 @@ int sqlite3rbu_close(sqlite3rbu *p, char **pzErrmsg){
     /* Close any open statement handles. */
     rbuObjIterFinalize(&p->objiter);
 
+    /* If this is an RBU vacuum handle and the vacuum has either finished
+    ** successfully or encountered an error, delete the contents of the 
+    ** state table. This causes the next call to sqlite3rbu_vacuum() 
+    ** specifying the current target and state databases to start a new
+    ** vacuum from scratch.  */
+    if( rbuIsVacuum(p) && p->rc!=SQLITE_OK && p->dbRbu ){
+      int rc2 = sqlite3_exec(p->dbRbu, "DELETE FROM stat.rbu_state", 0, 0, 0);
+      if( p->rc==SQLITE_DONE && rc2!=SQLITE_OK ) p->rc = rc2;
+    }
+
     /* Close the open database handle and VFS object. */
     sqlite3_close(p->dbRbu);
     sqlite3_close(p->dbMain);
index c0c95e51fdfabd8c1f5cd13f951aa7ef8249d483..fce9e493db278525ffeff1fa0930c55cc07bac05 100644 (file)
@@ -330,7 +330,11 @@ sqlite3rbu *sqlite3rbu_open(
 ** handle specifying the same target and state databases.
 **
 ** This function does not delete the state database after an RBU vacuum
-** is completed, even if it created it.
+** is completed, even if it created it. However, if the call to
+** sqlite3rbu_close() returns any value other than SQLITE_OK, the contents
+** of the state tables within the state database are zeroed. This way,
+** the next call to sqlite3rbu_vacuum() opens a handle that starts a 
+** new RBU vacuum operation.
 **
 ** As with sqlite3rbu_open(), Zipvfs users should rever to the comment
 ** describing the sqlite3rbu_create_vfs() API function below for 
index dbe7f79adcec09bd36c1644a1273e3488a1c78d1..a1b6be3a3e5d7f2925de96981db8e556bec88740 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sproblem\sin\srbu\svacuum\son\stables\swith\sa\slarge\ssqlite_master\stable.
-D 2016-04-21T15:26:26.501
+C If\sa\scall\sto\ssqlite3rbu_close()\son\san\srbu\shandle\sopened\sby\ssqlite3rbu_vacuum()\sreturns\sother\sthan\sSQLITE_OK,\sdelete\sthe\scontents\sof\sthe\srbu_state\stable.\sThis\sensures\sthat\sif\san\sRBU\svacuum\soperation\seither\scompletes\ssuccessfully\sor\sencounters\san\serror,\sthe\snext\scall\sto\ssqlite3rbu_vacuum()\swith\sthe\ssame\sparameters\sstarts\sa\snew\sRBU\svacuum\soperation.
+D 2016-04-21T16:44:38.130
 F Makefile.in eba680121821b8a60940a81454316f47a341487a
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836
@@ -247,9 +247,9 @@ F ext/rbu/rbufault3.test 54a399888ac4af44c68f9f58afbed23149428bca
 F ext/rbu/rbufts.test 828cd689da825f0a7b7c53ffc1f6f7fdb6fa5bda
 F ext/rbu/rbuprogress.test 2023a7df2c523e3df1cb532eff811cda385a789a
 F ext/rbu/rbusave.test 0f43b6686084f426ddd040b878426452fd2c2f48
-F ext/rbu/rbuvacuum.test aa405cff38b15a89f6c97f91f1c6a67b2140b358
-F ext/rbu/sqlite3rbu.c 8310553b029e749329a89b3880a21f80876755c3
-F ext/rbu/sqlite3rbu.h efcafd0e36861943a88deb181753236f84dbc244
+F ext/rbu/rbuvacuum.test bcbc1dcd8e2a46a811e46477692ae1c0e8917a85
+F ext/rbu/sqlite3rbu.c 20922328dcebe89589638923bb46840df8bc7733
+F ext/rbu/sqlite3rbu.h 2acd0a6344a6079de15c8dc9d84d3df83a665930
 F ext/rbu/test_rbu.c 430b8b9520c233505371d564d3561e0b554355f4
 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
 F ext/rtree/rtree.c 0b870ccb7b58b734a2a8e1e2755a7c0ded070920
@@ -1484,7 +1484,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P da5c753ddac3cbfdf03710a82f5fd9fa2e29e819
-R e2636288f7318e2301180a849b5ff72b
+P 23eac52e987996afe8db847921aef434cebd25b5
+R 9f2af869b142a7169421543b9ca51ae8
 U dan
-Z d9d3e7dacedd64ed84574ca4c0316d8e
+Z 717b7e491d25b95d9f80b6c2df00ade7
index 8f13cab8e3ab666f30d1268af3e4aa33ab473c7a..ef1798e1f08cd5c76b8de4f4a1c3379b484a51bc 100644 (file)
@@ -1 +1 @@
-23eac52e987996afe8db847921aef434cebd25b5
\ No newline at end of file
+6e4ac704f51bdd1e0b16814f6a45ab29f26400ee
\ No newline at end of file