drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 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 | # |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 16 | |
| 17 | set testdir [file dirname $argv0] |
| 18 | source $testdir/tester.tcl |
| 19 | |
| 20 | # |
shaneh | 9dd6e08 | 2011-04-15 20:18:40 +0000 | [diff] [blame] | 21 | # These tests are only applicable when pager pragma are |
danielk1977 | 5a8f937 | 2007-10-09 08:29:32 +0000 | [diff] [blame] | 22 | # enabled. Also, since every test uses an ATTACHed database, they |
| 23 | # are only run when ATTACH is enabled. |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 24 | # |
danielk1977 | 5a8f937 | 2007-10-09 08:29:32 +0000 | [diff] [blame] | 25 | ifcapable !pager_pragmas||!attach { |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 26 | finish_test |
drh | 7aae994 | 2006-01-31 15:19:45 +0000 | [diff] [blame] | 27 | return |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 28 | } |
dan | 69aedc8 | 2018-01-13 13:07:49 +0000 | [diff] [blame] | 29 | if {[atomic_batch_write test.db]} { |
| 30 | finish_test |
| 31 | return |
| 32 | } |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 33 | |
shaneh | 9dd6e08 | 2011-04-15 20:18:40 +0000 | [diff] [blame] | 34 | set sqlite_sync_count 0 |
| 35 | proc cond_incr_sync_count {adj} { |
| 36 | global sqlite_sync_count |
| 37 | if {$::tcl_platform(platform) == "windows"} { |
| 38 | incr sqlite_sync_count $adj |
drh | 6d25899 | 2016-02-04 09:48:12 +0000 | [diff] [blame] | 39 | } else { |
shaneh | 9dd6e08 | 2011-04-15 20:18:40 +0000 | [diff] [blame] | 40 | ifcapable !dirsync { |
| 41 | incr sqlite_sync_count $adj |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 46 | do_test sync-1.1 { |
| 47 | set sqlite_sync_count 0 |
mistachkin | fda06be | 2011-08-02 00:57:34 +0000 | [diff] [blame] | 48 | forcedelete test2.db |
| 49 | forcedelete test2.db-journal |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 50 | execsql { |
drh | ac530b1 | 2006-02-11 01:25:50 +0000 | [diff] [blame] | 51 | PRAGMA fullfsync=OFF; |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 52 | CREATE TABLE t1(a,b); |
| 53 | ATTACH DATABASE 'test2.db' AS db2; |
| 54 | CREATE TABLE db2.t2(x,y); |
| 55 | } |
shaneh | 9dd6e08 | 2011-04-15 20:18:40 +0000 | [diff] [blame] | 56 | cond_incr_sync_count 2 |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 57 | set sqlite_sync_count |
| 58 | } 8 |
danielk1977 | 3bdca9c | 2006-01-17 09:35:01 +0000 | [diff] [blame] | 59 | ifcapable 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 | } |
drh | 6d25899 | 2016-02-04 09:48:12 +0000 | [diff] [blame] | 70 | cond_incr_sync_count 4 |
danielk1977 | 3bdca9c | 2006-01-17 09:35:01 +0000 | [diff] [blame] | 71 | set sqlite_sync_count |
drh | 6d25899 | 2016-02-04 09:48:12 +0000 | [diff] [blame] | 72 | } 9 |
danielk1977 | 3bdca9c | 2006-01-17 09:35:01 +0000 | [diff] [blame] | 73 | } |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 74 | do_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 | } |
drh | 6d25899 | 2016-02-04 09:48:12 +0000 | [diff] [blame] | 84 | cond_incr_sync_count 4 |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 85 | set sqlite_sync_count |
drh | 6d25899 | 2016-02-04 09:48:12 +0000 | [diff] [blame] | 86 | } 11 |
danielk1977 | 3bdca9c | 2006-01-17 09:35:01 +0000 | [diff] [blame] | 87 | ifcapable pager_pragmas { |
dan | 05accd2 | 2016-04-27 18:54:49 +0000 | [diff] [blame] | 88 | if {[permutation]!="journaltest"} { |
danielk1977 | 3bdca9c | 2006-01-17 09:35:01 +0000 | [diff] [blame] | 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 | } |
dan | 05accd2 | 2016-04-27 18:54:49 +0000 | [diff] [blame] | 102 | } |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 103 | |
| 104 | |
| 105 | finish_test |