SQLite

Check-in [4cde92909c]
Login

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

Overview
Comment:Change wal.test and walhook.test so that they work with DEFAULT_AUTOVACUUM=1 builds.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4cde92909c20982f7d4e6b550f55d786df398ccd
User & Date: dan 2010-05-07 12:49:23.000
Context
2010-05-07
13:52
Fix a recently introduced problem in wal.test. (check-in: 79b52d0ff7 user: dan tags: trunk)
12:49
Change wal.test and walhook.test so that they work with DEFAULT_AUTOVACUUM=1 builds. (check-in: 4cde92909c user: dan tags: trunk)
09:43
Test another IO error case in wal.c. (check-in: 8b3b5ab8fa user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/permutations.test.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
  crash7.test               memleak.test              sqllimits1.test
  crash.test                memsubsys1.test           thread001.test
  exclusive3.test           memsubsys2.test           thread002.test
  fts3.test                 misc7.test                utf16.test
  fuzz_malloc.test          misuse.test               veryquick.test
  fuzz.test                 mutex2.test               vtab_err.test
  lookaside.test            fuzz3.test                savepoint4.test
  savepoint6.test
}
set ALLTESTS [list]
foreach filename [glob $testdir/*.test] {
  set filename [file tail $filename]
  if {[lsearch $EXCLUDE $filename] < 0} { lappend ALLTESTS $filename }
}
set ALLTESTS [lsort $ALLTESTS]







<







69
70
71
72
73
74
75

76
77
78
79
80
81
82
  crash7.test               memleak.test              sqllimits1.test
  crash.test                memsubsys1.test           thread001.test
  exclusive3.test           memsubsys2.test           thread002.test
  fts3.test                 misc7.test                utf16.test
  fuzz_malloc.test          misuse.test               veryquick.test
  fuzz.test                 mutex2.test               vtab_err.test
  lookaside.test            fuzz3.test                savepoint4.test

}
set ALLTESTS [list]
foreach filename [glob $testdir/*.test] {
  set filename [file tail $filename]
  if {[lsearch $EXCLUDE $filename] < 0} { lappend ALLTESTS $filename }
}
set ALLTESTS [lsort $ALLTESTS]
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
  incrvacuum.test
  ioerr.test
  corrupt4.test 
  io.test 
  crash8.test 
  async4.test 
  bigfile.test
  savepoint6.test
}]

if {[info commands register_demovfs] != ""} {
  run_tests "demovfs" -description {
    Check that pages are synced before being written (test_journal.c).
  } -initialize {
    register_demovfs







<







739
740
741
742
743
744
745

746
747
748
749
750
751
752
  incrvacuum.test
  ioerr.test
  corrupt4.test 
  io.test 
  crash8.test 
  async4.test 
  bigfile.test

}]

if {[info commands register_demovfs] != ""} {
  run_tests "demovfs" -description {
    Check that pages are synced before being written (test_journal.c).
  } -initialize {
    register_demovfs
Changes to test/wal.test.
29
30
31
32
33
34
35

36
37
38
39
40
41
42
proc blob {nByte} {
  incr ::blobcnt
  return [string range [string repeat "${::blobcnt}x" $nByte] 1 $nByte]
}

proc sqlite3_wal {args} {
  eval sqlite3 $args

  [lindex $args 0] eval { PRAGMA page_size = 1024 }
  [lindex $args 0] eval { PRAGMA journal_mode = wal }
  [lindex $args 0] eval { PRAGMA synchronous = normal }
  [lindex $args 0] function blob blob
}

proc log_file_size {nFrame pgsz} {







>







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
proc blob {nByte} {
  incr ::blobcnt
  return [string range [string repeat "${::blobcnt}x" $nByte] 1 $nByte]
}

proc sqlite3_wal {args} {
  eval sqlite3 $args
  [lindex $args 0] eval { PRAGMA auto_vacuum = 0 }
  [lindex $args 0] eval { PRAGMA page_size = 1024 }
  [lindex $args 0] eval { PRAGMA journal_mode = wal }
  [lindex $args 0] eval { PRAGMA synchronous = normal }
  [lindex $args 0] function blob blob
}

proc log_file_size {nFrame pgsz} {
57
58
59
60
61
62
63

64
65
66
67
68
69
70
# wal-4.*: Test savepoint/statement rollback.
# wal-5.*: Test the temp database.
# wal-6.*: Test creating databases with different page sizes.
#
#

do_test wal-0.1 {

  execsql { PRAGMA synchronous = normal }
  execsql { PRAGMA journal_mode = wal }
} {wal}
do_test wal-0.2 {
  file size test.db
} {1024}








>







58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# wal-4.*: Test savepoint/statement rollback.
# wal-5.*: Test the temp database.
# wal-6.*: Test creating databases with different page sizes.
#
#

do_test wal-0.1 {
  execsql { PRAGMA auto_vacuum = 0 }
  execsql { PRAGMA synchronous = normal }
  execsql { PRAGMA journal_mode = wal }
} {wal}
do_test wal-0.2 {
  file size test.db
} {1024}

333
334
335
336
337
338
339

340
341
342
343
344
345
346
  sqlite3_simulate_device -sectorsize $sector
  foreach pgsz {512 1024 2048 4096} {
    file delete -force test.db test.db-wal
    do_test wal-6.$sector.$pgsz.1 {
      sqlite3 db test.db -vfs devsym
      execsql "
        PRAGMA page_size = $pgsz;

        PRAGMA journal_mode = wal;
      "
      execsql "
        CREATE TABLE t1(a, b);
        INSERT INTO t1 VALUES(1, 2);
      "
      db close







>







335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
  sqlite3_simulate_device -sectorsize $sector
  foreach pgsz {512 1024 2048 4096} {
    file delete -force test.db test.db-wal
    do_test wal-6.$sector.$pgsz.1 {
      sqlite3 db test.db -vfs devsym
      execsql "
        PRAGMA page_size = $pgsz;
        PRAGMA auto_vacuum = 0;
        PRAGMA journal_mode = wal;
      "
      execsql "
        CREATE TABLE t1(a, b);
        INSERT INTO t1 VALUES(1, 2);
      "
      db close
904
905
906
907
908
909
910

911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
} {0}

do_test wal-13.2.1 {
  sqlite3 db test.db
  execsql { SELECT count(*) FROM t2 }
} {1}
do_test wal-13.2.2 {

  for {set i 0} {$i < 16} {incr i} {
    execsql { INSERT INTO t2 SELECT randomblob(400), randomblob(400) FROM t2 }
  }
  execsql { SELECT count(*) FROM t2 }
} [expr int(pow(2, 16))]
do_test wal-13.2.1 {
  file size test.db-wal
} [log_file_size 33123 1024]

foreach code [list {
  set tn 3
  proc buddy {tcl} { uplevel #0 $tcl }
} {
  set tn 4
  set ::buddy [launch_testfixture]







>

|



|

|







907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
} {0}

do_test wal-13.2.1 {
  sqlite3 db test.db
  execsql { SELECT count(*) FROM t2 }
} {1}
do_test wal-13.2.2 {
  db function blob blob
  for {set i 0} {$i < 16} {incr i} {
    execsql { INSERT INTO t2 SELECT blob(400), blob(400) FROM t2 }
  }
  execsql { SELECT count(*) FROM t2 }
} [expr int(pow(2, 16))]
do_test wal-13.2.3 {
  file size test.db-wal
} [log_file_size 33502 1024]

foreach code [list {
  set tn 3
  proc buddy {tcl} { uplevel #0 $tcl }
} {
  set tn 4
  set ::buddy [launch_testfixture]
1009
1010
1011
1012
1013
1014
1015

1016
1017
1018
1019
1020
1021
1022
# The following block of tests - wal-15.* - focus on testing the 
# implementation of the sqlite3_wal_checkpoint() interface.
#
file delete -force test.db test.db-wal
sqlite3 db test.db
do_test wal-15.1 {
  execsql {

    PRAGMA page_size = 1024;
    PRAGMA journal_mode = WAL;
  }
  execsql {
    CREATE TABLE t1(a, b);
    INSERT INTO t1 VALUES(1, 2);
  }







>







1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
# The following block of tests - wal-15.* - focus on testing the 
# implementation of the sqlite3_wal_checkpoint() interface.
#
file delete -force test.db test.db-wal
sqlite3 db test.db
do_test wal-15.1 {
  execsql {
    PRAGMA auto_vacuum = 0;
    PRAGMA page_size = 1024;
    PRAGMA journal_mode = WAL;
  }
  execsql {
    CREATE TABLE t1(a, b);
    INSERT INTO t1 VALUES(1, 2);
  }
1105
1106
1107
1108
1109
1110
1111


1112
1113
1114
1115
1116
1117
1118
  do_test wal-16.$tn.1 {
    file delete -force test2.db test2.db-wal test2.db-journal
    file delete -force test.db test.db-wal test.db-journal

    sqlite3 db test.db
    execsql {
      ATTACH 'test2.db' AS aux;


      PRAGMA main.journal_mode = WAL;
      PRAGMA aux.journal_mode = WAL;
      PRAGMA synchronous = NORMAL;
    }
  } {wal wal}

  do_test wal-16.$tn.2 {







>
>







1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
  do_test wal-16.$tn.1 {
    file delete -force test2.db test2.db-wal test2.db-journal
    file delete -force test.db test.db-wal test.db-journal

    sqlite3 db test.db
    execsql {
      ATTACH 'test2.db' AS aux;
      PRAGMA main.auto_vacuum = 0;
      PRAGMA aux.auto_vacuum = 0;
      PRAGMA main.journal_mode = WAL;
      PRAGMA aux.journal_mode = WAL;
      PRAGMA synchronous = NORMAL;
    }
  } {wal wal}

  do_test wal-16.$tn.2 {
1298
1299
1300
1301
1302
1303
1304




1305
1306
1307
1308
1309
1310
1311
  6   4096    1
  7   8192    1
  8  16384    1
  9  32768    1
 10  65536    0
 11   1020    0
} {





  for {set pg 1} {$pg <= 3} {incr pg} {
    file copy -force testX.db test.db
    file delete -force test.db-wal
  
    # Check that the database now exists and consists of three pages. And
    # that there is no associated wal file.







>
>
>
>







1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
  6   4096    1
  7   8192    1
  8  16384    1
  9  32768    1
 10  65536    0
 11   1020    0
} {

  if {$::SQLITE_MAX_PAGE_SIZE < $pgsz} {
    set works 0
  }

  for {set pg 1} {$pg <= 3} {incr pg} {
    file copy -force testX.db test.db
    file delete -force test.db-wal
  
    # Check that the database now exists and consists of three pages. And
    # that there is no associated wal file.
Changes to test/walhook.test.
32
33
34
35
36
37
38

39
40
41
42
43
44
45
  return 0
}
db wal_hook wal_hook

do_test walhook-1.1 {
  execsql { 
    PRAGMA page_size = 1024;

    PRAGMA journal_mode = wal;
    PRAGMA synchronous = normal;
    CREATE TABLE t1(i PRIMARY KEY, j);
  }
  set ::wal_hook
} {main 3}








>







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  return 0
}
db wal_hook wal_hook

do_test walhook-1.1 {
  execsql { 
    PRAGMA page_size = 1024;
    PRAGMA auto_vacuum = 0;
    PRAGMA journal_mode = wal;
    PRAGMA synchronous = normal;
    CREATE TABLE t1(i PRIMARY KEY, j);
  }
  set ::wal_hook
} {main 3}