1# 2005 August 28 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# This file implements regression tests for SQLite library. 12# 13# This file implements tests to verify that fsync is disabled when 14# pragma synchronous=off even for multi-database commits. 15# 16 17set testdir [file dirname $argv0] 18source $testdir/tester.tcl 19 20# 21# These tests are only applicable when pager pragma are 22# enabled. Also, since every test uses an ATTACHed database, they 23# are only run when ATTACH is enabled. 24# 25ifcapable !pager_pragmas||!attach { 26 finish_test 27 return 28} 29if {[atomic_batch_write test.db]} { 30 finish_test 31 return 32} 33 34set sqlite_sync_count 0 35proc cond_incr_sync_count {adj} { 36 global sqlite_sync_count 37 if {$::tcl_platform(platform) == "windows"} { 38 incr sqlite_sync_count $adj 39 } else { 40 ifcapable !dirsync { 41 incr sqlite_sync_count $adj 42 } 43 } 44} 45 46do_test sync-1.1 { 47 set sqlite_sync_count 0 48 forcedelete test2.db 49 forcedelete test2.db-journal 50 execsql { 51 PRAGMA fullfsync=OFF; 52 CREATE TABLE t1(a,b); 53 ATTACH DATABASE 'test2.db' AS db2; 54 CREATE TABLE db2.t2(x,y); 55 } 56 cond_incr_sync_count 2 57 set sqlite_sync_count 58} 8 59ifcapable pager_pragmas { 60 do_test sync-1.2 { 61 set sqlite_sync_count 0 62 execsql { 63 PRAGMA main.synchronous=on; 64 PRAGMA db2.synchronous=on; 65 BEGIN; 66 INSERT INTO t1 VALUES(1,2); 67 INSERT INTO t2 VALUES(3,4); 68 COMMIT; 69 } 70 cond_incr_sync_count 4 71 set sqlite_sync_count 72 } 9 73} 74do_test sync-1.3 { 75 set sqlite_sync_count 0 76 execsql { 77 PRAGMA main.synchronous=full; 78 PRAGMA db2.synchronous=full; 79 BEGIN; 80 INSERT INTO t1 VALUES(3,4); 81 INSERT INTO t2 VALUES(5,6); 82 COMMIT; 83 } 84 cond_incr_sync_count 4 85 set sqlite_sync_count 86} 11 87ifcapable pager_pragmas { 88if {[permutation]!="journaltest"} { 89 do_test sync-1.4 { 90 set sqlite_sync_count 0 91 execsql { 92 PRAGMA main.synchronous=off; 93 PRAGMA db2.synchronous=off; 94 BEGIN; 95 INSERT INTO t1 VALUES(5,6); 96 INSERT INTO t2 VALUES(7,8); 97 COMMIT; 98 } 99 set sqlite_sync_count 100 } 0 101} 102} 103 104 105finish_test 106