mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
If SQLITE_USE_SEH is defined, handle structured-exceptions thrown by MSVC builds if the *-shm file mapping is accessed after it becomes invalid for some reason.
FossilOrigin-Name: 5c5fa47076c5da25ca92248df3a4c11b90a0225a07f05d7220fa95d9bbb36f43
This commit is contained in:
@ -23,6 +23,7 @@ set testprefix snapshot_fault
|
||||
# checkpointing the db.
|
||||
#
|
||||
do_faultsim_test 1.0 -prep {
|
||||
catch { db2 close }
|
||||
faultsim_delete_and_reopen
|
||||
sqlite3 db2 test.db
|
||||
db2 eval {
|
||||
|
106
test/walseh1.test
Normal file
106
test/walseh1.test
Normal file
@ -0,0 +1,106 @@
|
||||
# 2021 August 16
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/malloc_common.tcl
|
||||
set testprefix seh1
|
||||
|
||||
set ::seh_countdown 0
|
||||
proc seh_faultsim_callback {iFault} {
|
||||
if {$iFault==650} {
|
||||
incr ::seh_countdown -1
|
||||
if {$::seh_countdown==0} { return 1 }
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
proc seh_injectinstall {} {
|
||||
sqlite3_test_control_fault_install seh_faultsim_callback
|
||||
}
|
||||
proc seh_injectuninstall {} {
|
||||
sqlite3_test_control_fault_install
|
||||
}
|
||||
proc seh_injectstart {iFail} {
|
||||
set ::seh_countdown $iFail
|
||||
}
|
||||
proc seh_injectstop {} {
|
||||
set res [expr $::seh_countdown<=0]
|
||||
set ::seh_countdown 0
|
||||
set res
|
||||
}
|
||||
|
||||
set FAULTSIM(seh) [list \
|
||||
-injectinstall seh_injectinstall \
|
||||
-injectstart seh_injectstart \
|
||||
-injectstop seh_injectstop \
|
||||
-injecterrlist {{1 {disk I/O error}}} \
|
||||
-injectuninstall seh_injectuninstall \
|
||||
]
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(x, y);
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
INSERT INTO t1 VALUES(3, 4);
|
||||
} {wal}
|
||||
faultsim_save_and_close
|
||||
|
||||
do_faultsim_test 1 -faults seh -prep {
|
||||
catch { db2 close }
|
||||
faultsim_restore_and_reopen
|
||||
execsql { SELECT * FROM sqlite_schema }
|
||||
sqlite3 db2 test.db
|
||||
} -body {
|
||||
execsql { SELECT * FROM t1 } db2
|
||||
} -test {
|
||||
faultsim_test_result {0 {1 2 3 4}}
|
||||
}
|
||||
catch { db2 close }
|
||||
|
||||
faultsim_save_and_close
|
||||
|
||||
do_faultsim_test 2 -faults seh -prep {
|
||||
catch { db close }
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql { SELECT * FROM t1 }
|
||||
} -test {
|
||||
faultsim_test_result {0 {1 2 3 4}}
|
||||
}
|
||||
|
||||
do_faultsim_test 3 -faults seh -prep {
|
||||
catch { db close }
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql { INSERT INTO t1 VALUES(5, 6) }
|
||||
execsql { SELECT * FROM t1 }
|
||||
} -test {
|
||||
faultsim_test_result {0 {1 2 3 4 5 6}}
|
||||
}
|
||||
catch { db close }
|
||||
|
||||
do_faultsim_test 4 -faults seh -prep {
|
||||
catch { db close }
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql { PRAGMA wal_checkpoint }
|
||||
execsql { INSERT INTO t1 VALUES(7, 8) }
|
||||
execsql { SELECT * FROM t1 }
|
||||
} -test {
|
||||
faultsim_test_result {0 {1 2 3 4 7 8}}
|
||||
}
|
||||
catch { db close }
|
||||
|
||||
finish_test
|
||||
|
||||
|
Reference in New Issue
Block a user