1# 2010 July 29 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 13set testdir [file dirname $argv0] 14source $testdir/tester.tcl 15source $testdir/malloc_common.tcl 16 17foreach f [glob -nocomplain test.db*mj*] { forcedelete $f } 18forcedelete test.db2 19 20do_test tkt-f3e5abed55-1.1 { 21 execsql { 22 ATTACH 'test.db2' AS aux; 23 CREATE TABLE main.t1(a, b); 24 CREATE TABLE aux.t2(c, d); 25 } 26} {} 27 28do_test tkt-f3e5abed55-1.2 { 29 glob -nocomplain test.db*mj* 30} {} 31 32do_test tkt-f3e5abed55-1.3 { 33 sqlite3 db2 test.db 34 execsql { BEGIN; SELECT * FROM t1 } db2 35} {} 36 37do_test tkt-f3e5abed55-1.4 { 38 execsql { 39 BEGIN; 40 INSERT INTO t1 VALUES(1, 2); 41 INSERT INTO t2 VALUES(1, 2); 42 } 43 catchsql COMMIT 44} {1 {database is locked}} 45 46do_test tkt-f3e5abed55-1.5 { 47 execsql COMMIT db2 48 execsql COMMIT 49} {} 50 51do_test tkt-f3e5abed55-1.6 { 52 glob -nocomplain test.db*mj* 53} {} 54foreach f [glob -nocomplain test.db*mj*] { forcedelete $f } 55db close 56db2 close 57 58 59 60# Set up a testvfs so that the next time SQLite tries to delete the 61# file "test.db-journal", a snapshot of the current file-system contents 62# is taken. 63# 64# This test will not work with an in-memory journal. 65# 66if {[permutation]!="inmemory_journal"} { 67 testvfs tvfs -default 1 68 tvfs script xDelete 69 tvfs filter xDelete 70 proc xDelete {method file args} { 71 if {[file tail $file] == "test.db-journal"} { 72 faultsim_save 73 tvfs filter {} 74 } 75 return "SQLITE_OK" 76 } 77 78 sqlite3 db test.db 79 sqlite3 db2 test.db 80 do_test tkt-f3e5abed55-2.1 { 81 execsql { 82 ATTACH 'test.db2' AS aux; 83 BEGIN; 84 INSERT INTO t1 VALUES(3, 4); 85 INSERT INTO t2 VALUES(3, 4); 86 } 87 } {} 88 do_test tkt-f3e5abed55-2.2 { 89 execsql { BEGIN; SELECT * FROM t1 } db2 90 } {1 2} 91 do_test tkt-f3e5abed55-2.3 { 92 catchsql COMMIT 93 } {1 {database is locked}} 94 95 do_test tkt-f3e5abed55-2.4 { 96 execsql COMMIT db2 97 execsql { 98 COMMIT; 99 SELECT * FROM t1; 100 SELECT * FROM t2; 101 } 102 } {1 2 3 4 1 2 3 4} 103 do_test tkt-f3e5abed55-2.5 { 104 db close 105 db2 close 106 faultsim_restore_and_reopen 107 execsql { 108 ATTACH 'test.db2' AS aux; 109 SELECT * FROM t1; 110 SELECT * FROM t2; 111 } 112 } {1 2 3 4 1 2 3 4} 113} 114 115 116finish_test 117