blob: 023425e6b1dac6b540ff6fce7c747e3f7db26d5c [file] [log] [blame]
drh2c8997b2005-08-27 16:36:48 +00001# 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#
drh2c8997b2005-08-27 16:36:48 +000016
17set testdir [file dirname $argv0]
18source $testdir/tester.tcl
19
20#
shaneh9dd6e082011-04-15 20:18:40 +000021# These tests are only applicable when pager pragma are
danielk19775a8f9372007-10-09 08:29:32 +000022# enabled. Also, since every test uses an ATTACHed database, they
23# are only run when ATTACH is enabled.
drh2c8997b2005-08-27 16:36:48 +000024#
danielk19775a8f9372007-10-09 08:29:32 +000025ifcapable !pager_pragmas||!attach {
drh2c8997b2005-08-27 16:36:48 +000026 finish_test
drh7aae9942006-01-31 15:19:45 +000027 return
drh2c8997b2005-08-27 16:36:48 +000028}
dan69aedc82018-01-13 13:07:49 +000029if {[atomic_batch_write test.db]} {
30 finish_test
31 return
32}
drh2c8997b2005-08-27 16:36:48 +000033
shaneh9dd6e082011-04-15 20:18:40 +000034set 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
drh6d258992016-02-04 09:48:12 +000039 } else {
shaneh9dd6e082011-04-15 20:18:40 +000040 ifcapable !dirsync {
41 incr sqlite_sync_count $adj
42 }
43 }
44}
45
drh2c8997b2005-08-27 16:36:48 +000046do_test sync-1.1 {
47 set sqlite_sync_count 0
mistachkinfda06be2011-08-02 00:57:34 +000048 forcedelete test2.db
49 forcedelete test2.db-journal
drh2c8997b2005-08-27 16:36:48 +000050 execsql {
drhac530b12006-02-11 01:25:50 +000051 PRAGMA fullfsync=OFF;
drh2c8997b2005-08-27 16:36:48 +000052 CREATE TABLE t1(a,b);
53 ATTACH DATABASE 'test2.db' AS db2;
54 CREATE TABLE db2.t2(x,y);
55 }
shaneh9dd6e082011-04-15 20:18:40 +000056 cond_incr_sync_count 2
drh2c8997b2005-08-27 16:36:48 +000057 set sqlite_sync_count
58} 8
danielk19773bdca9c2006-01-17 09:35:01 +000059ifcapable 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 }
drh6d258992016-02-04 09:48:12 +000070 cond_incr_sync_count 4
danielk19773bdca9c2006-01-17 09:35:01 +000071 set sqlite_sync_count
drh6d258992016-02-04 09:48:12 +000072 } 9
danielk19773bdca9c2006-01-17 09:35:01 +000073}
drh2c8997b2005-08-27 16:36:48 +000074do_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 }
drh6d258992016-02-04 09:48:12 +000084 cond_incr_sync_count 4
drh2c8997b2005-08-27 16:36:48 +000085 set sqlite_sync_count
drh6d258992016-02-04 09:48:12 +000086} 11
danielk19773bdca9c2006-01-17 09:35:01 +000087ifcapable pager_pragmas {
dan05accd22016-04-27 18:54:49 +000088if {[permutation]!="journaltest"} {
danielk19773bdca9c2006-01-17 09:35:01 +000089 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}
dan05accd22016-04-27 18:54:49 +0000102}
drh2c8997b2005-08-27 16:36:48 +0000103
104
105finish_test