Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Unified Diff: third_party/sqlite/src/ext/rbu/rbu_common.tcl

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/ext/rbu/rbuC.test ('k') | third_party/sqlite/src/ext/rbu/rbudiff.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/ext/rbu/rbu_common.tcl
diff --git a/third_party/sqlite/src/ext/rbu/rbu_common.tcl b/third_party/sqlite/src/ext/rbu/rbu_common.tcl
index 8190021baf9072236864173f5bf93faadd3beedd..a58c3aa0a781af34ee9885349c48085a0ea35d3b 100644
--- a/third_party/sqlite/src/ext/rbu/rbu_common.tcl
+++ b/third_party/sqlite/src/ext/rbu/rbu_common.tcl
@@ -15,12 +15,43 @@ if {![info exists testdir]} {
}
source $testdir/tester.tcl
+proc check_prestep_state {target state} {
+ set oal_exists [file exists $target-oal]
+ set wal_exists [file exists $target-wal]
+ set progress [rbu progress]
+
+ if {($progress==0 && $state!="oal" && $state!="done")
+ || ($oal_exists && $wal_exists)
+ || ($progress>0 && $state=="oal" && (!$oal_exists || $wal_exists))
+ || ($state=="move" && (!$oal_exists || $wal_exists))
+ || ($state=="checkpoint" && ($oal_exists || !$wal_exists))
+ || ($state=="done" && ($oal_exists && $progress!=0))
+ } {
+ error "B: state=$state progress=$progress oal=$oal_exists wal=$wal_exists"
+ }
+}
+
+proc check_poststep_state {rc target state} {
+ if {$rc=="SQLITE_OK" || $rc=="SQLITE_DONE"} {
+ set oal_exists [file exists $target-oal]
+ set wal_exists [file exists $target-wal]
+ if {$state=="move" && ($oal_exists || !$wal_exists)} {
+ error "A: state=$state progress=$progress oal=$oal_exists wal=$wal_exists"
+ }
+ }
+}
+
# Run the RBU in file $rbu on target database $target until completion.
#
proc run_rbu {target rbu} {
sqlite3rbu rbu $target $rbu
while 1 {
+ set state [rbu state]
+
+ check_prestep_state $target $state
set rc [rbu step]
+ check_poststep_state $rc $target $state
+
if {$rc!="SQLITE_OK"} break
}
rbu close
@@ -29,10 +60,33 @@ proc run_rbu {target rbu} {
proc step_rbu {target rbu} {
while 1 {
sqlite3rbu rbu $target $rbu
+ set state [rbu state]
+ check_prestep_state $target $state
set rc [rbu step]
+ check_poststep_state $rc $target $state
rbu close
if {$rc != "SQLITE_OK"} break
}
set rc
}
+proc do_rbu_vacuum_test {tn step} {
+ uplevel [list do_test $tn.1 {
+ if {$step==0} { sqlite3rbu_vacuum rbu test.db state.db }
+ while 1 {
+ if {$step==1} { sqlite3rbu_vacuum rbu test.db state.db }
+ set state [rbu state]
+ check_prestep_state test.db $state
+ set rc [rbu step]
+ check_poststep_state $rc test.db $state
+ if {$rc!="SQLITE_OK"} break
+ if {$step==1} { rbu close }
+ }
+ rbu close
+ } {SQLITE_DONE}]
+
+ uplevel [list do_execsql_test $tn.2 {
+ PRAGMA integrity_check
+ } ok]
+}
+
« no previous file with comments | « third_party/sqlite/src/ext/rbu/rbuC.test ('k') | third_party/sqlite/src/ext/rbu/rbudiff.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698