OLD | NEW |
1 # 2007 April 26 | 1 # 2007 April 26 |
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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 set control [execsql "SELECT * FROM $tbl" $A] | 324 set control [execsql "SELECT * FROM $tbl" $A] |
325 do_test ${tname}.[incr tn] [subst { | 325 do_test ${tname}.[incr tn] [subst { |
326 execsql "SELECT * FROM $tbl" $B | 326 execsql "SELECT * FROM $tbl" $B |
327 }] $control | 327 }] $control |
328 } | 328 } |
329 } | 329 } |
330 | 330 |
331 set ::str1 [string repeat abcdefghij 130] | 331 set ::str1 [string repeat abcdefghij 130] |
332 set ::str2 [string repeat 1234567890 105] | 332 set ::str2 [string repeat 1234567890 105] |
333 | 333 |
334 file delete -force test1.db test1.db-journal test2.db test2.db-journal | 334 forcedelete test1.db test1.db-journal test2.db test2.db-journal |
335 sqlite3 db1 test1.db | 335 sqlite3 db1 test1.db |
336 sqlite3 db2 test2.db | 336 sqlite3 db2 test2.db |
337 execsql { PRAGMA auto_vacuum = 'none' } db1 | 337 execsql { PRAGMA auto_vacuum = 'none' } db1 |
338 execsql { PRAGMA auto_vacuum = 'incremental' } db2 | 338 execsql { PRAGMA auto_vacuum = 'incremental' } db2 |
339 | 339 |
340 set tn 1 | 340 set tn 1 |
341 foreach sql $::TestScriptList { | 341 foreach sql $::TestScriptList { |
342 execsql $sql db1 | 342 execsql $sql db1 |
343 execsql $sql db2 | 343 execsql $sql db2 |
344 | 344 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 execsql { | 468 execsql { |
469 PRAGMA incremental_vacuum(50); | 469 PRAGMA incremental_vacuum(50); |
470 } | 470 } |
471 } {} | 471 } {} |
472 | 472 |
473 #--------------------------------------------------------------------- | 473 #--------------------------------------------------------------------- |
474 # At one point this test case was causing an assert() to fail. | 474 # At one point this test case was causing an assert() to fail. |
475 # | 475 # |
476 do_test incrvacuum-9.1 { | 476 do_test incrvacuum-9.1 { |
477 db close | 477 db close |
478 file delete -force test.db test.db-journal | 478 forcedelete test.db test.db-journal |
479 sqlite3 db test.db | 479 sqlite3 db test.db |
480 | 480 |
481 execsql { | 481 execsql { |
482 PRAGMA auto_vacuum = 'incremental'; | 482 PRAGMA auto_vacuum = 'incremental'; |
483 CREATE TABLE t1(a, b, c); | 483 CREATE TABLE t1(a, b, c); |
484 CREATE TABLE t2(a, b, c); | 484 CREATE TABLE t2(a, b, c); |
485 INSERT INTO t2 VALUES(randstr(500,500),randstr(500,500),randstr(500,500)); | 485 INSERT INTO t2 VALUES(randstr(500,500),randstr(500,500),randstr(500,500)); |
486 INSERT INTO t1 VALUES(1, 2, 3); | 486 INSERT INTO t1 VALUES(1, 2, 3); |
487 INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1; | 487 INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1; |
488 INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1; | 488 INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 } | 586 } |
587 expr [file size test.db] / 1024 | 587 expr [file size test.db] / 1024 |
588 } {1} | 588 } {1} |
589 | 589 |
590 #---------------------------------------------------------------- | 590 #---------------------------------------------------------------- |
591 # Test that if we set the auto_vacuum mode to 'incremental', then | 591 # Test that if we set the auto_vacuum mode to 'incremental', then |
592 # create a database, thereafter that database defaults to incremental | 592 # create a database, thereafter that database defaults to incremental |
593 # vacuum mode. | 593 # vacuum mode. |
594 # | 594 # |
595 db close | 595 db close |
596 file delete -force test.db test.db-journal | 596 forcedelete test.db test.db-journal |
597 sqlite3 db test.db | 597 sqlite3 db test.db |
598 | 598 |
599 ifcapable default_autovacuum { | 599 ifcapable default_autovacuum { |
600 do_test incrvacuum-11.1-av-dflt-on { | 600 do_test incrvacuum-11.1-av-dflt-on { |
601 execsql { | 601 execsql { |
602 PRAGMA auto_vacuum; | 602 PRAGMA auto_vacuum; |
603 } | 603 } |
604 } $AUTOVACUUM | 604 } $AUTOVACUUM |
605 } else { | 605 } else { |
606 do_test incrvacuum-11.1-av-dflt-off { | 606 do_test incrvacuum-11.1-av-dflt-off { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 | 644 |
645 # Test we are still in "full" auto-vacuum mode. | 645 # Test we are still in "full" auto-vacuum mode. |
646 execsql { PRAGMA auto_vacuum; } | 646 execsql { PRAGMA auto_vacuum; } |
647 } {1} | 647 } {1} |
648 | 648 |
649 #---------------------------------------------------------------------- | 649 #---------------------------------------------------------------------- |
650 # Special case: What happens if the database is locked when a "PRAGMA | 650 # Special case: What happens if the database is locked when a "PRAGMA |
651 # auto_vacuum = XXX" statement is executed. | 651 # auto_vacuum = XXX" statement is executed. |
652 # | 652 # |
653 db close | 653 db close |
654 file delete -force test.db test.db-journal | 654 forcedelete test.db test.db-journal |
655 sqlite3 db test.db | 655 sqlite3 db test.db |
656 | 656 |
657 do_test incrvacuum-12.1 { | 657 do_test incrvacuum-12.1 { |
658 execsql { | 658 execsql { |
659 PRAGMA auto_vacuum = 1; | 659 PRAGMA auto_vacuum = 1; |
660 } | 660 } |
661 expr {[file size test.db]>0} | 661 expr {[file size test.db]>0} |
662 } {1} | 662 } {1} |
663 | 663 |
664 # Try to change the auto-vacuum from "full" to "incremental" while the | 664 # Try to change the auto-vacuum from "full" to "incremental" while the |
(...skipping 20 matching lines...) Expand all Loading... |
685 execsql { PRAGMA auto_vacuum } | 685 execsql { PRAGMA auto_vacuum } |
686 } {1} | 686 } {1} |
687 | 687 |
688 #---------------------------------------------------------------------- | 688 #---------------------------------------------------------------------- |
689 # Special case #2: What if one process prepares a "PRAGMA auto_vacuum = XXX" | 689 # Special case #2: What if one process prepares a "PRAGMA auto_vacuum = XXX" |
690 # statement when the database is empty, but doesn't execute it until | 690 # statement when the database is empty, but doesn't execute it until |
691 # after some other process has created the database. | 691 # after some other process has created the database. |
692 # | 692 # |
693 db2 close | 693 db2 close |
694 db close | 694 db close |
695 file delete -force test.db test.db-journal | 695 forcedelete test.db test.db-journal |
696 sqlite3 db test.db ; set ::DB [sqlite3_connection_pointer db] | 696 sqlite3 db test.db ; set ::DB [sqlite3_connection_pointer db] |
697 sqlite3 db2 test.db | 697 sqlite3 db2 test.db |
698 | 698 |
699 do_test incrvacuum-13.1 { | 699 do_test incrvacuum-13.1 { |
700 # File size is sometimes 1 instead of 0 due to the hack we put in | 700 # File size is sometimes 1 instead of 0 due to the hack we put in |
701 # to work around ticket #3260. Search for comments on #3260 in | 701 # to work around ticket #3260. Search for comments on #3260 in |
702 # os_unix.c. | 702 # os_unix.c. |
703 expr {[file size test.db]>1} | 703 expr {[file size test.db]>1} |
704 } {0} | 704 } {0} |
705 do_test incrvacuum-13.2 { | 705 do_test incrvacuum-13.2 { |
(...skipping 30 matching lines...) Expand all Loading... |
736 catchsql { | 736 catchsql { |
737 PRAGMA incremental_vacuum(10); | 737 PRAGMA incremental_vacuum(10); |
738 } db3 | 738 } db3 |
739 } {1 {file is encrypted or is not a database}} | 739 } {1 {file is encrypted or is not a database}} |
740 db3 close | 740 db3 close |
741 } | 741 } |
742 | 742 |
743 do_test incrvacuum-15.1 { | 743 do_test incrvacuum-15.1 { |
744 db close | 744 db close |
745 db2 close | 745 db2 close |
746 file delete -force test.db | 746 forcedelete test.db |
747 sqlite3 db test.db | 747 sqlite3 db test.db |
748 | 748 |
749 set str [string repeat "abcdefghij" 500] | 749 set str [string repeat "abcdefghij" 500] |
750 | 750 |
751 execsql { | 751 execsql { |
752 PRAGMA cache_size = 10; | 752 PRAGMA cache_size = 10; |
753 PRAGMA auto_vacuum = incremental; | 753 PRAGMA auto_vacuum = incremental; |
754 CREATE TABLE t1(x, y); | 754 CREATE TABLE t1(x, y); |
755 INSERT INTO t1 VALUES('a', $str); | 755 INSERT INTO t1 VALUES('a', $str); |
756 INSERT INTO t1 VALUES('b', $str); | 756 INSERT INTO t1 VALUES('b', $str); |
(...skipping 20 matching lines...) Expand all Loading... |
777 | 777 |
778 catchsql {INSERT INTO t2 SELECT * FROM t1} | 778 catchsql {INSERT INTO t2 SELECT * FROM t1} |
779 | 779 |
780 execsql { | 780 execsql { |
781 COMMIT; | 781 COMMIT; |
782 PRAGMA integrity_check; | 782 PRAGMA integrity_check; |
783 } | 783 } |
784 } {ok} | 784 } {ok} |
785 | 785 |
786 finish_test | 786 finish_test |
OLD | NEW |