OLD | NEW |
1 # 2005 August 28 | 1 # 2005 August 28 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
11 # This file implements regression tests for SQLite library. | 11 # This file implements regression tests for SQLite library. |
12 # | 12 # |
13 # This file implements tests to verify that fsync is disabled when | 13 # This file implements tests to verify that fsync is disabled when |
14 # pragma synchronous=off even for multi-database commits. | 14 # pragma synchronous=off even for multi-database commits. |
15 # | 15 # |
16 # $Id: sync.test,v 1.6 2007/10/09 08:29:33 danielk1977 Exp $ | 16 # $Id: sync.test,v 1.6 2007/10/09 08:29:33 danielk1977 Exp $ |
17 | 17 |
18 set testdir [file dirname $argv0] | 18 set testdir [file dirname $argv0] |
19 source $testdir/tester.tcl | 19 source $testdir/tester.tcl |
20 | 20 |
21 # | 21 # |
22 # These tests are only applicable on unix when pager pragma are | 22 # These tests are only applicable when pager pragma are |
23 # enabled. Also, since every test uses an ATTACHed database, they | 23 # enabled. Also, since every test uses an ATTACHed database, they |
24 # are only run when ATTACH is enabled. | 24 # are only run when ATTACH is enabled. |
25 # | 25 # |
26 if {$::tcl_platform(platform)!="unix"} { | |
27 finish_test | |
28 return | |
29 } | |
30 ifcapable !pager_pragmas||!attach { | 26 ifcapable !pager_pragmas||!attach { |
31 finish_test | 27 finish_test |
32 return | 28 return |
33 } | 29 } |
34 | 30 |
| 31 set sqlite_sync_count 0 |
| 32 proc cond_incr_sync_count {adj} { |
| 33 global sqlite_sync_count |
| 34 if {$::tcl_platform(platform) == "windows"} { |
| 35 incr sqlite_sync_count $adj |
| 36 } { |
| 37 ifcapable !dirsync { |
| 38 incr sqlite_sync_count $adj |
| 39 } |
| 40 } |
| 41 } |
| 42 |
35 do_test sync-1.1 { | 43 do_test sync-1.1 { |
36 set sqlite_sync_count 0 | 44 set sqlite_sync_count 0 |
37 file delete -force test2.db | 45 forcedelete test2.db |
38 file delete -force test2.db-journal | 46 forcedelete test2.db-journal |
39 execsql { | 47 execsql { |
40 PRAGMA fullfsync=OFF; | 48 PRAGMA fullfsync=OFF; |
41 CREATE TABLE t1(a,b); | 49 CREATE TABLE t1(a,b); |
42 ATTACH DATABASE 'test2.db' AS db2; | 50 ATTACH DATABASE 'test2.db' AS db2; |
43 CREATE TABLE db2.t2(x,y); | 51 CREATE TABLE db2.t2(x,y); |
44 } | 52 } |
45 ifcapable !dirsync { | 53 cond_incr_sync_count 2 |
46 incr sqlite_sync_count 2 | |
47 } | |
48 set sqlite_sync_count | 54 set sqlite_sync_count |
49 } 8 | 55 } 8 |
50 ifcapable pager_pragmas { | 56 ifcapable pager_pragmas { |
51 do_test sync-1.2 { | 57 do_test sync-1.2 { |
52 set sqlite_sync_count 0 | 58 set sqlite_sync_count 0 |
53 execsql { | 59 execsql { |
54 PRAGMA main.synchronous=on; | 60 PRAGMA main.synchronous=on; |
55 PRAGMA db2.synchronous=on; | 61 PRAGMA db2.synchronous=on; |
56 BEGIN; | 62 BEGIN; |
57 INSERT INTO t1 VALUES(1,2); | 63 INSERT INTO t1 VALUES(1,2); |
58 INSERT INTO t2 VALUES(3,4); | 64 INSERT INTO t2 VALUES(3,4); |
59 COMMIT; | 65 COMMIT; |
60 } | 66 } |
61 ifcapable !dirsync { | 67 cond_incr_sync_count 3 |
62 incr sqlite_sync_count 3 | |
63 } | |
64 set sqlite_sync_count | 68 set sqlite_sync_count |
65 } 8 | 69 } 8 |
66 } | 70 } |
67 do_test sync-1.3 { | 71 do_test sync-1.3 { |
68 set sqlite_sync_count 0 | 72 set sqlite_sync_count 0 |
69 execsql { | 73 execsql { |
70 PRAGMA main.synchronous=full; | 74 PRAGMA main.synchronous=full; |
71 PRAGMA db2.synchronous=full; | 75 PRAGMA db2.synchronous=full; |
72 BEGIN; | 76 BEGIN; |
73 INSERT INTO t1 VALUES(3,4); | 77 INSERT INTO t1 VALUES(3,4); |
74 INSERT INTO t2 VALUES(5,6); | 78 INSERT INTO t2 VALUES(5,6); |
75 COMMIT; | 79 COMMIT; |
76 } | 80 } |
77 ifcapable !dirsync { | 81 cond_incr_sync_count 3 |
78 incr sqlite_sync_count 3 | |
79 } | |
80 set sqlite_sync_count | 82 set sqlite_sync_count |
81 } 10 | 83 } 10 |
82 ifcapable pager_pragmas { | 84 ifcapable pager_pragmas { |
83 do_test sync-1.4 { | 85 do_test sync-1.4 { |
84 set sqlite_sync_count 0 | 86 set sqlite_sync_count 0 |
85 execsql { | 87 execsql { |
86 PRAGMA main.synchronous=off; | 88 PRAGMA main.synchronous=off; |
87 PRAGMA db2.synchronous=off; | 89 PRAGMA db2.synchronous=off; |
88 BEGIN; | 90 BEGIN; |
89 INSERT INTO t1 VALUES(5,6); | 91 INSERT INTO t1 VALUES(5,6); |
90 INSERT INTO t2 VALUES(7,8); | 92 INSERT INTO t2 VALUES(7,8); |
91 COMMIT; | 93 COMMIT; |
92 } | 94 } |
93 set sqlite_sync_count | 95 set sqlite_sync_count |
94 } 0 | 96 } 0 |
95 } | 97 } |
96 | 98 |
97 | 99 |
98 finish_test | 100 finish_test |
OLD | NEW |