Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: third_party/sqlite/src/test/backup.test

Issue 901033002: Import SQLite 3.8.7.4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chromium changes to support SQLite 3.8.7.4. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # 2009 January 30 1 # 2009 January 30
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 } {} 67 } {}
68 68
69 # Sanity check to verify that the [test_contents] proc works. 69 # Sanity check to verify that the [test_contents] proc works.
70 # 70 #
71 test_contents backup-1.2 db main db main 71 test_contents backup-1.2 db main db main
72 72
73 # Check that it is possible to create and finish backup operations. 73 # Check that it is possible to create and finish backup operations.
74 # 74 #
75 do_test backup-1.3.1 { 75 do_test backup-1.3.1 {
76 file delete test2.db 76 delete_file test2.db
77 sqlite3 db2 test2.db 77 sqlite3 db2 test2.db
78 sqlite3_backup B db2 main db main 78 sqlite3_backup B db2 main db main
79 } {B} 79 } {B}
80 do_test backup-1.3.2 { 80 do_test backup-1.3.2 {
81 B finish 81 B finish
82 } {SQLITE_OK} 82 } {SQLITE_OK}
83 do_test backup-1.3.3 { 83 do_test backup-1.3.3 {
84 info commands B 84 info commands B
85 } {} 85 } {}
86 86
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 sqlite3 db $zSrcFile 161 sqlite3 db $zSrcFile
162 sqlite3 db2 $zDestFile 162 sqlite3 db2 $zDestFile
163 set db_dest db2 163 set db_dest db2
164 set file_dest temp 164 set file_dest temp
165 }] { 165 }] {
166 foreach rows_dest {0 3 10} { 166 foreach rows_dest {0 3 10} {
167 foreach pgsz_dest {512 1024 2048} { 167 foreach pgsz_dest {512 1024 2048} {
168 foreach nPagePerStep {1 200} { 168 foreach nPagePerStep {1 200} {
169 169
170 # Open the databases. 170 # Open the databases.
171 catch { file delete test.db } 171 catch { delete_file test.db }
172 catch { file delete test2.db } 172 catch { delete_file test2.db }
173 eval $zOpenScript 173 eval $zOpenScript
174 174
175 # Set to true if copying to an in-memory destination. Copying to an 175 # Set to true if copying to an in-memory destination. Copying to an
176 # in-memory destination is only possible if the initial destination 176 # in-memory destination is only possible if the initial destination
177 # page size is the same as the source page size (in this case 1024 bytes). 177 # page size is the same as the source page size (in this case 1024 bytes).
178 # 178 #
179 set isMemDest [expr { 179 set isMemDest [expr {
180 $zDestFile eq ":memory:" || $file_dest eq "temp" && $TEMP_STORE>=2 180 $zDestFile eq ":memory:" || $file_dest eq "temp" && $TEMP_STORE>=2
181 }] 181 }]
182 182
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 # 272 #
273 # * Target database page-size is the same as the source, OR 273 # * Target database page-size is the same as the source, OR
274 # * Target database page-size is larger than the source, OR 274 # * Target database page-size is larger than the source, OR
275 # * Target database page-size is smaller than the source. 275 # * Target database page-size is smaller than the source.
276 # 276 #
277 set iTest 1 277 set iTest 1
278 foreach nSrcPg {10 64 65 66 100} { 278 foreach nSrcPg {10 64 65 66 100} {
279 foreach nDestRow {10 100} { 279 foreach nDestRow {10 100} {
280 foreach nDestPgsz {512 1024 2048 4096} { 280 foreach nDestPgsz {512 1024 2048 4096} {
281 281
282 catch { file delete test.db } 282 catch { delete_file test.db }
283 catch { file delete test2.db } 283 catch { delete_file test2.db }
284 sqlite3 db test.db 284 sqlite3 db test.db
285 sqlite3 db2 test2.db 285 sqlite3 db2 test2.db
286 286
287 # Set up the content of the two databases. 287 # Set up the content of the two databases.
288 # 288 #
289 execsql { PRAGMA page_size = 1024 } 289 execsql { PRAGMA page_size = 1024 }
290 execsql "PRAGMA page_size = $nDestPgsz" db2 290 execsql "PRAGMA page_size = $nDestPgsz" db2
291 foreach db {db db2} { 291 foreach db {db db2} {
292 execsql { 292 execsql {
293 BEGIN; 293 BEGIN;
(...skipping 26 matching lines...) Expand all
320 320
321 db close 321 db close
322 db2 close 322 db2 close
323 incr iTest 323 incr iTest
324 } 324 }
325 } 325 }
326 } 326 }
327 327
328 #-------------------------------------------------------------------- 328 #--------------------------------------------------------------------
329 do_test backup-3.$iTest.1 { 329 do_test backup-3.$iTest.1 {
330 catch { file delete -force test.db } 330 catch { forcedelete test.db }
331 catch { file delete -force test2.db } 331 catch { forcedelete test2.db }
332 sqlite3 db test.db 332 sqlite3 db test.db
333 set iTab 1 333 set iTab 1
334 334
335 db eval { PRAGMA page_size = 512 } 335 db eval { PRAGMA page_size = 512 }
336 while {[file size test.db] <= $::sqlite_pending_byte} { 336 while {[file size test.db] <= $::sqlite_pending_byte} {
337 db eval "CREATE TABLE t${iTab}(a, b, c)" 337 db eval "CREATE TABLE t${iTab}(a, b, c)"
338 incr iTab 338 incr iTab
339 } 339 }
340 340
341 sqlite3 db2 test2.db 341 sqlite3 db2 test2.db
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 sqlite3_errmsg db 385 sqlite3_errmsg db
386 } {unknown database aux} 386 } {unknown database aux}
387 do_test backup-4.1.3 { 387 do_test backup-4.1.3 {
388 catch { sqlite3_backup B db main db2 aux } 388 catch { sqlite3_backup B db main db2 aux }
389 } {1} 389 } {1}
390 do_test backup-4.1.4 { 390 do_test backup-4.1.4 {
391 sqlite3_errmsg db 391 sqlite3_errmsg db
392 } {unknown database aux} 392 } {unknown database aux}
393 393
394 do_test backup-4.2.1 { 394 do_test backup-4.2.1 {
395 catch { file delete -force test3.db } 395 catch { forcedelete test3.db }
396 catch { file delete -force test4.db } 396 catch { forcedelete test4.db }
397 execsql { 397 execsql {
398 ATTACH 'test3.db' AS aux1; 398 ATTACH 'test3.db' AS aux1;
399 CREATE TABLE aux1.t1(a, b); 399 CREATE TABLE aux1.t1(a, b);
400 } 400 }
401 execsql { 401 execsql {
402 ATTACH 'test4.db' AS aux2; 402 ATTACH 'test4.db' AS aux2;
403 CREATE TABLE aux2.t2(a, b); 403 CREATE TABLE aux2.t2(a, b);
404 } db2 404 } db2
405 sqlite3_backup B db aux1 db2 aux2 405 sqlite3_backup B db aux1 db2 aux2
406 } {B} 406 } {B}
407 do_test backup-4.2.2 { 407 do_test backup-4.2.2 {
408 catchsql { DETACH aux2 } db2 408 catchsql { DETACH aux2 } db2
409 } {1 {database aux2 is locked}} 409 } {1 {database aux2 is locked}}
410 do_test backup-4.2.3 { 410 do_test backup-4.2.3 {
411 B step 50 411 B step 50
412 } {SQLITE_DONE} 412 } {SQLITE_DONE}
413 do_test backup-4.2.4 { 413 do_test backup-4.2.4 {
414 B finish 414 B finish
415 } {SQLITE_OK} 415 } {SQLITE_OK}
416 416
417 do_test backup-4.3.1 { 417 do_test backup-4.3.1 {
418 sqlite3_backup B db aux1 db2 aux2 418 sqlite3_backup B db aux1 db2 aux2
419 } {B} 419 } {B}
420 do_test backup-4.3.2 { 420 do_test backup-4.3.2 {
421 db2 cache flush 421 db2 cache flush
422 sqlite3_close db2 422 sqlite3_close db2
423 } {SQLITE_BUSY} 423 } {SQLITE_BUSY}
424 do_test backup-4.3.3 { 424 do_test backup-4.3.3 {
425 sqlite3_errmsg db2 425 sqlite3_errmsg db2
426 } {unable to close due to unfinished backup operation} 426 } {unable to close due to unfinalized statements or unfinished backups}
427 do_test backup-4.3.4 { 427 do_test backup-4.3.4 {
428 B step 50 428 B step 50
429 } {SQLITE_DONE} 429 } {SQLITE_DONE}
430 do_test backup-4.3.5 { 430 do_test backup-4.3.5 {
431 B finish 431 B finish
432 } {SQLITE_OK} 432 } {SQLITE_OK}
433 433
434 do_test backup-4.4.1 { 434 do_test backup-4.4.1 {
435 set rc [catch {sqlite3_backup B db main db aux1}] 435 set rc [catch {sqlite3_backup B db main db aux1}]
436 list $rc [sqlite3_errcode db] [sqlite3_errmsg db] 436 list $rc [sqlite3_errcode db] [sqlite3_errmsg db]
437 } {1 SQLITE_ERROR {source and destination must be distinct}} 437 } {1 SQLITE_ERROR {source and destination must be distinct}}
438 db close 438 db close
439 db2 close 439 db2 close
440 440
441 do_test backup-4.5.1 { 441 do_test backup-4.5.1 {
442 catch { file delete -force test.db } 442 catch { forcedelete test.db }
443 sqlite3 db test.db 443 sqlite3 db test.db
444 sqlite3 db2 :memory: 444 sqlite3 db2 :memory:
445 execsql { 445 execsql {
446 CREATE TABLE t1(a, b); 446 CREATE TABLE t1(a, b);
447 INSERT INTO t1 VALUES(1, 2); 447 INSERT INTO t1 VALUES(1, 2);
448 } 448 }
449 execsql { 449 execsql {
450 PRAGMA page_size = 4096; 450 PRAGMA page_size = 4096;
451 CREATE TABLE t2(a, b); 451 CREATE TABLE t2(a, b);
452 INSERT INTO t2 VALUES(3, 4); 452 INSERT INTO t2 VALUES(3, 4);
453 } db2 453 } db2
454 sqlite3_backup B db2 main db main 454 sqlite3_backup B db2 main db main
455 } {B} 455 } {B}
456 do_test backup-4.5.2 { 456 do_test backup-4.5.2 {
457 B step 5000 457 B step 5000
458 } {SQLITE_READONLY} 458 } {SQLITE_READONLY}
459 do_test backup-4.5.3 { 459 do_test backup-4.5.3 {
460 B finish 460 B finish
461 } {SQLITE_READONLY} 461 } {SQLITE_READONLY}
462 462
463 db close 463 db close
464 db2 close 464 db2 close
465 # 465 #
466 # End of backup-5.* tests. 466 # End of backup-4.* tests.
467 #--------------------------------------------------------------------- 467 #---------------------------------------------------------------------
468 468
469 #--------------------------------------------------------------------- 469 #---------------------------------------------------------------------
470 # The following tests, backup-5.*, test that the backup works properly 470 # The following tests, backup-5.*, test that the backup works properly
471 # when the source database is modified during the backup. Test cases 471 # when the source database is modified during the backup. Test cases
472 # are organized as follows: 472 # are organized as follows:
473 # 473 #
474 # backup-5.x.1.*: Nothing special. Modify the database mid-backup. 474 # backup-5.x.1.*: Nothing special. Modify the database mid-backup.
475 # 475 #
476 # backup-5.x.2.*: Modify the database mid-backup so that one or more 476 # backup-5.x.2.*: Modify the database mid-backup so that one or more
477 # pages are written out due to cache stress. Then 477 # pages are written out due to cache stress. Then
478 # rollback the transaction. 478 # rollback the transaction.
479 # 479 #
480 # backup-5.x.3.*: Database is vacuumed. 480 # backup-5.x.3.*: Database is vacuumed.
481 # 481 #
482 # backup-5.x.4.*: Database is vacuumed and the page-size modified. 482 # backup-5.x.4.*: Database is vacuumed and the page-size modified.
483 # 483 #
484 # backup-5.x.5.*: Database is shrunk via incr-vacuum. 484 # backup-5.x.5.*: Database is shrunk via incr-vacuum.
485 # 485 #
486 # Each test is run three times, in the following configurations: 486 # Each test is run three times, in the following configurations:
487 # 487 #
488 # 1) Backing up file-to-file. The writer writes via an external pager. 488 # 1) Backing up file-to-file. The writer writes via an external pager.
489 # 2) Backing up file-to-file. The writer writes via the same pager as 489 # 2) Backing up file-to-file. The writer writes via the same pager as
490 # is used by the backup operation. 490 # is used by the backup operation.
491 # 3) Backing up memory-to-file. 491 # 3) Backing up memory-to-file.
492 # 492 #
493 set iTest 0 493 set iTest 0
494 file delete -force bak.db-wal 494 forcedelete bak.db-wal
495 foreach {writer file} {db test.db db3 test.db db :memory:} { 495 foreach {writer file} {db test.db db3 test.db db :memory:} {
496 incr iTest 496 incr iTest
497 catch { file delete bak.db } 497 catch { delete_file bak.db }
498 sqlite3 db2 bak.db 498 sqlite3 db2 bak.db
499 catch { file delete $file } 499 catch { delete_file $file }
500 sqlite3 db $file 500 sqlite3 db $file
501 sqlite3 db3 $file 501 sqlite3 db3 $file
502 502
503 do_test backup-5.$iTest.1.1 { 503 do_test backup-5.$iTest.1.1 {
504 execsql { 504 execsql {
505 BEGIN; 505 BEGIN;
506 CREATE TABLE t1(a, b); 506 CREATE TABLE t1(a, b);
507 CREATE INDEX i1 ON t1(a, b); 507 CREATE INDEX i1 ON t1(a, b);
508 INSERT INTO t1 VALUES(1, randstr(1000,1000)); 508 INSERT INTO t1 VALUES(1, randstr(1000,1000));
509 INSERT INTO t1 VALUES(2, randstr(1000,1000)); 509 INSERT INTO t1 VALUES(2, randstr(1000,1000));
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 } {SQLITE_DONE} 590 } {SQLITE_DONE}
591 do_test backup-5.$iTest.4.4 { 591 do_test backup-5.$iTest.4.4 {
592 B finish 592 B finish
593 } {SQLITE_OK} 593 } {SQLITE_OK}
594 integrity_check backup-5.$iTest.4.5 db2 594 integrity_check backup-5.$iTest.4.5 db2
595 test_contents backup-5.$iTest.4.6 db main db2 main 595 test_contents backup-5.$iTest.4.6 db main db2 main
596 596
597 catch {db close} 597 catch {db close}
598 catch {db2 close} 598 catch {db2 close}
599 catch {db3 close} 599 catch {db3 close}
600 catch { file delete bak.db } 600 catch { delete_file bak.db }
601 sqlite3 db2 bak.db 601 sqlite3 db2 bak.db
602 catch { file delete $file } 602 catch { delete_file $file }
603 sqlite3 db $file 603 sqlite3 db $file
604 sqlite3 db3 $file 604 sqlite3 db3 $file
605 do_test backup-5.$iTest.5.1 { 605 do_test backup-5.$iTest.5.1 {
606 execsql { 606 execsql {
607 PRAGMA auto_vacuum = incremental; 607 PRAGMA auto_vacuum = incremental;
608 BEGIN; 608 BEGIN;
609 CREATE TABLE t1(a, b); 609 CREATE TABLE t1(a, b);
610 CREATE INDEX i1 ON t1(a, b); 610 CREATE INDEX i1 ON t1(a, b);
611 INSERT INTO t1 VALUES(1, randstr(1000,1000)); 611 INSERT INTO t1 VALUES(1, randstr(1000,1000));
612 INSERT INTO t1 VALUES(2, randstr(1000,1000)); 612 INSERT INTO t1 VALUES(2, randstr(1000,1000));
(...skipping 24 matching lines...) Expand all
637 catch {db3 close} 637 catch {db3 close}
638 } 638 }
639 # 639 #
640 # End of backup-5.* tests. 640 # End of backup-5.* tests.
641 #--------------------------------------------------------------------- 641 #---------------------------------------------------------------------
642 642
643 #--------------------------------------------------------------------- 643 #---------------------------------------------------------------------
644 # Test the sqlite3_backup_remaining() and backup_pagecount() APIs. 644 # Test the sqlite3_backup_remaining() and backup_pagecount() APIs.
645 # 645 #
646 do_test backup-6.1 { 646 do_test backup-6.1 {
647 catch { file delete -force test.db } 647 catch { forcedelete test.db }
648 catch { file delete -force test2.db } 648 catch { forcedelete test2.db }
649 sqlite3 db test.db 649 sqlite3 db test.db
650 sqlite3 db2 test2.db 650 sqlite3 db2 test2.db
651 execsql { 651 execsql {
652 BEGIN; 652 BEGIN;
653 CREATE TABLE t1(a, b); 653 CREATE TABLE t1(a, b);
654 CREATE INDEX i1 ON t1(a, b); 654 CREATE INDEX i1 ON t1(a, b);
655 INSERT INTO t1 VALUES(1, randstr(1000,1000)); 655 INSERT INTO t1 VALUES(1, randstr(1000,1000));
656 INSERT INTO t1 VALUES(2, randstr(1000,1000)); 656 INSERT INTO t1 VALUES(2, randstr(1000,1000));
657 INSERT INTO t1 VALUES(3, randstr(1000,1000)); 657 INSERT INTO t1 VALUES(3, randstr(1000,1000));
658 INSERT INTO t1 VALUES(4, randstr(1000,1000)); 658 INSERT INTO t1 VALUES(4, randstr(1000,1000));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 # 694 #
695 # backup-7.1.*: Source database is externally locked (return SQLITE_BUSY). 695 # backup-7.1.*: Source database is externally locked (return SQLITE_BUSY).
696 # 696 #
697 # backup-7.2.*: Attempt to step the backup process while a 697 # backup-7.2.*: Attempt to step the backup process while a
698 # write-transaction is underway on the source pager (return 698 # write-transaction is underway on the source pager (return
699 # SQLITE_LOCKED). 699 # SQLITE_LOCKED).
700 # 700 #
701 # backup-7.3.*: Destination database is externally locked (return SQLITE_BUSY). 701 # backup-7.3.*: Destination database is externally locked (return SQLITE_BUSY).
702 # 702 #
703 do_test backup-7.0 { 703 do_test backup-7.0 {
704 catch { file delete -force test.db } 704 catch { forcedelete test.db }
705 catch { file delete -force test2.db } 705 catch { forcedelete test2.db }
706 sqlite3 db2 test2.db 706 sqlite3 db2 test2.db
707 sqlite3 db test.db 707 sqlite3 db test.db
708 execsql { 708 execsql {
709 CREATE TABLE t1(a, b); 709 CREATE TABLE t1(a, b);
710 CREATE INDEX i1 ON t1(a, b); 710 CREATE INDEX i1 ON t1(a, b);
711 INSERT INTO t1 VALUES(1, randstr(1000,1000)); 711 INSERT INTO t1 VALUES(1, randstr(1000,1000));
712 INSERT INTO t1 SELECT a+ 1, randstr(1000,1000) FROM t1; 712 INSERT INTO t1 SELECT a+ 1, randstr(1000,1000) FROM t1;
713 INSERT INTO t1 SELECT a+ 2, randstr(1000,1000) FROM t1; 713 INSERT INTO t1 SELECT a+ 2, randstr(1000,1000) FROM t1;
714 INSERT INTO t1 SELECT a+ 4, randstr(1000,1000) FROM t1; 714 INSERT INTO t1 SELECT a+ 4, randstr(1000,1000) FROM t1;
715 INSERT INTO t1 SELECT a+ 8, randstr(1000,1000) FROM t1; 715 INSERT INTO t1 SELECT a+ 8, randstr(1000,1000) FROM t1;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 } {SQLITE_DONE} 747 } {SQLITE_DONE}
748 do_test backup-7.2.4 { 748 do_test backup-7.2.4 {
749 B finish 749 B finish
750 } {SQLITE_OK} 750 } {SQLITE_OK}
751 test_contents backup-7.2.5 db main db2 main 751 test_contents backup-7.2.5 db main db2 main
752 integrity_check backup-7.3.6 db2 752 integrity_check backup-7.3.6 db2
753 753
754 do_test backup-7.3.1 { 754 do_test backup-7.3.1 {
755 db2 close 755 db2 close
756 db3 close 756 db3 close
757 file delete -force test2.db 757 forcedelete test2.db
758 sqlite3 db2 test2.db 758 sqlite3 db2 test2.db
759 sqlite3 db3 test2.db 759 sqlite3 db3 test2.db
760 760
761 sqlite3_backup B db2 main db main 761 sqlite3_backup B db2 main db main
762 execsql { BEGIN ; CREATE TABLE t2(a, b); } db3 762 execsql { BEGIN ; CREATE TABLE t2(a, b); } db3
763 763
764 B step 5 764 B step 5
765 } {SQLITE_BUSY} 765 } {SQLITE_BUSY}
766 do_test backup-7.3.2 { 766 do_test backup-7.3.2 {
767 execsql { COMMIT } db3 767 execsql { COMMIT } db3
768 B step 5000 768 B step 5000
769 } {SQLITE_DONE} 769 } {SQLITE_DONE}
770 do_test backup-7.3.3 { 770 do_test backup-7.3.3 {
771 B finish 771 B finish
772 } {SQLITE_OK} 772 } {SQLITE_OK}
773 test_contents backup-7.3.4 db main db2 main 773 test_contents backup-7.3.4 db main db2 main
774 integrity_check backup-7.3.5 db2 774 integrity_check backup-7.3.5 db2
775 catch { db2 close } 775 catch { db2 close }
776 catch { db3 close } 776 catch { db3 close }
777 777
778 #----------------------------------------------------------------------- 778 #-----------------------------------------------------------------------
779 # The following tests, backup-8.*, test attaching multiple backup 779 # The following tests, backup-8.*, test attaching multiple backup
780 # processes to the same source database. Also, reading from the source 780 # processes to the same source database. Also, reading from the source
781 # database while a read transaction is active. 781 # database while a read transaction is active.
782 # 782 #
783 # These tests reuse the database "test.db" left over from backup-7.*. 783 # These tests reuse the database "test.db" left over from backup-7.*.
784 # 784 #
785 do_test backup-8.1 { 785 do_test backup-8.1 {
786 catch { file delete -force test2.db } 786 catch { forcedelete test2.db }
787 catch { file delete -force test3.db } 787 catch { forcedelete test3.db }
788 sqlite3 db2 test2.db 788 sqlite3 db2 test2.db
789 sqlite3 db3 test3.db 789 sqlite3 db3 test3.db
790 790
791 sqlite3_backup B2 db2 main db main 791 sqlite3_backup B2 db2 main db main
792 sqlite3_backup B3 db3 main db main 792 sqlite3_backup B3 db3 main db main
793 list [B2 finish] [B3 finish] 793 list [B2 finish] [B3 finish]
794 } {SQLITE_OK SQLITE_OK} 794 } {SQLITE_OK SQLITE_OK}
795 do_test backup-8.2 { 795 do_test backup-8.2 {
796 sqlite3_backup B3 db3 main db main 796 sqlite3_backup B3 db3 main db main
797 sqlite3_backup B2 db2 main db main 797 sqlite3_backup B2 db2 main db main
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 do_test backup-9.2.2 { 858 do_test backup-9.2.2 {
859 B remaining 859 B remaining
860 } {0} 860 } {0}
861 do_test backup-9.2.3 { 861 do_test backup-9.2.3 {
862 B finish 862 B finish
863 } {SQLITE_OK} 863 } {SQLITE_OK}
864 catch {db2 close} 864 catch {db2 close}
865 865
866 ifcapable memorymanage { 866 ifcapable memorymanage {
867 db close 867 db close
868 file delete -force test.db 868 forcedelete test.db
869 file delete -force bak.db 869 forcedelete bak.db
870 870
871 sqlite3 db test.db 871 sqlite3 db test.db
872 sqlite3 db2 test.db 872 sqlite3 db2 test.db
873 sqlite3 db3 bak.db 873 sqlite3 db3 bak.db
874 874
875 do_test backup-10.1.1 { 875 do_test backup-10.1.1 {
876 execsql { 876 execsql {
877 BEGIN; 877 BEGIN;
878 CREATE TABLE t1(a, b); 878 CREATE TABLE t1(a, b);
879 INSERT INTO t1 VALUES(1, randstr(1000,1000)); 879 INSERT INTO t1 VALUES(1, randstr(1000,1000));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 911
912 912
913 #----------------------------------------------------------------------- 913 #-----------------------------------------------------------------------
914 # Test that if the database is written to via the same database handle being 914 # Test that if the database is written to via the same database handle being
915 # used as the source by a backup operation: 915 # used as the source by a backup operation:
916 # 916 #
917 # 10.1.*: If the db is in-memory, the backup is restarted. 917 # 10.1.*: If the db is in-memory, the backup is restarted.
918 # 10.2.*: If the db is a file, the backup is not restarted. 918 # 10.2.*: If the db is a file, the backup is not restarted.
919 # 919 #
920 db close 920 db close
921 file delete -force test.db test.db-journal 921 forcedelete test.db test.db-journal
922 foreach {tn file rc} { 922 foreach {tn file rc} {
923 1 test.db SQLITE_DONE 923 1 test.db SQLITE_DONE
924 2 :memory: SQLITE_OK 924 2 :memory: SQLITE_OK
925 } { 925 } {
926 do_test backup-10.$tn.1 { 926 do_test backup-10.$tn.1 {
927 sqlite3 db $file 927 sqlite3 db $file
928 execsql { 928 execsql {
929 CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB); 929 CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB);
930 BEGIN; 930 BEGIN;
931 INSERT INTO t1 VALUES(NULL, randomblob(200)); 931 INSERT INTO t1 VALUES(NULL, randomblob(200));
932 INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1; 932 INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
933 INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1; 933 INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
934 INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1; 934 INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
935 INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1; 935 INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
936 INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1; 936 INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
937 INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1; 937 INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
938 INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1; 938 INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
939 INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1; 939 INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
940 COMMIT; 940 COMMIT;
941 SELECT count(*) FROM t1; 941 SELECT count(*) FROM t1;
942 } 942 }
943 } {256} 943 } {256}
944 944
945 do_test backup-10.$tn.2 { 945 do_test backup-10.$tn.2 {
946 set pgs [execsql {pragma page_count}] 946 set pgs [execsql {pragma page_count}]
947 expr {$pgs > 50 && $pgs < 75} 947 expr {$pgs > 50 && $pgs < 75}
948 } {1} 948 } {1}
949 949
950 do_test backup-10.$tn.3 { 950 do_test backup-10.$tn.3 {
951 file delete -force bak.db bak.db-journal 951 forcedelete bak.db bak.db-journal
952 sqlite3 db2 bak.db 952 sqlite3 db2 bak.db
953 sqlite3_backup B db2 main db main 953 sqlite3_backup B db2 main db main
954 B step 50 954 B step 50
955 } {SQLITE_OK} 955 } {SQLITE_OK}
956 956
957 do_test backup-10.$tn.4 { 957 do_test backup-10.$tn.4 {
958 execsql { UPDATE t1 SET b = randomblob(200) WHERE a IN (1, 250) } 958 execsql { UPDATE t1 SET b = randomblob(200) WHERE a IN (1, 250) }
959 } {} 959 } {}
960 960
961 do_test backup-10.$tn.5 { 961 do_test backup-10.$tn.5 {
962 B step 50 962 B step 50
963 } $rc 963 } $rc
964 964
965 do_test backup-10.$tn.6 { 965 do_test backup-10.$tn.6 {
966 B finish 966 B finish
967 } {SQLITE_OK} 967 } {SQLITE_OK}
968 968
969 db2 close 969 db2 close
970 } 970 }
971 971
972 finish_test 972 finish_test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698