aboutsummaryrefslogtreecommitdiff
path: root/ext/session/sessionfault.test
diff options
context:
space:
mode:
authordan <dan@noemail.net>2014-08-18 16:03:46 +0000
committerdan <dan@noemail.net>2014-08-18 16:03:46 +0000
commit082c96dffa373ed10d000001edce62ae757f13ec (patch)
treeaee64d465280162564a7493fb36cd84f3c3fae14 /ext/session/sessionfault.test
parent8b7a2e3a1e9b373a1174ee84feb818fd2df01bdf (diff)
downloadsqlite-082c96dffa373ed10d000001edce62ae757f13ec.tar.gz
sqlite-082c96dffa373ed10d000001edce62ae757f13ec.zip
Add miscellaneous test cases to improve coverage of sessions module.
FossilOrigin-Name: 0fac6cfffe628ea02c78ebad065307309ec9eaa1
Diffstat (limited to 'ext/session/sessionfault.test')
-rw-r--r--ext/session/sessionfault.test52
1 files changed, 48 insertions, 4 deletions
diff --git a/ext/session/sessionfault.test b/ext/session/sessionfault.test
index f17daccfc..4b278098a 100644
--- a/ext/session/sessionfault.test
+++ b/ext/session/sessionfault.test
@@ -20,8 +20,6 @@ source $testdir/tester.tcl
set testprefix sessionfault
-if 1 {
-
forcedelete test.db2
sqlite3 db2 test.db2
do_common_sql {
@@ -399,8 +397,6 @@ do_faultsim_test 9.1 -faults oom-transient -prep {
}
}
-}
-
faultsim_delete_and_reopen
do_test 9.2.prep {
execsql {
@@ -438,6 +434,54 @@ do_faultsim_test 9.2 -faults oom-transient -prep {
}
}
+#-------------------------------------------------------------------------
+# Test that if a conflict-handler encounters an OOM in
+# sqlite3_value_text() but goes on to return SQLITE_CHANGESET_REPLACE
+# anyway, the OOM is picked up by the sessions module.
+set bigstr [string repeat abcdefghij 100]
+faultsim_delete_and_reopen
+do_test 10.prep.1 {
+ execsql {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES($bigstr, $bigstr);
+ }
+
+ sqlite3session S db main
+ S attach *
+ execsql { UPDATE t1 SET b = b||'x' }
+ set C [S changeset]
+ S delete
+ execsql { UPDATE t1 SET b = b||'xyz' }
+} {}
+faultsim_save_and_close
+
+faultsim_restore_and_reopen
+do_test 10.prep.2 {
+ proc xConflict {args} { return "ABORT" }
+ list [catch { sqlite3changeset_apply db $C xConflict } msg] $msg
+} {1 SQLITE_ABORT}
+do_execsql_test 10.prep.3 { SELECT b=$bigstr||'x' FROM t1 } 0
+do_test 10.prep.4 {
+ proc xConflict {args} { return "REPLACE" }
+ list [catch { sqlite3changeset_apply db $C xConflict } msg] $msg
+} {0 {}}
+do_execsql_test 10.prep.5 { SELECT b=$bigstr||'x' FROM t1 } 1
+db close
+
+do_faultsim_test 10 -faults oom-tra* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ sqlite3changeset_apply_replace_all db $::C
+} -test {
+ faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
+ if {$testrc==0} {
+ if {[db one {SELECT b=$bigstr||'x' FROM t1}]==0} {
+ error "data does not look right"
+ }
+ }
+}
+
+
finish_test