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# $Id: sync.test,v 1.2 2005/11/25 10:38:22 danielk1977 Exp $ 17 18set testdir [file dirname $argv0] 19source $testdir/tester.tcl 20 21# 22# These tests are only applicable on unix when pager pragma are 23# enabled. 24# 25if {$::tcl_platform(platform)!="unix"} { 26 finish_test 27} 28ifcapable !pager_pragmas { 29 finish_test 30} 31 32do_test sync-1.1 { 33 set sqlite_sync_count 0 34 file delete -force test2.db 35 file delete -force test2.db-journal 36 execsql { 37 CREATE TABLE t1(a,b); 38 ATTACH DATABASE 'test2.db' AS db2; 39 CREATE TABLE db2.t2(x,y); 40 } 41 ifcapable !dirsync { 42 incr sqlite_sync_count 2 43 } 44 set sqlite_sync_count 45} 8 46do_test sync-1.2 { 47 set sqlite_sync_count 0 48 execsql { 49 PRAGMA main.synchronous=on; 50 PRAGMA db2.synchronous=on; 51 BEGIN; 52 INSERT INTO t1 VALUES(1,2); 53 INSERT INTO t2 VALUES(3,4); 54 COMMIT; 55 } 56 ifcapable !dirsync { 57 incr sqlite_sync_count 3 58 } 59 set sqlite_sync_count 60} 8 61do_test sync-1.3 { 62 set sqlite_sync_count 0 63 execsql { 64 PRAGMA main.synchronous=full; 65 PRAGMA db2.synchronous=full; 66 BEGIN; 67 INSERT INTO t1 VALUES(3,4); 68 INSERT INTO t2 VALUES(5,6); 69 COMMIT; 70 } 71 ifcapable !dirsync { 72 incr sqlite_sync_count 3 73 } 74 set sqlite_sync_count 75} 10 76do_test sync-1.4 { 77 set sqlite_sync_count 0 78 execsql { 79 PRAGMA main.synchronous=off; 80 PRAGMA db2.synchronous=off; 81 BEGIN; 82 INSERT INTO t1 VALUES(5,6); 83 INSERT INTO t2 VALUES(7,8); 84 COMMIT; 85 } 86 set sqlite_sync_count 87} 0 88 89 90finish_test 91