--- /dev/null
+# 2014 October 22
+#
+# 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.
+#
+#***********************************************************************
+#
+
+if {![info exists testdir]} {
+ set testdir [file join [file dirname [info script]] .. .. test]
+}
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set ::testprefix otafault
+
+do_test 1.1 {
+ forcedelete ota.db
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
+ CREATE INDEX t1cb ON t1(c, b);
+ INSERT INTO t1 VALUES(1, 1, 1);
+ INSERT INTO t1 VALUES(2, 2, 2);
+ INSERT INTO t1 VALUES(3, 3, 3);
+ CREATE TABLE t2(a PRIMARY KEY, b, c) WITHOUT ROWID;
+ CREATE INDEX t2cb ON t1(c, b);
+ INSERT INTO t2 VALUES('a', 'a', 'a');
+ INSERT INTO t2 VALUES('b', 'b', 'b');
+ INSERT INTO t2 VALUES('c', 'c', 'c');
+
+ ATTACH 'ota.db' AS ota;
+ CREATE TABLE ota.data_t1(a, b, c, ota_control);
+ CREATE TABLE ota.data_t2(a, b, c, ota_control);
+
+ INSERT INTO data_t1 VALUES(2, NULL, NULL, 1);
+ INSERT INTO data_t1 VALUES(3, 'three', NULL, '.x.');
+ INSERT INTO data_t1 VALUES(4, 4, 4, 0);
+
+ INSERT INTO data_t2 VALUES('b', NULL, NULL, 1);
+ INSERT INTO data_t2 VALUES('c', 'see', NULL, '.x.');
+ INSERT INTO data_t2 VALUES('d', 'd', 'd', 0);
+ }
+ db close
+
+ forcecopy test.db test.db.bak
+ forcecopy ota.db ota.db.bak
+} {}
+
+do_faultsim_test 2 -faults oom-trans* -prep {
+ catch { db close }
+ forcedelete test.db-journal test.db-wal ota.db-journal ota.db-wal
+ forcecopy test.db.bak test.db
+ forcecopy ota.db.bak ota.db
+} -body {
+ sqlite3ota ota test.db ota.db
+ while {[ota step]=="SQLITE_OK"} {}
+ ota close
+} -test {
+ faultsim_test_result {0 SQLITE_DONE} \
+ {1 {SQLITE_NOMEM - out of memory}} \
+ {1 SQLITE_NOMEM} \
+ {1 SQLITE_IOERR_NOMEM} \
+ {1 {SQLITE_NOMEM - unable to open a temporary database file for storing temporary tables}}
+
+ if {$testrc==0} {
+ sqlite3 db test.db
+ faultsim_integrity_check
+ set res [db eval {
+ SELECT * FROM t1 UNION ALL SELECT * FROM t2;
+ }]
+ set expected [list {*}{
+ 1 1 1 3 three 3 4 4 4
+ a a a c see c d d d
+ }]
+
+ if {$res != $expected} {
+ puts ""
+ puts "res: $res"
+ puts "exp: $expected"
+ error "data not as expected!"
+ }
+ }
+}
+
+proc copy_if_exists {src target} {
+ if {[file exists $src]} {
+ forcecopy $src $target
+ } else {
+ forcedelete $target
+ }
+}
+
+for {set iStep 0} {$iStep<=21} {incr iStep} {
+
+ forcedelete test.db-journal test.db-wal ota.db-journal ota.db-wal
+
+ copy_if_exists test.db.bak test.db
+ copy_if_exists ota.db.bak ota.db
+
+ sqlite3ota ota test.db ota.db
+ for {set x 0} {$x < $::iStep} {incr x} { ota step }
+ ota close
+
+ copy_if_exists test.db test.db.bak.2
+ copy_if_exists test.db-wal test.db.bak.2-wal
+ copy_if_exists test.db-oal test.db.bak.2-oal
+ copy_if_exists ota.db ota.db.bak.2
+
+ do_faultsim_test 3.$iStep -faults oom-trans* -prep {
+ catch { db close }
+ forcedelete test.db-journal test.db-wal ota.db-journal ota.db-wal
+ copy_if_exists test.db.bak.2 test.db
+ copy_if_exists test.db.bak.2-wal test.db-wal
+ copy_if_exists test.db.bak.2-oal test.db-oal
+ copy_if_exists ota.db.bak.2 ota.db
+ } -body {
+ sqlite3ota ota test.db ota.db
+ while {[ota step] == "SQLITE_OK"} {}
+ ota close
+ } -test {
+ faultsim_test_result {0 SQLITE_DONE} \
+ {1 {SQLITE_NOMEM - out of memory}} \
+ {1 SQLITE_NOMEM} \
+ {1 SQLITE_IOERR_NOMEM} \
+ {1 {SQLITE_NOMEM - unable to open a temporary database file for storing temporary tables}}
+
+ if {$testrc==0} {
+ sqlite3 db test.db
+ faultsim_integrity_check
+ set res [db eval {
+ SELECT * FROM t1 UNION ALL SELECT * FROM t2;
+ }]
+ set expected [list {*}{
+ 1 1 1 3 three 3 4 4 4
+ a a a c see c d d d
+ }]
+
+ if {$res != $expected} {
+ puts ""
+ puts "res: $res"
+ puts "exp: $expected"
+ error "data not as expected!"
+ }
+ }
+ }
+
+}
+
+finish_test
+
-C Sync\sthe\sdatabase\sfile\sin\ssqlite3_ckpt_close(),\seven\sif\sthe\scheckpoint\shas\snot\sfinished.
-D 2014-10-22T11:30:08.642
+C Add\stests\sto\scheck\serror\shandling\sin\sOTA.
+D 2014-10-22T15:33:12.681
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F ext/ota/ota4.test 60f897f329a6782ef2f24862640acf3c52e48077
F ext/ota/ota5.test ad0799daf8923ddebffe75ae8c5504ca90b7fadb
F ext/ota/ota6.test 82f1f757ec9b2ad07d6de4060b8e3ba8e44dfdd3
-F ext/ota/sqlite3ota.c a8b4fbe2234964238678ed939e035346efbfeff2
+F ext/ota/otafault.test be02466863015a583cc0ceb6aca871a5e6f7a71b
+F ext/ota/sqlite3ota.c c7f8cdf55449b5169f79632e78f8e5049abf904c
F ext/ota/sqlite3ota.h 7b20abe9247d292429d00f0a5c237ff6e0dc0196
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
F ext/rtree/rtree.c 57bec53e1a677ab74217fe1f20a58c3a47261d6b
F src/vdbesort.c 975aeffa99acb0991b2f288d30294756bff41438
F src/vdbetrace.c 7e4222955e07dd707a2f360c0eb73452be1cb010
F src/vtab.c cb0c194303fea276b48d7d4b6d970b5a96bde8de
-F src/wal.c 99c5b0a68e525d854d86f93be215e9c2bfb7b194
+F src/wal.c 2787dfceb22d50c45ca51a8f56684516894a135c
F src/wal.h 0d3ba0c3f1b4c25796cb213568a84b9f9063f465
F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804
F src/where.c 2947912f1f3d6a7766fe087fd532a5d688d745b1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 6fd09854feb46739f42b7e7a5e76680d5f9b8c5a
-R b3f281b9e115a81e4161ab510da7f09d
+P e2729d623c6e9d0b3049049f3f3051bbb479184f
+R f1db06b4abcee6f48965e7da46a3387a
U dan
-Z 3d20cbfe4cbde996e6770d4067fcc8a6
+Z 87316fa0e6665a6aa049c94bffdd7d8b