2005-08-27 20:36:48 +04:00
|
|
|
# 2005 August 28
|
|
|
|
#
|
|
|
|
# The author disclaims copyright to this source code. In place of
|
|
|
|
# a legal notice, here is a blessing:
|
|
|
|
#
|
|
|
|
# May you do good and not evil.
|
|
|
|
# May you find forgiveness for yourself and forgive others.
|
|
|
|
# May you share freely, never taking more than you give.
|
|
|
|
#
|
|
|
|
#***********************************************************************
|
|
|
|
# This file implements regression tests for SQLite library.
|
|
|
|
#
|
|
|
|
# This file implements tests to verify that fsync is disabled when
|
|
|
|
# pragma synchronous=off even for multi-database commits.
|
|
|
|
#
|
2007-10-09 12:29:32 +04:00
|
|
|
# $Id: sync.test,v 1.6 2007/10/09 08:29:33 danielk1977 Exp $
|
2005-08-27 20:36:48 +04:00
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
|
|
|
|
#
|
2011-04-16 00:18:40 +04:00
|
|
|
# These tests are only applicable when pager pragma are
|
2007-10-09 12:29:32 +04:00
|
|
|
# enabled. Also, since every test uses an ATTACHed database, they
|
|
|
|
# are only run when ATTACH is enabled.
|
2005-08-27 20:36:48 +04:00
|
|
|
#
|
2007-10-09 12:29:32 +04:00
|
|
|
ifcapable !pager_pragmas||!attach {
|
2005-08-27 20:36:48 +04:00
|
|
|
finish_test
|
2006-01-31 18:19:45 +03:00
|
|
|
return
|
2005-08-27 20:36:48 +04:00
|
|
|
}
|
|
|
|
|
2011-04-16 00:18:40 +04:00
|
|
|
set sqlite_sync_count 0
|
|
|
|
proc cond_incr_sync_count {adj} {
|
|
|
|
global sqlite_sync_count
|
|
|
|
if {$::tcl_platform(platform) == "windows"} {
|
|
|
|
incr sqlite_sync_count $adj
|
|
|
|
} {
|
|
|
|
ifcapable !dirsync {
|
|
|
|
incr sqlite_sync_count $adj
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-27 20:36:48 +04:00
|
|
|
do_test sync-1.1 {
|
|
|
|
set sqlite_sync_count 0
|
2011-08-02 04:57:34 +04:00
|
|
|
forcedelete test2.db
|
|
|
|
forcedelete test2.db-journal
|
2005-08-27 20:36:48 +04:00
|
|
|
execsql {
|
2006-02-11 04:25:50 +03:00
|
|
|
PRAGMA fullfsync=OFF;
|
2005-08-27 20:36:48 +04:00
|
|
|
CREATE TABLE t1(a,b);
|
|
|
|
ATTACH DATABASE 'test2.db' AS db2;
|
|
|
|
CREATE TABLE db2.t2(x,y);
|
|
|
|
}
|
2011-04-16 00:18:40 +04:00
|
|
|
cond_incr_sync_count 2
|
2005-08-27 20:36:48 +04:00
|
|
|
set sqlite_sync_count
|
|
|
|
} 8
|
2006-01-17 12:35:01 +03:00
|
|
|
ifcapable pager_pragmas {
|
|
|
|
do_test sync-1.2 {
|
|
|
|
set sqlite_sync_count 0
|
|
|
|
execsql {
|
|
|
|
PRAGMA main.synchronous=on;
|
|
|
|
PRAGMA db2.synchronous=on;
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t1 VALUES(1,2);
|
|
|
|
INSERT INTO t2 VALUES(3,4);
|
|
|
|
COMMIT;
|
|
|
|
}
|
2011-04-16 00:18:40 +04:00
|
|
|
cond_incr_sync_count 3
|
2006-01-17 12:35:01 +03:00
|
|
|
set sqlite_sync_count
|
|
|
|
} 8
|
|
|
|
}
|
2005-08-27 20:36:48 +04:00
|
|
|
do_test sync-1.3 {
|
|
|
|
set sqlite_sync_count 0
|
|
|
|
execsql {
|
|
|
|
PRAGMA main.synchronous=full;
|
|
|
|
PRAGMA db2.synchronous=full;
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t1 VALUES(3,4);
|
|
|
|
INSERT INTO t2 VALUES(5,6);
|
|
|
|
COMMIT;
|
|
|
|
}
|
2011-04-16 00:18:40 +04:00
|
|
|
cond_incr_sync_count 3
|
2005-08-27 20:36:48 +04:00
|
|
|
set sqlite_sync_count
|
|
|
|
} 10
|
2006-01-17 12:35:01 +03:00
|
|
|
ifcapable pager_pragmas {
|
|
|
|
do_test sync-1.4 {
|
|
|
|
set sqlite_sync_count 0
|
|
|
|
execsql {
|
|
|
|
PRAGMA main.synchronous=off;
|
|
|
|
PRAGMA db2.synchronous=off;
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t1 VALUES(5,6);
|
|
|
|
INSERT INTO t2 VALUES(7,8);
|
|
|
|
COMMIT;
|
|
|
|
}
|
|
|
|
set sqlite_sync_count
|
|
|
|
} 0
|
|
|
|
}
|
2005-08-27 20:36:48 +04:00
|
|
|
|
|
|
|
|
|
|
|
finish_test
|