interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / ext / rbu / rbufault2.test

64 lines · 1747 bytes Raw Blame History
1# 2014 October 22
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
13source [file join [file dirname [info script]] rbu_common.tcl]
14if_no_rbu_support { finish_test ; return }
15source $testdir/malloc_common.tcl
16set ::testprefix rbufault2
17
18forcedelete rbu.db
19do_execsql_test 1.0 {
20 CREATE TABLE target(x UNIQUE, y, z, PRIMARY KEY(y));
21 INSERT INTO target VALUES(1, 2, 3);
22 INSERT INTO target VALUES(4, 5, 6);
23
24 ATTACH 'rbu.db' AS rbu;
25 CREATE TABLE rbu.data_target(x, y, z, rbu_control);
26 INSERT INTO data_target VALUES(7, 8, 9, 0);
27 INSERT INTO data_target VALUES(1, 11, 12, 0);
28 DETACH rbu;
29}
30db close
31
32forcecopy test.db test.db-bak
33forcecopy rbu.db rbu.db-bak
34
35do_faultsim_test 1 -faults oom* -prep {
36 forcecopy test.db-bak test.db
37 forcecopy rbu.db-bak rbu.db
38 forcedelete test.db-oal test.db-wal rbu.db-journal
39 sqlite3rbu rbu test.db rbu.db
40} -body {
41 while {[rbu step]=="SQLITE_OK"} { }
42 rbu close
43} -test {
44 faultsim_test_result \
45 {1 {SQLITE_CONSTRAINT - UNIQUE constraint failed: target.x}} \
46 {1 SQLITE_CONSTRAINT} \
47 {1 SQLITE_NOMEM} \
48 {1 {SQLITE_NOMEM - unable to open a temporary database file for storing temporary tables}} \
49 {1 {SQLITE_NOMEM - out of memory}}
50}
51
52
53sqlite3rbu_create_vfs -default rbu ""
54sqlite3 db test.db
55set ::vfsname [file_control_vfsname db]
56do_faultsim_test 2 -faults oom* -prep {
57} -body {
58 file_control_vfsname db
59}
60db close
61sqlite3rbu_destroy_vfs rbu
62
63
64finish_test