summaryrefslogtreecommitdiffstats
path: root/third_party/sqlite/test/shared_err.test
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/sqlite/test/shared_err.test')
-rw-r--r--third_party/sqlite/test/shared_err.test40
1 files changed, 30 insertions, 10 deletions
diff --git a/third_party/sqlite/test/shared_err.test b/third_party/sqlite/test/shared_err.test
index 95e8c90..f501fc7 100644
--- a/third_party/sqlite/test/shared_err.test
+++ b/third_party/sqlite/test/shared_err.test
@@ -13,7 +13,7 @@
# cache context. What happens to connection B if one connection A encounters
# an IO-error whilst reading or writing the file-system?
#
-# $Id: shared_err.test,v 1.21 2008/07/07 17:55:29 danielk1977 Exp $
+# $Id: shared_err.test,v 1.24 2008/10/12 00:27:54 shane Exp $
proc skip {args} {}
@@ -57,12 +57,13 @@ do_ioerr_test shared_ioerr-1 -tclprep {
set res [catchsql {
SELECT * FROM t1;
} db2]
- set possible_results [list \
- "1 {disk I/O error}" \
- "0 {1 2 3}" \
- "0 {1 2 3 1 2 3 4 5 6}" \
- "0 {1 2 3 1 2 3 4 5 6 1 2 3 4 5 6}" \
- "0 {}" \
+ set possible_results [list \
+ "1 {disk I/O error}" \
+ "0 {1 2 3}" \
+ "0 {1 2 3 1 2 3 4 5 6}" \
+ "0 {1 2 3 1 2 3 4 5 6 1 2 3 4 5 6}" \
+ "0 {}" \
+ "1 {database disk image is malformed}" \
]
set rc [expr [lsearch -exact $possible_results $res] >= 0]
if {$rc != 1} {
@@ -71,7 +72,15 @@ do_ioerr_test shared_ioerr-1 -tclprep {
}
set rc
} {1}
+
+ # The "database disk image is malformed" is a special case that can
+ # occur if an IO error occurs during a rollback in the {SELECT * FROM t1}
+ # statement above. This test is to make sure there is no real database
+ # corruption.
db2 close
+ do_test shared_ioerr-1.$n.cleanup.2 {
+ execsql {pragma integrity_check} db
+ } {ok}
}
do_ioerr_test shared_ioerr-2 -tclprep {
@@ -353,7 +362,9 @@ do_malloc_test shared_err-5 -tclbody {
do_malloc_test shared_err-6 -tclbody {
catch {db close}
- sqlite3_thread_cleanup
+ ifcapable deprecated {
+ sqlite3_thread_cleanup
+ }
sqlite3_enable_shared_cache 0
} -cleanup {
sqlite3_enable_shared_cache 1
@@ -401,11 +412,19 @@ do_malloc_test shared_err-8 -tclprep {
ROLLBACK;
}
} -cleanup {
+ # UPDATE: As of [5668], if the rollback fails SQLITE_CORRUPT is returned.
+ # So these tests have been updated to expect SQLITE_CORRUPT and its
+ # associated English language error message.
+ #
do_test shared_malloc-8.$::n.cleanup.1 {
set res [catchsql {SELECT a FROM t1} db2]
set ans [lindex $res 1]
if {[lindex $res 0]} {
- set r [expr {$ans=="disk I/O error" || $ans=="out of memory"}]
+ set r [expr {
+ $ans=="disk I/O error" ||
+ $ans=="out of memory" ||
+ $ans=="database disk image is malformed"
+ }]
} else {
set r [expr {[lrange $ans 0 1]=="0000000000 1111111111"}]
}
@@ -420,7 +439,8 @@ do_malloc_test shared_err-8 -tclprep {
($rc1=="SQLITE_DONE" && $rc2=="SQLITE_OK") ||
($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_ABORT") ||
($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_NOMEM") ||
- ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_IOERR")
+ ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_IOERR") ||
+ ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_CORRUPT")
}
} {1}
db2 close