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 | # |
danielk1977 | 5a8f937 | 2007-10-09 08:29:32 +0000 | [diff] [blame] | 16 | # $Id: sync.test,v 1.6 2007/10/09 08:29:33 danielk1977 Exp $ |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 17 | |
| 18 | set testdir [file dirname $argv0] |
| 19 | source $testdir/tester.tcl |
| 20 | |
| 21 | # |
shaneh | 9dd6e08 | 2011-04-15 20:18:40 +0000 | [diff] [blame] | 22 | # These tests are only applicable when pager pragma are |
danielk1977 | 5a8f937 | 2007-10-09 08:29:32 +0000 | [diff] [blame] | 23 | # enabled. Also, since every test uses an ATTACHed database, they |
| 24 | # are only run when ATTACH is enabled. |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 25 | # |
danielk1977 | 5a8f937 | 2007-10-09 08:29:32 +0000 | [diff] [blame] | 26 | ifcapable !pager_pragmas||!attach { |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 27 | finish_test |
drh | 7aae994 | 2006-01-31 15:19:45 +0000 | [diff] [blame] | 28 | return |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 29 | } |
| 30 | |
shaneh | 9dd6e08 | 2011-04-15 20:18:40 +0000 | [diff] [blame] | 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 | |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 43 | do_test sync-1.1 { |
| 44 | set sqlite_sync_count 0 |
mistachkin | fda06be | 2011-08-02 00:57:34 +0000 | [diff] [blame] | 45 | forcedelete test2.db |
| 46 | forcedelete test2.db-journal |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 47 | execsql { |
drh | ac530b1 | 2006-02-11 01:25:50 +0000 | [diff] [blame] | 48 | PRAGMA fullfsync=OFF; |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 49 | CREATE TABLE t1(a,b); |
| 50 | ATTACH DATABASE 'test2.db' AS db2; |
| 51 | CREATE TABLE db2.t2(x,y); |
| 52 | } |
shaneh | 9dd6e08 | 2011-04-15 20:18:40 +0000 | [diff] [blame] | 53 | cond_incr_sync_count 2 |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 54 | set sqlite_sync_count |
| 55 | } 8 |
danielk1977 | 3bdca9c | 2006-01-17 09:35:01 +0000 | [diff] [blame] | 56 | ifcapable pager_pragmas { |
| 57 | do_test sync-1.2 { |
| 58 | set sqlite_sync_count 0 |
| 59 | execsql { |
| 60 | PRAGMA main.synchronous=on; |
| 61 | PRAGMA db2.synchronous=on; |
| 62 | BEGIN; |
| 63 | INSERT INTO t1 VALUES(1,2); |
| 64 | INSERT INTO t2 VALUES(3,4); |
| 65 | COMMIT; |
| 66 | } |
shaneh | 9dd6e08 | 2011-04-15 20:18:40 +0000 | [diff] [blame] | 67 | cond_incr_sync_count 3 |
danielk1977 | 3bdca9c | 2006-01-17 09:35:01 +0000 | [diff] [blame] | 68 | set sqlite_sync_count |
| 69 | } 8 |
| 70 | } |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 71 | do_test sync-1.3 { |
| 72 | set sqlite_sync_count 0 |
| 73 | execsql { |
| 74 | PRAGMA main.synchronous=full; |
| 75 | PRAGMA db2.synchronous=full; |
| 76 | BEGIN; |
| 77 | INSERT INTO t1 VALUES(3,4); |
| 78 | INSERT INTO t2 VALUES(5,6); |
| 79 | COMMIT; |
| 80 | } |
shaneh | 9dd6e08 | 2011-04-15 20:18:40 +0000 | [diff] [blame] | 81 | cond_incr_sync_count 3 |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 82 | set sqlite_sync_count |
| 83 | } 10 |
danielk1977 | 3bdca9c | 2006-01-17 09:35:01 +0000 | [diff] [blame] | 84 | ifcapable pager_pragmas { |
| 85 | do_test sync-1.4 { |
| 86 | set sqlite_sync_count 0 |
| 87 | execsql { |
| 88 | PRAGMA main.synchronous=off; |
| 89 | PRAGMA db2.synchronous=off; |
| 90 | BEGIN; |
| 91 | INSERT INTO t1 VALUES(5,6); |
| 92 | INSERT INTO t2 VALUES(7,8); |
| 93 | COMMIT; |
| 94 | } |
| 95 | set sqlite_sync_count |
| 96 | } 0 |
| 97 | } |
drh | 2c8997b | 2005-08-27 16:36:48 +0000 | [diff] [blame] | 98 | |
| 99 | |
| 100 | finish_test |