From: dan Date: Thu, 3 Jan 2019 15:17:01 +0000 (+0000) Subject: Fix a problem with the second and subsequent sqlite3rbu_savestate() calls made X-Git-Tag: version-3.27.0~214 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0d756cc83a889e95871e974c6184fc35953c2f92;p=thirdparty%2Fsqlite.git Fix a problem with the second and subsequent sqlite3rbu_savestate() calls made on an RBU vacuum handle. FossilOrigin-Name: bef216dfa1456a787e3d9c74936ee1c6600827d4e252bd13e7a93046ce07469f --- diff --git a/ext/rbu/rbuvacuum3.test b/ext/rbu/rbuvacuum3.test new file mode 100644 index 0000000000..7e1e337f3c --- /dev/null +++ b/ext/rbu/rbuvacuum3.test @@ -0,0 +1,63 @@ +# 2019 Jan 3 +# +# 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 contains tests for the RBU module. More specifically, it +# contains tests to ensure that the sqlite3rbu_vacuum() API works as +# expected. +# + +source [file join [file dirname [info script]] rbu_common.tcl] +set testprefix rbuvacuum3 + +do_execsql_test 1.0 { + CREATE TABLE t1(a PRIMARY KEY, b, c); + CREATE INDEX i1b ON t1(b); + CREATE INDEX i1c ON t1(c); + + WITH s(i) AS ( + VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100 + ) + INSERT INTO t1 SELECT i, randomblob(100), randomblob(100) FROM s; +} + +forcedelete state.db +do_test 1.1 { + sqlite3rbu_vacuum rbu test.db state.db + while {1} { + set rc [rbu step] + if {$rc!="SQLITE_OK"} break + rbu savestate + } + rbu close +} {SQLITE_DONE} + +do_test 1.2 { + sqlite3rbu_vacuum rbu test.db state.db + while {1} { + set rc [rbu step] + if {$rc!="SQLITE_OK"} break + rbu savestate + } + rbu close +} {SQLITE_DONE} + +do_test 1.3 { + while {1} { + sqlite3rbu_vacuum rbu test.db state.db + set rc [rbu step] + if {$rc!="SQLITE_OK"} break + rbu savestate + rbu close + } + rbu close +} {SQLITE_DONE} + +finish_test diff --git a/ext/rbu/sqlite3rbu.c b/ext/rbu/sqlite3rbu.c index 7683c3464b..e86606be99 100644 --- a/ext/rbu/sqlite3rbu.c +++ b/ext/rbu/sqlite3rbu.c @@ -3945,7 +3945,10 @@ int sqlite3rbu_savestate(sqlite3rbu *p){ if( p->eStage==RBU_STAGE_OAL ){ assert( rc!=SQLITE_DONE ); if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbRbu, "COMMIT", 0, 0, 0); - if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbRbu, "BEGIN IMMEDIATE", 0, 0, 0); + if( rc==SQLITE_OK ){ + const char *zBegin = rbuIsVacuum(p) ? "BEGIN" : "BEGIN IMMEDIATE"; + rc = sqlite3_exec(p->dbRbu, zBegin, 0, 0, 0); + } if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, "BEGIN IMMEDIATE", 0, 0,0); } diff --git a/manifest b/manifest index 565e26bed8..e0e5a649b0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sgeopoly_svg()\sfunction\sso\sthat\sit\sreturns\sNULL\swhen\sgiven\szero\narguments. -D 2019-01-03T00:44:03.987 +C Fix\sa\sproblem\swith\sthe\ssecond\sand\ssubsequent\ssqlite3rbu_savestate()\scalls\smade\non\san\sRBU\svacuum\shandle. +D 2019-01-03T15:17:01.041 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in d8b254f8bb81bab43c340d70d17dc3babab40fcc8a348c8255881f780a45fee6 @@ -350,7 +350,8 @@ F ext/rbu/rbusplit.test b37e7b40b38760881dc9c854bd40b4744c6b6cd74990754eca3bda0f F ext/rbu/rbutemplimit.test 7f408f49b90fa0a720d7599f3aec74a3c85e6cd78e56fdf726ce00af9147a341 F ext/rbu/rbuvacuum.test 55e101e90168c2b31df6c9638fe73dc7f7cc666b6142266d1563697d79f73534 F ext/rbu/rbuvacuum2.test b8e5b51dc8b2c0153373d024c0936be3f66f9234acbd6d0baab0869d56b14e6b -F ext/rbu/sqlite3rbu.c f722ed4177c9fb73f2f6f116240687ac7603735fa95ea63bff71827929d4c192 +F ext/rbu/rbuvacuum3.test 8addd82e4b83b4c93fa47428eae4fd0dbf410f8512c186f38e348feb49ba03dc +F ext/rbu/sqlite3rbu.c d643661c7c85e79f4d0bc56c73f6f2dd55c35732dd41f378b0fd3b182a33242d F ext/rbu/sqlite3rbu.h 1dc88ab7bd32d0f15890ea08d23476c4198d3da3056985403991f8c9cd389812 F ext/rbu/test_rbu.c 03f6f177096a5f822d68d8e4069ad8907fe572c62ff2d19b141f59742821828a F ext/repair/README.md 92f5e8aae749a4dae14f02eea8e1bb42d4db2b6ce5e83dbcdd6b1446997e0c15 @@ -1795,7 +1796,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 703029ac6d24860230a8c30fcbf5e7e1da619e84f1cc9b9e65ebc74879a184d2 -R 27ad789d0b8700d6a91681e7bac70229 -U drh -Z e14ce0e496dd84038f55cf2afe147fcb +P 120cb1768338eb86412fb69d4c7677247775bb37875ab3a98766cffd535f04cf +R 5d2fee07520201670f7bcc9f026ba340 +U dan +Z b549416e8d4beb3bab9f7e64a67b786d diff --git a/manifest.uuid b/manifest.uuid index 5007e61ce1..27fcac3810 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -120cb1768338eb86412fb69d4c7677247775bb37875ab3a98766cffd535f04cf \ No newline at end of file +bef216dfa1456a787e3d9c74936ee1c6600827d4e252bd13e7a93046ce07469f \ No newline at end of file