summaryrefslogtreecommitdiff
path: root/test/wal6.test
blob: ec31bb8b0fc3cfdd404d9874e854656534ca2541 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# 2010 December 1
#
# 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.  The
# focus of this file is testing the operation of the library in
# "PRAGMA journal_mode=WAL" mode.
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/lock_common.tcl
source $testdir/wal_common.tcl
source $testdir/malloc_common.tcl
ifcapable !wal {finish_test ; return }

#-------------------------------------------------------------------------
# Changing to WAL mode in one connection forces the change in others.
#
db close
forcedelete test.db

set all_journal_modes {delete persist truncate memory off}
foreach jmode $all_journal_modes {

	do_test wal6-1.0.$jmode {
    sqlite3 db test.db
    execsql "PRAGMA journal_mode = $jmode;"
	} $jmode

	do_test wal6-1.1.$jmode {
	  execsql {
	    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
	    INSERT INTO t1 VALUES(1,2);
	    SELECT * FROM t1;
	  }
	} {1 2}

# Under Windows, you'll get an error trying to delete
# a file this is already opened.  Close the first connection
# so the other tests work.
if {$tcl_platform(platform)=="windows"} {
  if {$jmode=="persist" || $jmode=="truncate"} {
    db close
  }
}

	do_test wal6-1.2.$jmode {
	  sqlite3 db2 test.db
	  execsql {
		PRAGMA journal_mode=WAL;
		INSERT INTO t1 VALUES(3,4);
		SELECT * FROM t1 ORDER BY a;
	  } db2
	} {wal 1 2 3 4}

if {$tcl_platform(platform)=="windows"} {
  if {$jmode=="persist" || $jmode=="truncate"} {
	  sqlite3 db test.db
  }
}

	do_test wal6-1.3.$jmode {
	  execsql {
		  SELECT * FROM t1 ORDER BY a;
	  }
	} {1 2 3 4}

	db close
	db2 close
  forcedelete test.db

}

finish_test