2022-07-06 15:59:45 +02:00
|
|
|
# 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
|
|
|
|
}
|
|
|
|
|
2022-11-08 20:36:26 +01:00
|
|
|
ifcapable !vtab {
|
|
|
|
finish_test
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-07-06 15:59:45 +02:00
|
|
|
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();
|
|
|
|
INSERT INTO t1 DEFAULT VALUES;
|
|
|
|
}
|
|
|
|
} -test {
|
|
|
|
execsql { PRAGMA journal_mode = off }
|
|
|
|
faultsim_test_result {1 {no such schema}} {1 {SQL logic error}}
|
|
|
|
}
|
|
|
|
|
2022-08-19 22:10:51 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-11-05 20:26:45 +01:00
|
|
|
# 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;
|
2022-08-19 22:10:51 +02:00
|
|
|
}
|
2022-11-05 20:26:45 +01:00
|
|
|
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 {}}
|
|
|
|
#}
|
2022-08-19 22:10:51 +02:00
|
|
|
|
|
|
|
|
2022-07-06 15:59:45 +02:00
|
|
|
finish_test
|
2022-08-19 22:10:51 +02:00
|
|
|
|
|
|
|
|