OLD | NEW |
1 # 2007 August 21 | 1 # 2007 August 21 |
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 execsql { COMMIT } | 193 execsql { COMMIT } |
194 list [nWrite db] [nSync] | 194 list [nWrite db] [nSync] |
195 } {3 4} | 195 } {3 4} |
196 | 196 |
197 # Test that the journal file is created and sync()d if the transaction | 197 # Test that the journal file is created and sync()d if the transaction |
198 # modifies a single database page and also appends a page to the file. | 198 # modifies a single database page and also appends a page to the file. |
199 # Internally, this case is handled differently to the one above. The | 199 # Internally, this case is handled differently to the one above. The |
200 # journal file is not actually created until the 'COMMIT' statement | 200 # journal file is not actually created until the 'COMMIT' statement |
201 # is executed. | 201 # is executed. |
202 # | 202 # |
| 203 # Changed 2010-03-27: The size of the database is now stored in |
| 204 # bytes 28..31 and so when a page is added to the database, page 1 |
| 205 # is immediately modified and the journal file immediately comes into |
| 206 # existance. To fix this test, the BEGIN is changed into a a |
| 207 # BEGIN IMMEDIATE and the INSERT is omitted. |
| 208 # |
203 do_test io-2.6.1 { | 209 do_test io-2.6.1 { |
204 execsql { | 210 execsql { |
205 BEGIN; | 211 BEGIN IMMEDIATE; |
206 INSERT INTO abc VALUES(9, randstr(1000,1000)); | 212 -- INSERT INTO abc VALUES(9, randstr(1000,1000)); |
207 } | 213 } |
208 file exists test.db-journal | 214 file exists test.db-journal |
209 } {0} | 215 } {0} |
210 do_test io-2.6.2 { | 216 do_test io-2.6.2 { |
211 # Create a file at "test.db-journal". This will prevent SQLite from | 217 # Create a file at "test.db-journal". This will prevent SQLite from |
212 # opening the journal for exclusive access. As a result, the COMMIT | 218 # opening the journal for exclusive access. As a result, the COMMIT |
213 # should fail with SQLITE_CANTOPEN and the transaction rolled back. | 219 # should fail with SQLITE_CANTOPEN and the transaction rolled back. |
214 # | 220 # |
215 file mkdir test.db-journal | 221 file mkdir test.db-journal |
216 catchsql { COMMIT } | 222 catchsql { |
| 223 INSERT INTO abc VALUES(9, randstr(1000,1000)); |
| 224 COMMIT |
| 225 } |
217 } {1 {unable to open database file}} | 226 } {1 {unable to open database file}} |
218 do_test io-2.6.3 { | 227 do_test io-2.6.3 { |
219 file delete -force test.db-journal | 228 file delete -force test.db-journal |
220 catchsql { COMMIT } | 229 catchsql { COMMIT } |
221 } {1 {cannot commit - no transaction is active}} | 230 } {0 {}} |
222 do_test io-2.6.4 { | 231 do_test io-2.6.4 { |
223 execsql { SELECT * FROM abc } | 232 execsql { SELECT * FROM abc } |
224 } {1 2 3 4 5 6 7 8} | 233 } {1 2 3 4 5 6 7 8} |
225 | 234 |
226 # Test that if the database modification is part of multi-file commit, | 235 # Test that if the database modification is part of multi-file commit, |
227 # the journal file is always created. In this case, the journal file | 236 # the journal file is always created. In this case, the journal file |
228 # is created during execution of the COMMIT statement, so we have to | 237 # is created during execution of the COMMIT statement, so we have to |
229 # use the same technique to check that it is created as in the above | 238 # use the same technique to check that it is created as in the above |
230 # block. | 239 # block. |
231 file delete -force test2.db test2.db-journal | 240 file delete -force test2.db test2.db-journal |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 do_test io-5.$tn { | 556 do_test io-5.$tn { |
548 execsql { | 557 execsql { |
549 CREATE TABLE abc(a, b, c); | 558 CREATE TABLE abc(a, b, c); |
550 } | 559 } |
551 expr {[file size test.db]/2} | 560 expr {[file size test.db]/2} |
552 } $pgsize | 561 } $pgsize |
553 } | 562 } |
554 | 563 |
555 sqlite3_simulate_device -char {} -sectorsize 0 | 564 sqlite3_simulate_device -char {} -sectorsize 0 |
556 finish_test | 565 finish_test |
OLD | NEW |