blob: f27741cba1084b7c25997cb7d12170d8e8471de3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# 2022 July 06
#
# 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/lock_common.tcl
source $testdir/malloc_common.tcl
if {[permutation] == "inmemory_journal"} {
finish_test
return
}
ifcapable !vtab {
finish_test
return
}
set testprefix dbpagefault
faultsim_save_and_close
do_faultsim_test 1 -prep {
faultsim_restore_and_reopen
execsql { ATTACH 'test.db2' AS aux; }
} -body {
execsql {
CREATE VIRTUAL TABLE t1 USING sqlite_dbpage();
}
} -test {
execsql { PRAGMA journal_mode = off }
faultsim_test_result {0 {}}
}
do_faultsim_test 2 -prep {
sqlite3 db "xyz.db" -vfs memdb
execsql { ATTACH 'test.db2' AS aux; }
} -body {
execsql {
CREATE VIRTUAL TABLE t1 USING sqlite_dbpage();
UPDATE t1 SET data=zeroblob(1024) WHERE pgno=1 AND schema='aux';
}
} -test {
execsql { PRAGMA journal_mode = off }
faultsim_test_result {0 {}} {1 {no such schema}} {1 {SQL logic error}} {1 {unable to open a temporary database file for storing temporary tables}}
}
reset_db
do_execsql_test 3.0 {
CREATE TABLE x1(z, b);
CREATE TRIGGER BEFORE INSERT ON x1 BEGIN
DELETE FROM sqlite_dbpage WHERE pgno=100;
UPDATE sqlite_dbpage SET data=null WHERE pgno=100;
END;
}
# This test case no longer works, as it is no longer possible to use
# virtual table sqlite_dbpage from within a trigger.
#
do_execsql_test 3.1 {
PRAGMA trusted_schema = 1;
}
do_catchsql_test 3.2 {
PRAGMA trusted_schema = 1;
INSERT INTO x1 DEFAULT VALUES;
} {1 {unsafe use of virtual table "sqlite_dbpage"}}
#do_faultsim_test 3 -prep {
# catch { db close }
# sqlite3 db test.db
# execsql { PRAGMA trusted_schema = 1 }
#} -body {
# execsql { INSERT INTO x1 DEFAULT VALUES; }
#} -test {
# faultsim_test_result {0 {}}
#}
finish_test
|