SQLite

Check-in [f4b9003a2d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merge with [15abbc3416].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | wal-incr-ckpt
Files: files | file ages | folders
SHA1: f4b9003a2d3db88eaabb4b291e6cea8e8ea6ff51
User & Date: dan 2010-06-01 14:30:49.000
Context
2010-06-01
15:24
The incremental checkpoint feature is not perfect yet, but it is working well enough to merge it into the trunk. (check-in: 1d3e569e59 user: drh tags: trunk)
14:30
Merge with [15abbc3416]. (Closed-Leaf check-in: f4b9003a2d user: dan tags: wal-incr-ckpt)
14:12
If an attempt to get a read-lock on the WAL fails with SQLITE_BUSY_RECOVER, call the busy-handler at the btree level. (check-in: ce64496509 user: dan tags: wal-incr-ckpt)
2010-05-31
06:38
Changes to the way one of the WAL/OOM tests works. (check-in: 15abbc3416 user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/malloc_common.tcl.
18
19
20
21
22
23
24





















































































25
26
27
28
29
30
31
#
ifcapable builtin_test {
  set MEMDEBUG 1
} else {
  set MEMDEBUG 0
  return 0
}






















































































# Usage: do_malloc_test <test number> <options...>
#
# The first argument, <test number>, is an integer used to name the
# tests executed by this proc. Options are as follows:
#
#     -tclprep          TCL script to run to prepare test.







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#
ifcapable builtin_test {
  set MEMDEBUG 1
} else {
  set MEMDEBUG 0
  return 0
}

# The following procs are used as [do_faultsim_test] when injecting OOM
# faults into test cases.
#
proc oom_injectstart {nRepeat iFail} {
  sqlite3_memdebug_fail $iFail -repeat $nRepeat
}
proc oom_injectstop {} {
  sqlite3_memdebug_fail -1
}

# This command is only useful when used by the -test script of a 
# [do_faultsim_test] test case.
#
proc faultsim_test_result {args} {
  upvar testrc testrc testresult testresult testnfail testnfail
  set t [list $testrc $testresult]
  set r [concat $args [list {1 {out of memory}}]]
  if { ($testnfail==0 && $t != [lindex $r 0]) || [lsearch $r $t]<0 } {
    error "nfail=$testnfail rc=$testrc result=$testresult"
  }
}

# Usage do_faultsim_test NAME ?OPTIONS...? 
#
# The first argument, <test number>, is used as a prefix of the test names
# taken by tests executed by this command. Options are as follows. All
# options take a single argument.
#
#     -injectstart      Script to enable fault-injection.
#
#     -injectstop       Script to disable fault-injection.
#
#     -prep             Script to execute before -body.
#
#     -body             Script to execute (with fault injection).
#
#     -test             Script to execute after -body.
#
proc do_faultsim_test {testname args} {

  set DEFAULT(-injectstart) {oom_injectstart 0}
  set DEFAULT(-injectstop)  {oom_injectstop}
  set DEFAULT(-prep)        ""
  set DEFAULT(-body)        ""
  set DEFAULT(-test)        ""

  array set O [array get DEFAULT]
  array set O $args
  foreach o [array names O] {
    if {[info exists DEFAULT($o)]==0} { error "unknown option: $o" }
  }

  proc faultsim_test_proc {testrc testresult testnfail} $O(-test)

  set stop 0
  for {set iFail 1} {!$stop} {incr iFail} {

    # Evaluate the -prep script.
    #
    eval $O(-prep)

    # Start the fault-injection. Run the -body script. Stop the fault
    # injection. Local var $nfail is set to the total number of faults 
    # injected into the system this trial.
    #
    eval $O(-injectstart) $iFail
    set rc [catch $O(-body) res]
    set nfail [eval $O(-injectstop)]

    # Run the -test script. If it throws no error, consider this trial
    # sucessful. If it does throw an error, cause a [do_test] test to
    # fail (and print out the unexpected exception thrown by the -test
    # script at the same time).
    #
    set rc [catch [list faultsim_test_proc $rc $res $nfail] res]
    if {$rc == 0} {set res ok}
    do_test $testname.$iFail [list list $rc $res] {0 ok}

    # If no faults where injected this trial, don't bother running
    # any more. This test is finished.
    #
    if {$nfail==0} { set stop 1 }
  }
}

# Usage: do_malloc_test <test number> <options...>
#
# The first argument, <test number>, is an integer used to name the
# tests executed by this proc. Options are as follows:
#
#     -tclprep          TCL script to run to prepare test.
Changes to test/walfault.test.
15
16
17
18
19
20
21
22




23

24

25















26


27
28
29
30
31
32
33

set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/malloc_common.tcl

ifcapable !wal {finish_test ; return }

do_malloc_test walfault-oom-1 -sqlbody {




  PRAGMA journal_mode = WAL;

  CREATE TABLE t1(a, b);

  INSERT INTO t1 VALUES(1, 2);















  PRAGMA wal_checkpoint;


}

do_malloc_test walfault-oom-2 -tclprep {
  execsql {
    PRAGMA journal_mode = WAL;
    BEGIN;
      CREATE TABLE x(y, z, UNIQUE(y, z));







|
>
>
>
>
|
>
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>







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

set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/malloc_common.tcl

ifcapable !wal {finish_test ; return }

do_faultsim_test walfault-oom-1 -prep {
  catch { db close }
  file delete -force test.db test.db-wal test.db-journal
  sqlite3 db test.db
} -body {
  db eval { PRAGMA main.journal_mode = WAL }
} -test {

  faultsim_test_result {0 wal}

  # Test that the connection that encountered an error as part of 
  # "PRAGMA journal_mode = WAL" and a new connection use the same
  # journal mode when accessing the database.
  #
  # If "PRAGMA journal_mode" is executed immediately, connection [db] (the 
  # one that hit the error in journal_mode="WAL") might return "wal" even 
  # if it failed to switch the database to WAL mode. This is not considered 
  # a problem. When it tries to read the database, connection [db] correctly 
  # recognizes that it is a rollback database and switches back to a 
  # rollback compatible journal mode.
  #
  set jm  [db one  {SELECT * FROM sqlite_master ; PRAGMA main.journal_mode}]
  sqlite3 db2 test.db
  set jm2 [db2 one {SELECT * FROM sqlite_master ; PRAGMA main.journal_mode}]
  db2 close

  if { $jm!=$jm2 } { error "Journal modes do not match: $jm $jm2" }
  if { $testrc==0 && $jm!="wal" } { error "Journal mode is not WAL" }
}

do_malloc_test walfault-oom-2 -tclprep {
  execsql {
    PRAGMA journal_mode = WAL;
    BEGIN;
      CREATE TABLE x(y, z, UNIQUE(y, z));