| OLD | NEW |
| 1 # 2003 July 1 | 1 # 2003 July 1 |
| 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 15 matching lines...) Expand all Loading... |
| 26 # Ticket #354 | 26 # Ticket #354 |
| 27 # | 27 # |
| 28 # Databases test.db and test2.db contain identical schemas. Make | 28 # Databases test.db and test2.db contain identical schemas. Make |
| 29 # sure we can attach test2.db from test.db. | 29 # sure we can attach test2.db from test.db. |
| 30 # | 30 # |
| 31 do_test attach2-1.1 { | 31 do_test attach2-1.1 { |
| 32 db eval { | 32 db eval { |
| 33 CREATE TABLE t1(a,b); | 33 CREATE TABLE t1(a,b); |
| 34 CREATE INDEX x1 ON t1(a); | 34 CREATE INDEX x1 ON t1(a); |
| 35 } | 35 } |
| 36 file delete -force test2.db | 36 forcedelete test2.db |
| 37 file delete -force test2.db-journal | 37 forcedelete test2.db-journal |
| 38 sqlite3 db2 test2.db | 38 sqlite3 db2 test2.db |
| 39 db2 eval { | 39 db2 eval { |
| 40 CREATE TABLE t1(a,b); | 40 CREATE TABLE t1(a,b); |
| 41 CREATE INDEX x1 ON t1(a); | 41 CREATE INDEX x1 ON t1(a); |
| 42 } | 42 } |
| 43 catchsql { | 43 catchsql { |
| 44 ATTACH 'test2.db' AS t2; | 44 ATTACH 'test2.db' AS t2; |
| 45 } | 45 } |
| 46 } {0 {}} | 46 } {0 {}} |
| 47 | 47 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 } {1 2} | 320 } {1 2} |
| 321 do_test attach2-4.14 { | 321 do_test attach2-4.14 { |
| 322 execsql {INSERT INTO t1 VALUES(1, 2)} | 322 execsql {INSERT INTO t1 VALUES(1, 2)} |
| 323 } {} | 323 } {} |
| 324 do_test attach2-4.15 { | 324 do_test attach2-4.15 { |
| 325 execsql {SELECT * FROM t1} db2 | 325 execsql {SELECT * FROM t1} db2 |
| 326 } {1 2 1 2} | 326 } {1 2 1 2} |
| 327 | 327 |
| 328 db close | 328 db close |
| 329 db2 close | 329 db2 close |
| 330 file delete -force test2.db | 330 forcedelete test2.db |
| 331 sqlite3_soft_heap_limit $soft_limit | 331 sqlite3_soft_heap_limit $soft_limit |
| 332 | 332 |
| 333 # These tests - attach2-5.* - check that the master journal file is deleted | 333 # These tests - attach2-5.* - check that the master journal file is deleted |
| 334 # correctly when a multi-file transaction is committed or rolled back. | 334 # correctly when a multi-file transaction is committed or rolled back. |
| 335 # | 335 # |
| 336 # Update: It's not actually created if a rollback occurs, so that test | 336 # Update: It's not actually created if a rollback occurs, so that test |
| 337 # doesn't really prove too much. | 337 # doesn't really prove too much. |
| 338 foreach f [glob test.db*] {file delete -force $f} | 338 foreach f [glob test.db*] {forcedelete $f} |
| 339 do_test attach2-5.1 { | 339 do_test attach2-5.1 { |
| 340 sqlite3 db test.db | 340 sqlite3 db test.db |
| 341 execsql { | 341 execsql { |
| 342 ATTACH 'test.db2' AS aux; | 342 ATTACH 'test.db2' AS aux; |
| 343 } | 343 } |
| 344 } {} | 344 } {} |
| 345 do_test attach2-5.2 { | 345 do_test attach2-5.2 { |
| 346 execsql { | 346 execsql { |
| 347 BEGIN; | 347 BEGIN; |
| 348 CREATE TABLE tbl(a, b, c); | 348 CREATE TABLE tbl(a, b, c); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 370 execsql { | 370 execsql { |
| 371 BEGIN; | 371 BEGIN; |
| 372 } | 372 } |
| 373 } {} | 373 } {} |
| 374 do_test attach2-6.2 { | 374 do_test attach2-6.2 { |
| 375 catchsql { | 375 catchsql { |
| 376 ATTACH 'test3.db' as aux2; | 376 ATTACH 'test3.db' as aux2; |
| 377 } | 377 } |
| 378 } {1 {cannot ATTACH database within transaction}} | 378 } {1 {cannot ATTACH database within transaction}} |
| 379 | 379 |
| 380 # EVIDENCE-OF: R-59740-55581 This statement will fail if SQLite is in |
| 381 # the middle of a transaction. |
| 382 # |
| 380 do_test attach2-6.3 { | 383 do_test attach2-6.3 { |
| 381 catchsql { | 384 catchsql { |
| 382 DETACH aux; | 385 DETACH aux; |
| 383 } | 386 } |
| 384 } {1 {cannot DETACH database within transaction}} | 387 } {1 {cannot DETACH database within transaction}} |
| 385 do_test attach2-6.4 { | 388 do_test attach2-6.4 { |
| 386 execsql { | 389 execsql { |
| 387 COMMIT; | 390 COMMIT; |
| 388 DETACH aux; | 391 DETACH aux; |
| 389 } | 392 } |
| 390 } {} | 393 } {} |
| 391 | 394 |
| 392 db close | 395 db close |
| 393 | 396 |
| 394 finish_test | 397 finish_test |
| OLD | NEW |