OLD | NEW |
1 # 2009 March 04 | 1 # 2009 March 04 |
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 # Hit an SQLITE_LOCKED error. Rollback the current transaction. | 143 # Hit an SQLITE_LOCKED error. Rollback the current transaction. |
144 set rc [catch { execsql_blocking $::DB ROLLBACK } msg] | 144 set rc [catch { execsql_blocking $::DB ROLLBACK } msg] |
145 if {$rc && [string match "SQLITE_LOCKED*" $msg]} { | 145 if {$rc && [string match "SQLITE_LOCKED*" $msg]} { |
146 sqlite3_close $::DB | 146 sqlite3_close $::DB |
147 opendb | 147 opendb |
148 } | 148 } |
149 } elseif {$rc} { | 149 } elseif {$rc} { |
150 # Hit some other kind of error. This is a malfunction. | 150 # Hit some other kind of error. This is a malfunction. |
151 error $msg | 151 error $msg |
152 } else { | 152 } else { |
153 # No error occured. Check that any SELECT statements in the transaction | 153 # No error occurred. Check that any SELECT statements in the transaction |
154 # returned "1". Otherwise, the invariant was false, indicating that | 154 # returned "1". Otherwise, the invariant was false, indicating that |
155 # some malfunction has occured. | 155 # some malfunction has occurred. |
156 foreach r $msg { if {$r != 1} { puts "Invariant check failed: $msg" } } | 156 foreach r $msg { if {$r != 1} { puts "Invariant check failed: $msg" } } |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 # Close the database connection and return 0. | 160 # Close the database connection and return 0. |
161 # | 161 # |
162 sqlite3_close $::DB | 162 sqlite3_close $::DB |
163 expr 0 | 163 expr 0 |
164 } | 164 } |
165 | 165 |
166 foreach {iTest xStep xPrepare} { | 166 foreach {iTest xStep xPrepare} { |
167 1 sqlite3_blocking_step sqlite3_blocking_prepare_v2 | 167 1 sqlite3_blocking_step sqlite3_blocking_prepare_v2 |
168 2 sqlite3_step sqlite3_nonblocking_prepare_v2 | 168 2 sqlite3_step sqlite3_nonblocking_prepare_v2 |
169 } { | 169 } { |
170 file delete -force test.db test2.db test3.db | 170 forcedelete test.db test2.db test3.db |
171 | 171 |
172 set ThreadSetup "set xStep $xStep;set xPrepare $xPrepare;set nSecond $nSecond" | 172 set ThreadSetup "set xStep $xStep;set xPrepare $xPrepare;set nSecond $nSecond" |
173 | 173 |
174 # Set up the database schema used by this test. Each thread opens file | 174 # Set up the database schema used by this test. Each thread opens file |
175 # test.db as the main database, then attaches files test2.db and test3.db | 175 # test.db as the main database, then attaches files test2.db and test3.db |
176 # as auxillary databases. Each file contains a single table (t1, t2 and t3, in | 176 # as auxillary databases. Each file contains a single table (t1, t2 and t3, in |
177 # files test.db, test2.db and test3.db, respectively). | 177 # files test.db, test2.db and test3.db, respectively). |
178 # | 178 # |
179 do_test notify2-$iTest.1.1 { | 179 do_test notify2-$iTest.1.1 { |
180 sqlite3 db test.db | 180 sqlite3 db test.db |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 puts "The following test seeks to demonstrate that the sqlite3_unlock_notify()" | 233 puts "The following test seeks to demonstrate that the sqlite3_unlock_notify()" |
234 puts "interface helps multi-core systems to run faster. This test sometimes" | 234 puts "interface helps multi-core systems to run faster. This test sometimes" |
235 puts "fails on single-core machines." | 235 puts "fails on single-core machines." |
236 puts [array get anWrite] | 236 puts [array get anWrite] |
237 do_test notify2-3 { | 237 do_test notify2-3 { |
238 expr {$anWrite(sqlite3_blocking_step) > $anWrite(sqlite3_step)} | 238 expr {$anWrite(sqlite3_blocking_step) > $anWrite(sqlite3_step)} |
239 } {1} | 239 } {1} |
240 | 240 |
241 sqlite3_enable_shared_cache $::enable_shared_cache | 241 sqlite3_enable_shared_cache $::enable_shared_cache |
242 finish_test | 242 finish_test |
OLD | NEW |