blob: 14252b5c08af33a59917bc79269cced40ed2aacb [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#
danielk19775a8f9372007-10-09 08:29:32 +000016# $Id: sync.test,v 1.6 2007/10/09 08:29:33 danielk1977 Exp $
drh2c8997b2005-08-27 16:36:48 +000017
18set testdir [file dirname $argv0]
19source $testdir/tester.tcl
20
21#
shaneh9dd6e082011-04-15 20:18:40 +000022# These tests are only applicable when pager pragma are
danielk19775a8f9372007-10-09 08:29:32 +000023# enabled. Also, since every test uses an ATTACHed database, they
24# are only run when ATTACH is enabled.
drh2c8997b2005-08-27 16:36:48 +000025#
danielk19775a8f9372007-10-09 08:29:32 +000026ifcapable !pager_pragmas||!attach {
drh2c8997b2005-08-27 16:36:48 +000027 finish_test
drh7aae9942006-01-31 15:19:45 +000028 return
drh2c8997b2005-08-27 16:36:48 +000029}
30
shaneh9dd6e082011-04-15 20:18:40 +000031set sqlite_sync_count 0
32proc 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
drh2c8997b2005-08-27 16:36:48 +000043do_test sync-1.1 {
44 set sqlite_sync_count 0
mistachkinfda06be2011-08-02 00:57:34 +000045 forcedelete test2.db
46 forcedelete test2.db-journal
drh2c8997b2005-08-27 16:36:48 +000047 execsql {
drhac530b12006-02-11 01:25:50 +000048 PRAGMA fullfsync=OFF;
drh2c8997b2005-08-27 16:36:48 +000049 CREATE TABLE t1(a,b);
50 ATTACH DATABASE 'test2.db' AS db2;
51 CREATE TABLE db2.t2(x,y);
52 }
shaneh9dd6e082011-04-15 20:18:40 +000053 cond_incr_sync_count 2
drh2c8997b2005-08-27 16:36:48 +000054 set sqlite_sync_count
55} 8
danielk19773bdca9c2006-01-17 09:35:01 +000056ifcapable 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 }
shaneh9dd6e082011-04-15 20:18:40 +000067 cond_incr_sync_count 3
danielk19773bdca9c2006-01-17 09:35:01 +000068 set sqlite_sync_count
69 } 8
70}
drh2c8997b2005-08-27 16:36:48 +000071do_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 }
shaneh9dd6e082011-04-15 20:18:40 +000081 cond_incr_sync_count 3
drh2c8997b2005-08-27 16:36:48 +000082 set sqlite_sync_count
83} 10
danielk19773bdca9c2006-01-17 09:35:01 +000084ifcapable 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}
drh2c8997b2005-08-27 16:36:48 +000098
99
100finish_test