SQLite

Check-in [7bd8ba084e]
Login

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

Overview
Comment:Fix some problems with running test scripts with the inmemory_journal permutation.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | experimental
Files: files | file ages | folders
SHA1: 7bd8ba084e75bcd5c744e1d4a1812df3a4d91887
User & Date: dan 2010-08-06 14:37:13.000
Context
2010-08-06
17:18
Further enhancements to comments in pager.c. (check-in: 876162c7e0 user: dan tags: experimental)
14:37
Fix some problems with running test scripts with the inmemory_journal permutation. (check-in: 7bd8ba084e user: dan tags: experimental)
13:53
Merge trunk changes into experimental branch. (check-in: aef6698c73 user: dan tags: experimental)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/dbstatus.test.
50
51
52
53
54
55
56






57
58
59
60
61
62
63
}

#---------------------------------------------------------------------------
# Run the dbstatus-2 and dbstatus-3 tests with several of different
# lookaside buffer sizes.
#
foreach ::lookaside_buffer_size {0 64 120} {







  #-------------------------------------------------------------------------
  # Tests for SQLITE_DBSTATUS_SCHEMA_USED.
  #
  # Each test in the following block works as follows. Each test uses a
  # different database schema.
  #







>
>
>
>
>
>







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
}

#---------------------------------------------------------------------------
# Run the dbstatus-2 and dbstatus-3 tests with several of different
# lookaside buffer sizes.
#
foreach ::lookaside_buffer_size {0 64 120} {

  # Do not run any of these tests if there is SQL configured to run
  # as part of the [sqlite3] command. This prevents the script from
  # configuring the size of the lookaside buffer after [sqlite3] has
  # returned.
  if {[presql] != ""} break

  #-------------------------------------------------------------------------
  # Tests for SQLITE_DBSTATUS_SCHEMA_USED.
  #
  # Each test in the following block works as follows. Each test uses a
  # different database schema.
  #
313
314
315
316
317
318
319

320
321
322
323
324
325
326
327
328
329
330
331

    # Tests for which the test name ends in an "x" report slightly less
    # memory than is actually freed when all statements are finalized.
    # This is because a small amount of memory allocated by a virtual table
    # implementation using sqlite3_mprintf() is technically considered
    # external and so is not counted as "statement memory".
    #

    if {[string match *x $tn]} {
      do_test dbstatus-3.$tn.bx { expr $nStmt1<=$nFree }  {1}
    } else {
      do_test dbstatus-3.$tn.b { expr $nStmt1==$nFree } {1}
    }

    do_test dbstatus-3.$tn.c { list $nAlloc1 $nStmt1 } [list $nAlloc3 $nStmt3]
    do_test dbstatus-3.$tn.d { list $nAlloc2 $nStmt2 } [list $nAlloc4 $nStmt4]
  }
}

finish_test







>












319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338

    # Tests for which the test name ends in an "x" report slightly less
    # memory than is actually freed when all statements are finalized.
    # This is because a small amount of memory allocated by a virtual table
    # implementation using sqlite3_mprintf() is technically considered
    # external and so is not counted as "statement memory".
    #
puts "$nStmt1 $nFree"
    if {[string match *x $tn]} {
      do_test dbstatus-3.$tn.bx { expr $nStmt1<=$nFree }  {1}
    } else {
      do_test dbstatus-3.$tn.b { expr $nStmt1==$nFree } {1}
    }

    do_test dbstatus-3.$tn.c { list $nAlloc1 $nStmt1 } [list $nAlloc3 $nStmt3]
    do_test dbstatus-3.$tn.d { list $nAlloc2 $nStmt2 } [list $nAlloc4 $nStmt4]
  }
}

finish_test
Changes to test/fallocate.test.
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#
# We need to check this to verify that if in the unlikely event a rollback
# causes a database file to grow, the database grows to its previous size
# on disk, not to the minimum size required to hold the database image.
#
do_test fallocate-1.7 {
  execsql { BEGIN; INSERT INTO t1 VALUES(1, 2); }

  hexio_get_int [hexio_read test.db-journal 16 4]



} {1024}
do_test fallocate-1.8 { execsql { COMMIT } } {}


#-------------------------------------------------------------------------
# The following tests - fallocate-2.* - test that things work in WAL
# mode as well.
#
set skipwaltests [expr {[permutation]=="journaltest"}]


ifcapable !wal { set skipwaltests 1 }

if {!$skipwaltests} {
db close
file delete -force test.db
sqlite3 db test.db
file_control_chunksize_test db main [expr 32*1024]

do_test fallocate-2.1 {
  execsql {
    PRAGMA page_size = 1024;
    PRAGMA journal_mode = WAL;
    CREATE TABLE t1(a, b);
  }
  file size test.db
} [expr 32*1024]

do_test fallocate-2.2 {
  execsql { INSERT INTO t1 VALUES(1, zeroblob(35*1024)) }
  execsql { PRAGMA wal_checkpoint }
  file size test.db
} [expr 64*1024]

do_test fallocate-2.3 {
  execsql { DELETE FROM t1 }
  execsql { VACUUM }
  file size test.db
} [expr 64*1024]

do_test fallocate-2.4 {
  execsql { PRAGMA wal_checkpoint }
  file size test.db
} [expr 32*1024]

do_test fallocate-2.5 {
  execsql { 
    INSERT INTO t1 VALUES(2, randomblob(35*1024));
    PRAGMA wal_checkpoint;
    INSERT INTO t1 VALUES(3, randomblob(128));
    DELETE FROM t1 WHERE a = 2;
    VACUUM;
  }
  file size test.db
} [expr 64*1024]

do_test fallocate-2.6 {
  sqlite3 db2 test.db
  execsql { BEGIN ; SELECT count(a) FROM t1 } db2
  execsql {  
    INSERT INTO t1 VALUES(4, randomblob(128));
    PRAGMA wal_checkpoint;
  }
  file size test.db
} [expr 64*1024]

do_test fallocate-2.7 {
  execsql { SELECT count(b) FROM t1 } db2
} {1}

do_test fallocate-2.8 {
  execsql { COMMIT } db2
  execsql { PRAGMA wal_checkpoint }
  file size test.db
} [expr 32*1024]

}


finish_test








>
|
>
>
>








|
>
>



|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<





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
117
118
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
#
# We need to check this to verify that if in the unlikely event a rollback
# causes a database file to grow, the database grows to its previous size
# on disk, not to the minimum size required to hold the database image.
#
do_test fallocate-1.7 {
  execsql { BEGIN; INSERT INTO t1 VALUES(1, 2); }
  if {[permutation] != "inmemory_journal"} {
    hexio_get_int [hexio_read test.db-journal 16 4]
  } else {
    set {} 1024
  }
} {1024}
do_test fallocate-1.8 { execsql { COMMIT } } {}


#-------------------------------------------------------------------------
# The following tests - fallocate-2.* - test that things work in WAL
# mode as well.
#
set skipwaltests [expr {
  [permutation]=="journaltest" || [permutation]=="inmemory_journal"
}]
ifcapable !wal { set skipwaltests 1 }

if {!$skipwaltests} {
  db close
  file delete -force test.db
  sqlite3 db test.db
  file_control_chunksize_test db main [expr 32*1024]
  
  do_test fallocate-2.1 {
    execsql {
      PRAGMA page_size = 1024;
      PRAGMA journal_mode = WAL;
      CREATE TABLE t1(a, b);
    }
    file size test.db
  } [expr 32*1024]
  
  do_test fallocate-2.2 {
    execsql { INSERT INTO t1 VALUES(1, zeroblob(35*1024)) }
    execsql { PRAGMA wal_checkpoint }
    file size test.db
  } [expr 64*1024]
  
  do_test fallocate-2.3 {
    execsql { DELETE FROM t1 }
    execsql { VACUUM }
    file size test.db
  } [expr 64*1024]
  
  do_test fallocate-2.4 {
    execsql { PRAGMA wal_checkpoint }
    file size test.db
  } [expr 32*1024]
  
  do_test fallocate-2.5 {
    execsql { 
      INSERT INTO t1 VALUES(2, randomblob(35*1024));
      PRAGMA wal_checkpoint;
      INSERT INTO t1 VALUES(3, randomblob(128));
      DELETE FROM t1 WHERE a = 2;
      VACUUM;
    }
    file size test.db
  } [expr 64*1024]
  
  do_test fallocate-2.6 {
    sqlite3 db2 test.db
    execsql { BEGIN ; SELECT count(a) FROM t1 } db2
    execsql {  
      INSERT INTO t1 VALUES(4, randomblob(128));
      PRAGMA wal_checkpoint;
    }
    file size test.db
  } [expr 64*1024]
  
  do_test fallocate-2.7 {
    execsql { SELECT count(b) FROM t1 } db2
  } {1}
  
  do_test fallocate-2.8 {
    execsql { COMMIT } db2
    execsql { PRAGMA wal_checkpoint }
    file size test.db
  } [expr 32*1024]

}


finish_test