| OLD | NEW |
| 1 # 2007 September 10 | 1 # 2007 September 10 |
| 2 # | 2 # |
| 3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
| 4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
| 5 # | 5 # |
| 6 # May you do good and not evil. | 6 # May you do good and not evil. |
| 7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
| 8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
| 9 # | 9 # |
| 10 #*********************************************************************** | 10 #*********************************************************************** |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 execsql { | 33 execsql { |
| 34 CREATE INDEX i1 ON t1(a, b); | 34 CREATE INDEX i1 ON t1(a, b); |
| 35 COMMIT; | 35 COMMIT; |
| 36 } | 36 } |
| 37 } {} | 37 } {} |
| 38 do_test thread003.1.2 { | 38 do_test thread003.1.2 { |
| 39 expr {([file size test.db] / 1024) > 2000} | 39 expr {([file size test.db] / 1024) > 2000} |
| 40 } {1} | 40 } {1} |
| 41 do_test thread003.1.3 { | 41 do_test thread003.1.3 { |
| 42 db close | 42 db close |
| 43 file delete -force test2.db | 43 forcedelete test2.db |
| 44 sqlite3 db test2.db | 44 sqlite3 db test2.db |
| 45 } {} | 45 } {} |
| 46 do_test thread003.1.4 { | 46 do_test thread003.1.4 { |
| 47 execsql { | 47 execsql { |
| 48 BEGIN; | 48 BEGIN; |
| 49 CREATE TABLE t1(a, b, c); | 49 CREATE TABLE t1(a, b, c); |
| 50 } | 50 } |
| 51 for {set ii 0} {$ii < 5000} {incr ii} { | 51 for {set ii 0} {$ii < 5000} {incr ii} { |
| 52 execsql {INSERT INTO t1 VALUES($ii, randomblob(200), randomblob(200))} | 52 execsql {INSERT INTO t1 VALUES($ii, randomblob(200), randomblob(200))} |
| 53 } | 53 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 73 # over again. This will force the connections to recycle clean pages from | 73 # over again. This will force the connections to recycle clean pages from |
| 74 # each other. If there is a thread-safety problem, a segfault or assertion | 74 # each other. If there is a thread-safety problem, a segfault or assertion |
| 75 # failure may eventually occur. | 75 # failure may eventually occur. |
| 76 # | 76 # |
| 77 set nSecond 30 | 77 set nSecond 30 |
| 78 puts "Starting thread003.2 (should run for ~$nSecond seconds)" | 78 puts "Starting thread003.2 (should run for ~$nSecond seconds)" |
| 79 do_test thread003.2 { | 79 do_test thread003.2 { |
| 80 foreach zFile {test.db test2.db} { | 80 foreach zFile {test.db test2.db} { |
| 81 set SCRIPT [format { | 81 set SCRIPT [format { |
| 82 set iEnd [expr {[clock_seconds] + %d}] | 82 set iEnd [expr {[clock_seconds] + %d}] |
| 83 set ::DB [sqlthread open %s] | 83 set ::DB [sqlthread open %s xyzzy] |
| 84 | 84 |
| 85 # Set the cache size to 15 pages per cache. 30 available globally. | 85 # Set the cache size to 15 pages per cache. 30 available globally. |
| 86 execsql { PRAGMA cache_size = 15 } | 86 execsql { PRAGMA cache_size = 15 } |
| 87 | 87 |
| 88 while {[clock_seconds] < $iEnd} { | 88 while {[clock_seconds] < $iEnd} { |
| 89 set iQuery [expr {int(rand()*5000)}] | 89 set iQuery [expr {int(rand()*5000)}] |
| 90 execsql " SELECT * FROM t1 WHERE a = $iQuery " | 90 execsql " SELECT * FROM t1 WHERE a = $iQuery " |
| 91 } | 91 } |
| 92 | 92 |
| 93 sqlite3_close $::DB | 93 sqlite3_close $::DB |
| (...skipping 16 matching lines...) Expand all Loading... |
| 110 # between the caches internal dirty and clean lists, which is another | 110 # between the caches internal dirty and clean lists, which is another |
| 111 # opportunity for a thread-related bug to present itself. | 111 # opportunity for a thread-related bug to present itself. |
| 112 # | 112 # |
| 113 set nSecond 30 | 113 set nSecond 30 |
| 114 puts "Starting thread003.3 (should run for ~$nSecond seconds)" | 114 puts "Starting thread003.3 (should run for ~$nSecond seconds)" |
| 115 do_test thread003.3 { | 115 do_test thread003.3 { |
| 116 foreach zFile {test.db test2.db} { | 116 foreach zFile {test.db test2.db} { |
| 117 set SCRIPT [format { | 117 set SCRIPT [format { |
| 118 set iStart [clock_seconds] | 118 set iStart [clock_seconds] |
| 119 set iEnd [expr {[clock_seconds] + %d}] | 119 set iEnd [expr {[clock_seconds] + %d}] |
| 120 set ::DB [sqlthread open %s] | 120 set ::DB [sqlthread open %s xyzzy] |
| 121 | 121 |
| 122 # Set the cache size to 15 pages per cache. 30 available globally. | 122 # Set the cache size to 15 pages per cache. 30 available globally. |
| 123 execsql { PRAGMA cache_size = 15 } | 123 execsql { PRAGMA cache_size = 15 } |
| 124 | 124 |
| 125 while {[clock_seconds] < $iEnd} { | 125 while {[clock_seconds] < $iEnd} { |
| 126 set iQuery [expr {int(rand()*5000)}] | 126 set iQuery [expr {int(rand()*5000)}] |
| 127 execsql "SELECT * FROM t1 WHERE a = $iQuery" | 127 execsql "SELECT * FROM t1 WHERE a = $iQuery" |
| 128 execsql "UPDATE t1 SET b = randomblob(200) | 128 execsql "UPDATE t1 SET b = randomblob(200) |
| 129 WHERE a < $iQuery AND a > $iQuery + 20 | 129 WHERE a < $iQuery AND a > $iQuery + 20 |
| 130 " | 130 " |
| (...skipping 18 matching lines...) Expand all Loading... |
| 149 # The other thread does not have a database connection, but calls | 149 # The other thread does not have a database connection, but calls |
| 150 # sqlite3_release_memory() over and over again. | 150 # sqlite3_release_memory() over and over again. |
| 151 # | 151 # |
| 152 set nSecond 30 | 152 set nSecond 30 |
| 153 puts "Starting thread003.4 (should run for ~$nSecond seconds)" | 153 puts "Starting thread003.4 (should run for ~$nSecond seconds)" |
| 154 unset -nocomplain finished(1) | 154 unset -nocomplain finished(1) |
| 155 unset -nocomplain finished(2) | 155 unset -nocomplain finished(2) |
| 156 do_test thread003.4 { | 156 do_test thread003.4 { |
| 157 thread_spawn finished(1) $thread_procs [format { | 157 thread_spawn finished(1) $thread_procs [format { |
| 158 set iEnd [expr {[clock_seconds] + %d}] | 158 set iEnd [expr {[clock_seconds] + %d}] |
| 159 set ::DB [sqlthread open test.db] | 159 set ::DB [sqlthread open test.db xyzzy] |
| 160 | 160 |
| 161 # Set the cache size to 15 pages per cache. 30 available globally. | 161 # Set the cache size to 15 pages per cache. 30 available globally. |
| 162 execsql { PRAGMA cache_size = 15 } | 162 execsql { PRAGMA cache_size = 15 } |
| 163 | 163 |
| 164 while {[clock_seconds] < $iEnd} { | 164 while {[clock_seconds] < $iEnd} { |
| 165 set iQuery [expr {int(rand()*5000)}] | 165 set iQuery [expr {int(rand()*5000)}] |
| 166 execsql "SELECT * FROM t1 WHERE a = $iQuery" | 166 execsql "SELECT * FROM t1 WHERE a = $iQuery" |
| 167 } | 167 } |
| 168 | 168 |
| 169 sqlite3_close $::DB | 169 sqlite3_close $::DB |
| (...skipping 10 matching lines...) Expand all Loading... |
| 180 foreach ii {1 2} { | 180 foreach ii {1 2} { |
| 181 if {![info exists finished($ii)]} { | 181 if {![info exists finished($ii)]} { |
| 182 vwait finished($ii) | 182 vwait finished($ii) |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 expr 0 | 185 expr 0 |
| 186 } {0} | 186 } {0} |
| 187 | 187 |
| 188 set sqlite_open_file_count 0 | 188 set sqlite_open_file_count 0 |
| 189 finish_test | 189 finish_test |
| OLD | NEW |