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 | |
dan | afe7681 | 2022-11-08 19:36:26 +0000 | [diff] [blame] | 23 | ifcapable !vtab { |
| 24 | finish_test |
| 25 | return |
| 26 | } |
| 27 | |
dan | e36281f | 2022-07-06 13:59:45 +0000 | [diff] [blame] | 28 | set testprefix dbpagefault |
| 29 | |
dan | e36281f | 2022-07-06 13:59:45 +0000 | [diff] [blame] | 30 | faultsim_save_and_close |
| 31 | do_faultsim_test 1 -prep { |
| 32 | faultsim_restore_and_reopen |
| 33 | execsql { ATTACH 'test.db2' AS aux; } |
| 34 | } -body { |
| 35 | execsql { |
| 36 | CREATE VIRTUAL TABLE t1 USING sqlite_dbpage(); |
| 37 | } |
| 38 | } -test { |
| 39 | execsql { PRAGMA journal_mode = off } |
| 40 | faultsim_test_result {0 {}} |
| 41 | } |
| 42 | |
| 43 | do_faultsim_test 2 -prep { |
| 44 | sqlite3 db "xyz.db" -vfs memdb |
| 45 | execsql { ATTACH 'test.db2' AS aux; } |
| 46 | } -body { |
| 47 | execsql { |
| 48 | CREATE VIRTUAL TABLE t1 USING sqlite_dbpage(); |
| 49 | INSERT INTO t1 DEFAULT VALUES; |
| 50 | } |
| 51 | } -test { |
| 52 | execsql { PRAGMA journal_mode = off } |
| 53 | faultsim_test_result {1 {no such schema}} {1 {SQL logic error}} |
| 54 | } |
| 55 | |
dan | f56291e | 2022-08-19 20:10:51 +0000 | [diff] [blame] | 56 | reset_db |
| 57 | do_execsql_test 3.0 { |
| 58 | CREATE TABLE x1(z, b); |
| 59 | CREATE TRIGGER BEFORE INSERT ON x1 BEGIN |
| 60 | DELETE FROM sqlite_dbpage WHERE pgno=100; |
| 61 | UPDATE sqlite_dbpage SET data=null WHERE pgno=100; |
| 62 | END; |
| 63 | } |
| 64 | |
dan | f53c0a0 | 2022-11-05 19:26:45 +0000 | [diff] [blame] | 65 | # This test case no longer works, as it is no longer possible to use |
| 66 | # virtual table sqlite_dbpage from within a trigger. |
| 67 | # |
| 68 | do_execsql_test 3.1 { |
| 69 | PRAGMA trusted_schema = 1; |
dan | f56291e | 2022-08-19 20:10:51 +0000 | [diff] [blame] | 70 | } |
dan | f53c0a0 | 2022-11-05 19:26:45 +0000 | [diff] [blame] | 71 | do_catchsql_test 3.2 { |
| 72 | PRAGMA trusted_schema = 1; |
| 73 | INSERT INTO x1 DEFAULT VALUES; |
| 74 | } {1 {unsafe use of virtual table "sqlite_dbpage"}} |
| 75 | #do_faultsim_test 3 -prep { |
| 76 | # catch { db close } |
| 77 | # sqlite3 db test.db |
| 78 | # execsql { PRAGMA trusted_schema = 1 } |
| 79 | #} -body { |
| 80 | # execsql { INSERT INTO x1 DEFAULT VALUES; } |
| 81 | #} -test { |
| 82 | # faultsim_test_result {0 {}} |
| 83 | #} |
dan | f56291e | 2022-08-19 20:10:51 +0000 | [diff] [blame] | 84 | |
| 85 | |
dan | e36281f | 2022-07-06 13:59:45 +0000 | [diff] [blame] | 86 | finish_test |
dan | f56291e | 2022-08-19 20:10:51 +0000 | [diff] [blame] | 87 | |
| 88 | |