2015-02-19 16:36:02 +03:00
|
|
|
# 2014 October 22
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
#***********************************************************************
|
|
|
|
#
|
|
|
|
|
2023-01-27 22:59:46 +03:00
|
|
|
source [file join [file dirname [info script]] rbu_common.tcl]
|
2023-02-05 00:25:17 +03:00
|
|
|
if_no_rbu_support { finish_test ; return }
|
2015-02-19 16:36:02 +03:00
|
|
|
source $testdir/malloc_common.tcl
|
2015-07-23 23:44:49 +03:00
|
|
|
set ::testprefix rbufault2
|
2015-02-19 16:36:02 +03:00
|
|
|
|
2015-07-23 23:44:49 +03:00
|
|
|
forcedelete rbu.db
|
2015-02-19 16:36:02 +03:00
|
|
|
do_execsql_test 1.0 {
|
|
|
|
CREATE TABLE target(x UNIQUE, y, z, PRIMARY KEY(y));
|
|
|
|
INSERT INTO target VALUES(1, 2, 3);
|
|
|
|
INSERT INTO target VALUES(4, 5, 6);
|
|
|
|
|
2015-07-23 23:44:49 +03:00
|
|
|
ATTACH 'rbu.db' AS rbu;
|
|
|
|
CREATE TABLE rbu.data_target(x, y, z, rbu_control);
|
2015-02-19 16:36:02 +03:00
|
|
|
INSERT INTO data_target VALUES(7, 8, 9, 0);
|
|
|
|
INSERT INTO data_target VALUES(1, 11, 12, 0);
|
2015-07-23 23:44:49 +03:00
|
|
|
DETACH rbu;
|
2015-02-19 16:36:02 +03:00
|
|
|
}
|
|
|
|
db close
|
|
|
|
|
|
|
|
forcecopy test.db test.db-bak
|
2015-07-23 23:44:49 +03:00
|
|
|
forcecopy rbu.db rbu.db-bak
|
2015-02-19 16:36:02 +03:00
|
|
|
|
|
|
|
do_faultsim_test 1 -faults oom* -prep {
|
|
|
|
forcecopy test.db-bak test.db
|
2015-07-23 23:44:49 +03:00
|
|
|
forcecopy rbu.db-bak rbu.db
|
|
|
|
forcedelete test.db-oal test.db-wal rbu.db-journal
|
|
|
|
sqlite3rbu rbu test.db rbu.db
|
2015-02-19 16:36:02 +03:00
|
|
|
} -body {
|
2015-07-23 23:44:49 +03:00
|
|
|
while {[rbu step]=="SQLITE_OK"} { }
|
|
|
|
rbu close
|
2015-02-19 16:36:02 +03:00
|
|
|
} -test {
|
|
|
|
faultsim_test_result \
|
|
|
|
{1 {SQLITE_CONSTRAINT - UNIQUE constraint failed: target.x}} \
|
|
|
|
{1 SQLITE_CONSTRAINT} \
|
|
|
|
{1 SQLITE_NOMEM} \
|
|
|
|
{1 {SQLITE_NOMEM - unable to open a temporary database file for storing temporary tables}} \
|
|
|
|
{1 {SQLITE_NOMEM - out of memory}}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-10 23:44:10 +03:00
|
|
|
sqlite3rbu_create_vfs -default rbu ""
|
|
|
|
sqlite3 db test.db
|
|
|
|
set ::vfsname [file_control_vfsname db]
|
|
|
|
do_faultsim_test 2 -faults oom* -prep {
|
|
|
|
} -body {
|
|
|
|
file_control_vfsname db
|
|
|
|
}
|
|
|
|
db close
|
|
|
|
sqlite3rbu_destroy_vfs rbu
|
2015-02-19 16:36:02 +03:00
|
|
|
|
|
|
|
|
|
|
|
finish_test
|