1# 2022 July 06 2# 3# The author disclaims copyright to this source code. In place of 4# a legal notice, here is a blessing: 5# 6# May you do good and not evil. 7# May you find forgiveness for yourself and forgive others. 8# May you share freely, never taking more than you give. 9# 10#*********************************************************************** 11# 12 13set testdir [file dirname $argv0] 14source $testdir/tester.tcl 15source $testdir/lock_common.tcl 16source $testdir/malloc_common.tcl 17 18if {[permutation] == "inmemory_journal"} { 19 finish_test 20 return 21} 22 23set testprefix dbpagefault 24 25faultsim_save_and_close 26do_faultsim_test 1 -prep { 27 faultsim_restore_and_reopen 28 execsql { ATTACH 'test.db2' AS aux; } 29} -body { 30 execsql { 31 CREATE VIRTUAL TABLE t1 USING sqlite_dbpage(); 32 } 33} -test { 34 execsql { PRAGMA journal_mode = off } 35 faultsim_test_result {0 {}} 36} 37 38do_faultsim_test 2 -prep { 39 sqlite3 db "xyz.db" -vfs memdb 40 execsql { ATTACH 'test.db2' AS aux; } 41} -body { 42 execsql { 43 CREATE VIRTUAL TABLE t1 USING sqlite_dbpage(); 44 INSERT INTO t1 DEFAULT VALUES; 45 } 46} -test { 47 execsql { PRAGMA journal_mode = off } 48 faultsim_test_result {1 {no such schema}} {1 {SQL logic error}} 49} 50 51reset_db 52do_execsql_test 3.0 { 53 CREATE TABLE x1(z, b); 54 CREATE TRIGGER BEFORE INSERT ON x1 BEGIN 55 DELETE FROM sqlite_dbpage WHERE pgno=100; 56 UPDATE sqlite_dbpage SET data=null WHERE pgno=100; 57 END; 58} 59 60do_faultsim_test 3 -prep { 61 catch { db close } 62 sqlite3 db test.db 63 execsql { PRAGMA trusted_schema = true } 64} -body { 65 execsql { INSERT INTO x1 DEFAULT VALUES; } 66} -test { 67 faultsim_test_result {0 {}} 68} 69 70 71finish_test 72 73 74