SQLite

Check-in [50f2f7dfd6]
Login

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

Overview
Comment:Further changes to test scripts so that the "inmemory_journal" permutation works.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 50f2f7dfd64f610982525fd7a0dd7c1ade67bebb
User & Date: dan 2010-07-03 16:37:45.000
Context
2010-07-03
17:13
Remove the unused xRename() method from the sqlite3_vfs object. Add better documentation on the xCurrentTimeInt64() method. (check-in: 51ec0e5432 user: drh tags: trunk)
16:37
Further changes to test scripts so that the "inmemory_journal" permutation works. (check-in: 50f2f7dfd6 user: dan tags: trunk)
13:59
Fix a bug in the permutations.test script. (check-in: 3b20ad03be user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/journal2.test.
12
13
14
15
16
17
18





19
20
21
22
23
24
25
#

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






set a_string_counter 1
proc a_string {n} {
  global a_string_counter
  incr a_string_counter
  string range [string repeat "${a_string_counter}." $n] 1 $n
}







>
>
>
>
>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#

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

if {[permutation] == "inmemory_journal"} {
  finish_test
  return
}

set a_string_counter 1
proc a_string {n} {
  global a_string_counter
  incr a_string_counter
  string range [string repeat "${a_string_counter}." $n] 1 $n
}
Changes to test/lookaside.test.
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
set testdir [file dirname $argv0]
source $testdir/tester.tcl

ifcapable !lookaside {
  finish_test
  return
}









catch {db close}
sqlite3_shutdown
sqlite3_config_pagecache 0 0
sqlite3_config_scratch 0 0
sqlite3_initialize
autoinstall_test_functions
sqlite3 db test.db

# Make sure sqlite3_db_config() and sqlite3_db_status are working.
#
do_test lookaside-1.1 {
  catch {sqlite3_config_error db}
} {0}

do_test lookaside-1.2 {
  sqlite3_db_config_lookaside db 1 18 18
} {0}
do_test lookaside-1.3 {
  sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0
} {0 0 0}

do_test lookaside-1.4 {
  db eval {CREATE TABLE t1(w,x,y,z);}
  foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0] break
  expr {$x==0 && $y<$z && $z==18}
} {0}
do_test lookaside-1.5 {
  foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 1] break







>
>
>
>
>
>
>
>














>






>







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
set testdir [file dirname $argv0]
source $testdir/tester.tcl

ifcapable !lookaside {
  finish_test
  return
}

# The tests in this file configure the lookaside allocator after a 
# connection is opened. This will not work if there is any "presql"
# configured (SQL run within the [sqlite3] wrapper in tester.tcl).
if {[info exists ::G(perm:presql)]} {
  finish_test
  return
}

catch {db close}
sqlite3_shutdown
sqlite3_config_pagecache 0 0
sqlite3_config_scratch 0 0
sqlite3_initialize
autoinstall_test_functions
sqlite3 db test.db

# Make sure sqlite3_db_config() and sqlite3_db_status are working.
#
do_test lookaside-1.1 {
  catch {sqlite3_config_error db}
} {0}

do_test lookaside-1.2 {
  sqlite3_db_config_lookaside db 1 18 18
} {0}
do_test lookaside-1.3 {
  sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0
} {0 0 0}

do_test lookaside-1.4 {
  db eval {CREATE TABLE t1(w,x,y,z);}
  foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0] break
  expr {$x==0 && $y<$z && $z==18}
} {0}
do_test lookaside-1.5 {
  foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 1] break
Changes to test/pagerfault.test.
10
11
12
13
14
15
16





17
18
19
20
21
22
23
24

25
26
27
28
29
30
31
#***********************************************************************
#

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






set a_string_counter 1
proc a_string {n} {
  global a_string_counter
  incr a_string_counter
  string range [string repeat "${a_string_counter}." $n] 1 $n
}
db func a_string a_string


if 1 {

#-------------------------------------------------------------------------
# Test fault-injection while rolling back a hot-journal file.
#
do_test pagerfault-1-pre1 {







>
>
>
>
>








>







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
#***********************************************************************
#

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

if {[permutation] == "inmemory_journal"} {
  finish_test
  return
}

set a_string_counter 1
proc a_string {n} {
  global a_string_counter
  incr a_string_counter
  string range [string repeat "${a_string_counter}." $n] 1 $n
}
db func a_string a_string


if 1 {

#-------------------------------------------------------------------------
# Test fault-injection while rolling back a hot-journal file.
#
do_test pagerfault-1-pre1 {
Changes to test/pagerfault2.test.
17
18
19
20
21
22
23





24
25
26
27
28
29
30
# run as part of pagerfault1.test.
#

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






sqlite3_memdebug_vfs_oom_test 0

set a_string_counter 1
proc a_string {n} {
  global a_string_counter
  incr a_string_counter







>
>
>
>
>







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# run as part of pagerfault1.test.
#

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

if {[permutation] == "inmemory_journal"} {
  finish_test
  return
}

sqlite3_memdebug_vfs_oom_test 0

set a_string_counter 1
proc a_string {n} {
  global a_string_counter
  incr a_string_counter
Changes to test/walfault.test.
46
47
48
49
50
51
52

53
54
55
56
57
58
59

60
61
62
63
64
65
66
  # 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" }

}

#--------------------------------------------------------------------------
# Test case walfault-2-* tests fault injection during recovery of a 
# short WAL file (a dozen frames or thereabouts).
#
do_test walfault-2-pre-1 {







>
|
|
|
|
|
|
|
>







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  # 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.
  #
  if {[permutation] != "inmemory_journal"} {
    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" }
  }
}

#--------------------------------------------------------------------------
# Test case walfault-2-* tests fault injection during recovery of a 
# short WAL file (a dozen frames or thereabouts).
#
do_test walfault-2-pre-1 {
119
120
121
122
123
124
125

126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141

142
143
144
145
146
147
148
} -test {
  faultsim_test_result {0 {}}
}


#--------------------------------------------------------------------------
#

faultsim_delete_and_reopen
faultsim_save_and_close
do_faultsim_test walfault-4 -prep {
  faultsim_restore_and_reopen
} -body {
  execsql {
    PRAGMA journal_mode = WAL;
    CREATE TABLE t1(a PRIMARY KEY, b);
    INSERT INTO t1 VALUES('a', 'b');
    PRAGMA wal_checkpoint;
    SELECT * FROM t1;
  }
} -test {
  faultsim_test_result {0 {wal a b}}
  faultsim_integrity_check
} 


#--------------------------------------------------------------------------
#
do_test walfault-5-pre-1 {
  faultsim_delete_and_reopen
  execsql {
    PRAGMA page_size = 512;







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







121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
} -test {
  faultsim_test_result {0 {}}
}


#--------------------------------------------------------------------------
#
if {[permutation] != "inmemory_journal"} {
  faultsim_delete_and_reopen
  faultsim_save_and_close
  do_faultsim_test walfault-4 -prep {
    faultsim_restore_and_reopen
  } -body {
    execsql {
      PRAGMA journal_mode = WAL;
      CREATE TABLE t1(a PRIMARY KEY, b);
      INSERT INTO t1 VALUES('a', 'b');
      PRAGMA wal_checkpoint;
      SELECT * FROM t1;
    }
  } -test {
    faultsim_test_result {0 {wal a b}}
    faultsim_integrity_check
  } 
}

#--------------------------------------------------------------------------
#
do_test walfault-5-pre-1 {
  faultsim_delete_and_reopen
  execsql {
    PRAGMA page_size = 512;