dan | e36281f | 2022-07-06 13:59:45 +0000 | [diff] [blame] | 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 | |
| 13 | set testdir [file dirname $argv0] |
| 14 | source $testdir/tester.tcl |
| 15 | source $testdir/lock_common.tcl |
| 16 | source $testdir/malloc_common.tcl |
| 17 | |
| 18 | if {[permutation] == "inmemory_journal"} { |
| 19 | finish_test |
| 20 | return |
| 21 | } |
| 22 | |
| 23 | set testprefix dbpagefault |
| 24 | |
dan | e36281f | 2022-07-06 13:59:45 +0000 | [diff] [blame] | 25 | faultsim_save_and_close |
| 26 | do_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 | |
| 38 | do_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 | |
dan | f56291e | 2022-08-19 20:10:51 +0000 | [diff] [blame] | 51 | reset_db |
| 52 | do_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 | |
| 60 | do_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 | |
dan | e36281f | 2022-07-06 13:59:45 +0000 | [diff] [blame] | 71 | finish_test |
dan | f56291e | 2022-08-19 20:10:51 +0000 | [diff] [blame] | 72 | |
| 73 | |