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

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

Issue 949043002: Add //third_party/sqlite to dirs_to_snapshot, remove net_sql.patch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « third_party/sqlite/src/test/server1.test ('k') | third_party/sqlite/src/test/shared2.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2005 December 30 1 # 2005 December 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 #***********************************************************************
11 # 11 #
12 # $Id: shared.test,v 1.36 2009/03/16 13:19:36 danielk1977 Exp $ 12 # $Id: shared.test,v 1.36 2009/03/16 13:19:36 danielk1977 Exp $
13 13
14 set testdir [file dirname $argv0] 14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl 15 source $testdir/tester.tcl
16 db close 16 db close
17 17
18 # These tests cannot be run without the ATTACH command. 18 # These tests cannot be run without the ATTACH command.
19 # 19 #
20 ifcapable !shared_cache||!attach { 20 ifcapable !shared_cache||!attach {
21 finish_test 21 finish_test
22 return 22 return
23 } 23 }
24 24
25 set ::enable_shared_cache [sqlite3_enable_shared_cache 1] 25 set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
26 26
27 foreach av [list 0 1] { 27 foreach av [list 0 1] {
28 28
29 # Open the database connection and execute the auto-vacuum pragma 29 # Open the database connection and execute the auto-vacuum pragma
30 file delete -force test.db 30 forcedelete test.db
31 sqlite3 db test.db 31 sqlite3 db test.db
32 32
33 ifcapable autovacuum { 33 ifcapable autovacuum {
34 do_test shared-[expr $av+1].1.0 { 34 do_test shared-[expr $av+1].1.0 {
35 execsql "pragma auto_vacuum=$::av" 35 execsql "pragma auto_vacuum=$::av"
36 execsql {pragma auto_vacuum} 36 execsql {pragma auto_vacuum}
37 } "$av" 37 } "$av"
38 } else { 38 } else {
39 if {$av} { 39 if {$av} {
40 db close 40 db close
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 # 286 #
287 287
288 # Open two database handles db and db2. Each has a single attach database 288 # Open two database handles db and db2. Each has a single attach database
289 # (as well as main): 289 # (as well as main):
290 # 290 #
291 # db.main -> ./test.db 291 # db.main -> ./test.db
292 # db.test2 -> ./test2.db 292 # db.test2 -> ./test2.db
293 # db2.main -> ./test2.db 293 # db2.main -> ./test2.db
294 # db2.test -> ./test.db 294 # db2.test -> ./test.db
295 # 295 #
296 file delete -force test.db 296 forcedelete test.db
297 file delete -force test2.db 297 forcedelete test2.db
298 file delete -force test2.db-journal 298 forcedelete test2.db-journal
299 sqlite3 db test.db 299 sqlite3 db test.db
300 sqlite3 db2 test2.db 300 sqlite3 db2 test2.db
301 do_test shared-$av.4.1.1 { 301 do_test shared-$av.4.1.1 {
302 set sqlite_open_file_count 302 set sqlite_open_file_count
303 expr $sqlite_open_file_count-($extrafds_prelock*2) 303 expr $sqlite_open_file_count-($extrafds_prelock*2)
304 } {2} 304 } {2}
305 do_test shared-$av.4.1.2 { 305 do_test shared-$av.4.1.2 {
306 execsql {ATTACH 'test2.db' AS test2} 306 execsql {ATTACH 'test2.db' AS test2}
307 set sqlite_open_file_count 307 set sqlite_open_file_count
308 expr $sqlite_open_file_count-($extrafds_postlock*2) 308 expr $sqlite_open_file_count-($extrafds_postlock*2)
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 } {1 {(6) database schema is locked: test}} 419 } {1 {(6) database schema is locked: test}}
420 420
421 421
422 catch {db2 close} 422 catch {db2 close}
423 catch {db close} 423 catch {db close}
424 424
425 #-------------------------------------------------------------------------- 425 #--------------------------------------------------------------------------
426 # Tests shared-5.* 426 # Tests shared-5.*
427 # 427 #
428 foreach db [list test.db test1.db test2.db test3.db] { 428 foreach db [list test.db test1.db test2.db test3.db] {
429 file delete -force $db ${db}-journal 429 forcedelete $db ${db}-journal
430 } 430 }
431 do_test shared-$av.5.1.1 { 431 do_test shared-$av.5.1.1 {
432 sqlite3 db1 test.db 432 sqlite3 db1 test.db
433 sqlite3 db2 test.db 433 sqlite3 db2 test.db
434 execsql { 434 execsql {
435 ATTACH 'test1.db' AS test1; 435 ATTACH 'test1.db' AS test1;
436 ATTACH 'test2.db' AS test2; 436 ATTACH 'test2.db' AS test2;
437 ATTACH 'test3.db' AS test3; 437 ATTACH 'test3.db' AS test3;
438 } db1 438 } db1
439 execsql { 439 execsql {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 } { 550 } {
551 lappend ret $d 551 lappend ret $d
552 } 552 }
553 } 553 }
554 set ret 554 set ret
555 } {} 555 } {}
556 556
557 catch {db1 close} 557 catch {db1 close}
558 catch {db2 close} 558 catch {db2 close}
559 foreach f [list test.db test2.db] { 559 foreach f [list test.db test2.db] {
560 file delete -force $f ${f}-journal 560 forcedelete $f ${f}-journal
561 } 561 }
562 562
563 #-------------------------------------------------------------------------- 563 #--------------------------------------------------------------------------
564 # Tests shared-7.* test auto-vacuum does not invalidate cursors from 564 # Tests shared-7.* test auto-vacuum does not invalidate cursors from
565 # other shared-cache users when it reorganizes the database on 565 # other shared-cache users when it reorganizes the database on
566 # COMMIT. 566 # COMMIT.
567 # 567 #
568 do_test shared-$av.7.1 { 568 do_test shared-$av.7.1 {
569 # This test case sets up a test database in auto-vacuum mode consisting 569 # This test case sets up a test database in auto-vacuum mode consisting
570 # of two tables, t1 and t2. Both have a single index. Table t1 is 570 # of two tables, t1 and t2. Both have a single index. Table t1 is
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 } {0} 636 } {0}
637 637
638 catch {db close} 638 catch {db close}
639 catch {db2 close} 639 catch {db2 close}
640 unset -nocomplain contents 640 unset -nocomplain contents
641 641
642 #-------------------------------------------------------------------------- 642 #--------------------------------------------------------------------------
643 # The following tests try to trick the shared-cache code into assuming 643 # The following tests try to trick the shared-cache code into assuming
644 # the wrong encoding for a database. 644 # the wrong encoding for a database.
645 # 645 #
646 file delete -force test.db test.db-journal 646 forcedelete test.db test.db-journal
647 ifcapable utf16 { 647 ifcapable utf16 {
648 do_test shared-$av.8.1.1 { 648 do_test shared-$av.8.1.1 {
649 sqlite3 db test.db 649 sqlite3 db test.db
650 execsql { 650 execsql {
651 PRAGMA encoding = 'UTF-16'; 651 PRAGMA encoding = 'UTF-16';
652 SELECT * FROM sqlite_master; 652 SELECT * FROM sqlite_master;
653 } 653 }
654 } {} 654 } {}
655 do_test shared-$av.8.1.2 { 655 do_test shared-$av.8.1.2 {
656 string range [execsql {PRAGMA encoding;}] 0 end-2 656 string range [execsql {PRAGMA encoding;}] 0 end-2
(...skipping 11 matching lines...) Expand all
668 SELECT * FROM sqlite_master; 668 SELECT * FROM sqlite_master;
669 } 669 }
670 } "table abc abc [expr $AUTOVACUUM?3:2] {CREATE TABLE abc(a, b, c)}" 670 } "table abc abc [expr $AUTOVACUUM?3:2] {CREATE TABLE abc(a, b, c)}"
671 do_test shared-$av.8.1.5 { 671 do_test shared-$av.8.1.5 {
672 db2 close 672 db2 close
673 execsql { 673 execsql {
674 PRAGMA encoding; 674 PRAGMA encoding;
675 } 675 }
676 } {UTF-8} 676 } {UTF-8}
677 677
678 file delete -force test2.db test2.db-journal 678 forcedelete test2.db test2.db-journal
679 do_test shared-$av.8.2.1 { 679 do_test shared-$av.8.2.1 {
680 execsql { 680 execsql {
681 ATTACH 'test2.db' AS aux; 681 ATTACH 'test2.db' AS aux;
682 SELECT * FROM aux.sqlite_master; 682 SELECT * FROM aux.sqlite_master;
683 } 683 }
684 } {} 684 } {}
685 do_test shared-$av.8.2.2 { 685 do_test shared-$av.8.2.2 {
686 sqlite3 db2 test2.db 686 sqlite3 db2 test2.db
687 execsql { 687 execsql {
688 PRAGMA encoding = 'UTF-16'; 688 PRAGMA encoding = 'UTF-16';
689 CREATE TABLE def(d, e, f); 689 CREATE TABLE def(d, e, f);
690 } db2 690 } db2
691 string range [execsql {PRAGMA encoding;} db2] 0 end-2 691 string range [execsql {PRAGMA encoding;} db2] 0 end-2
692 } {UTF-16} 692 } {UTF-16}
693 693
694 catch {db close} 694 catch {db close}
695 catch {db2 close} 695 catch {db2 close}
696 file delete -force test.db test2.db 696 forcedelete test.db test2.db
697 697
698 do_test shared-$av.8.3.2 { 698 do_test shared-$av.8.3.2 {
699 sqlite3 db test.db 699 sqlite3 db test.db
700 execsql { CREATE TABLE def(d, e, f) } 700 execsql { CREATE TABLE def(d, e, f) }
701 execsql { PRAGMA encoding } 701 execsql { PRAGMA encoding }
702 } {UTF-8} 702 } {UTF-8}
703 do_test shared-$av.8.3.3 { 703 do_test shared-$av.8.3.3 {
704 set zDb16 "[encoding convertto unicode test.db]\x00\x00" 704 set zDb16 "[encoding convertto unicode test.db]\x00\x00"
705 set db16 [sqlite3_open16 $zDb16 {}] 705 set db16 [sqlite3_open16 $zDb16 {}]
706 706
(...skipping 18 matching lines...) Expand all
725 do_test shared-$av.8.2.3 { 725 do_test shared-$av.8.2.3 {
726 catchsql { 726 catchsql {
727 SELECT * FROM aux.sqlite_master; 727 SELECT * FROM aux.sqlite_master;
728 } 728 }
729 } {1 {attached databases must use the same text encoding as main database}} 729 } {1 {attached databases must use the same text encoding as main database}}
730 } 730 }
731 } 731 }
732 732
733 catch {db close} 733 catch {db close}
734 catch {db2 close} 734 catch {db2 close}
735 file delete -force test.db test2.db 735 forcedelete test.db test2.db
736 736
737 #--------------------------------------------------------------------------- 737 #---------------------------------------------------------------------------
738 # The following tests - shared-9.* - test interactions between TEMP triggers 738 # The following tests - shared-9.* - test interactions between TEMP triggers
739 # and shared-schemas. 739 # and shared-schemas.
740 # 740 #
741 ifcapable trigger&&tempdb { 741 ifcapable trigger&&tempdb {
742 742
743 do_test shared-$av.9.1 { 743 do_test shared-$av.9.1 {
744 sqlite3 db test.db 744 sqlite3 db test.db
745 sqlite3 db2 test.db 745 sqlite3 db2 test.db
(...skipping 19 matching lines...) Expand all
765 } {} 765 } {}
766 766
767 } ; # End shared-9.* 767 } ; # End shared-9.*
768 768
769 #--------------------------------------------------------------------------- 769 #---------------------------------------------------------------------------
770 # The following tests - shared-10.* - test that the library behaves 770 # The following tests - shared-10.* - test that the library behaves
771 # correctly when a connection to a shared-cache is closed. 771 # correctly when a connection to a shared-cache is closed.
772 # 772 #
773 do_test shared-$av.10.1 { 773 do_test shared-$av.10.1 {
774 # Create a small sample database with two connections to it (db and db2). 774 # Create a small sample database with two connections to it (db and db2).
775 file delete -force test.db 775 forcedelete test.db
776 sqlite3 db test.db 776 sqlite3 db test.db
777 sqlite3 db2 test.db 777 sqlite3 db2 test.db
778 execsql { 778 execsql {
779 CREATE TABLE ab(a PRIMARY KEY, b); 779 CREATE TABLE ab(a PRIMARY KEY, b);
780 CREATE TABLE de(d PRIMARY KEY, e); 780 CREATE TABLE de(d PRIMARY KEY, e);
781 INSERT INTO ab VALUES('Chiang Mai', 100000); 781 INSERT INTO ab VALUES('Chiang Mai', 100000);
782 INSERT INTO ab VALUES('Bangkok', 8000000); 782 INSERT INTO ab VALUES('Bangkok', 8000000);
783 INSERT INTO de VALUES('Ubon', 120000); 783 INSERT INTO de VALUES('Ubon', 120000);
784 INSERT INTO de VALUES('Khon Kaen', 200000); 784 INSERT INTO de VALUES('Khon Kaen', 200000);
785 } 785 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 # Commit the external transaction. 846 # Commit the external transaction.
847 catchsql {COMMIT} db3 847 catchsql {COMMIT} db3
848 } {0 {}} 848 } {0 {}}
849 integrity_check shared-$av.10.10 849 integrity_check shared-$av.10.10
850 do_test shared-$av.10.11 { 850 do_test shared-$av.10.11 {
851 db close 851 db close
852 db3 close 852 db3 close
853 } {} 853 } {}
854 854
855 do_test shared-$av.11.1 { 855 do_test shared-$av.11.1 {
856 file delete -force test.db 856 forcedelete test.db
857 sqlite3 db test.db 857 sqlite3 db test.db
858 sqlite3 db2 test.db 858 sqlite3 db2 test.db
859 execsql { 859 execsql {
860 CREATE TABLE abc(a, b, c); 860 CREATE TABLE abc(a, b, c);
861 CREATE TABLE abc2(a, b, c); 861 CREATE TABLE abc2(a, b, c);
862 BEGIN; 862 BEGIN;
863 INSERT INTO abc VALUES(1, 2, 3); 863 INSERT INTO abc VALUES(1, 2, 3);
864 } 864 }
865 } {} 865 } {}
866 do_test shared-$av.11.2 { 866 do_test shared-$av.11.2 {
(...skipping 30 matching lines...) Expand all
897 SELECT abc.a as I, abc2.a as II FROM abc, abc2; 897 SELECT abc.a as I, abc2.a as II FROM abc, abc2;
898 } { 898 } {
899 execsql { 899 execsql {
900 DELETE FROM abc WHERE 1; 900 DELETE FROM abc WHERE 1;
901 } 901 }
902 lappend res $I $II 902 lappend res $I $II
903 } 903 }
904 set res 904 set res
905 } {1 4 {} 7} 905 } {1 4 {} 7}
906 if {[llength [info command sqlite3_shared_cache_report]]==1} { 906 if {[llength [info command sqlite3_shared_cache_report]]==1} {
907 do_test shared-$av.11.9 { 907 ifcapable curdir {
908 string tolower [sqlite3_shared_cache_report] 908 do_test shared-$av.11.9 {
909 } [string tolower [list [file nativename [file normalize test.db]] 2]] 909 string tolower [sqlite3_shared_cache_report]
910 } [string tolower [list [file nativename [file normalize test.db]] 2]]
911 }
910 } 912 }
911 913
912 do_test shared-$av.11.11 { 914 do_test shared-$av.11.11 {
913 db close 915 db close
914 db2 close 916 db2 close
915 } {} 917 } {}
916 918
917 # This tests that if it is impossible to free any pages, SQLite will 919 # This tests that if it is impossible to free any pages, SQLite will
918 # exceed the limit set by PRAGMA cache_size. 920 # exceed the limit set by PRAGMA cache_size.
919 file delete -force test.db test.db-journal 921 forcedelete test.db test.db-journal
920 sqlite3 db test.db 922 sqlite3 db test.db
921 ifcapable pager_pragmas { 923 ifcapable pager_pragmas {
922 do_test shared-$av.12.1 { 924 do_test shared-$av.12.1 {
923 execsql { 925 execsql {
924 PRAGMA cache_size = 10; 926 PRAGMA cache_size = 10;
925 PRAGMA cache_size; 927 PRAGMA cache_size;
926 } 928 }
927 } {10} 929 } {10}
928 } 930 }
929 do_test shared-$av.12.2 { 931 do_test shared-$av.12.2 {
(...skipping 26 matching lines...) Expand all
956 } 958 }
957 } {} 959 } {}
958 960
959 # Internally, locks are acquired on shared B-Tree structures in the order 961 # Internally, locks are acquired on shared B-Tree structures in the order
960 # that the structures appear in the virtual memory address space. This 962 # that the structures appear in the virtual memory address space. This
961 # test case attempts to cause the order of the structures in memory 963 # test case attempts to cause the order of the structures in memory
962 # to be different from the order in which they are attached to a given 964 # to be different from the order in which they are attached to a given
963 # database handle. This covers an extra line or two. 965 # database handle. This covers an extra line or two.
964 # 966 #
965 do_test shared-$av.13.1 { 967 do_test shared-$av.13.1 {
966 file delete -force test2.db test3.db test4.db test5.db 968 forcedelete test2.db test3.db test4.db test5.db
967 sqlite3 db :memory: 969 sqlite3 db :memory:
968 execsql { 970 execsql {
969 ATTACH 'test2.db' AS aux2; 971 ATTACH 'test2.db' AS aux2;
970 ATTACH 'test3.db' AS aux3; 972 ATTACH 'test3.db' AS aux3;
971 ATTACH 'test4.db' AS aux4; 973 ATTACH 'test4.db' AS aux4;
972 ATTACH 'test5.db' AS aux5; 974 ATTACH 'test5.db' AS aux5;
973 DETACH aux2; 975 DETACH aux2;
974 DETACH aux3; 976 DETACH aux3;
975 DETACH aux4; 977 DETACH aux4;
976 ATTACH 'test2.db' AS aux2; 978 ATTACH 'test2.db' AS aux2;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 } {} 1021 } {}
1020 1022
1021 # Populate a database schema using connection [db]. Then drop it using 1023 # Populate a database schema using connection [db]. Then drop it using
1022 # [db2]. This is to try to find any points where shared-schema elements 1024 # [db2]. This is to try to find any points where shared-schema elements
1023 # are allocated using the lookaside buffer of [db]. 1025 # are allocated using the lookaside buffer of [db].
1024 # 1026 #
1025 # Mutexes are enabled for this test as that activates a couple of useful 1027 # Mutexes are enabled for this test as that activates a couple of useful
1026 # assert() statements in the C code. 1028 # assert() statements in the C code.
1027 # 1029 #
1028 do_test shared-$av-15.1 { 1030 do_test shared-$av-15.1 {
1029 file delete -force test.db 1031 forcedelete test.db
1030 sqlite3 db test.db -fullmutex 1 1032 sqlite3 db test.db -fullmutex 1
1031 sqlite3 db2 test.db -fullmutex 1 1033 sqlite3 db2 test.db -fullmutex 1
1032 execsql { 1034 execsql {
1033 CREATE TABLE t1(a, b, c); 1035 CREATE TABLE t1(a, b, c);
1034 CREATE INDEX i1 ON t1(a, b); 1036 CREATE INDEX i1 ON t1(a, b);
1035 CREATE VIEW v1 AS SELECT * FROM t1; 1037 CREATE VIEW v1 AS SELECT * FROM t1;
1036 CREATE VIEW v2 AS SELECT * FROM t1, v1 1038 CREATE VIEW v2 AS SELECT * FROM t1, v1
1037 WHERE t1.c=v1.c GROUP BY t1.a ORDER BY v1.b; 1039 WHERE t1.c=v1.c GROUP BY t1.a ORDER BY v1.b;
1038 CREATE TRIGGER tr1 AFTER INSERT ON t1 1040 CREATE TRIGGER tr1 AFTER INSERT ON t1
1039 WHEN new.a!=1 1041 WHEN new.a!=1
1040 BEGIN 1042 BEGIN
1041 DELETE FROM t1 WHERE a=5; 1043 DELETE FROM t1 WHERE a=5;
1042 INSERT INTO t1 VALUES(1, 2, 3); 1044 INSERT INTO t1 VALUES(1, 2, 3);
1043 UPDATE t1 SET c=c+1; 1045 UPDATE t1 SET c=c+1;
1044 END; 1046 END;
1045 1047
1046 INSERT INTO t1 VALUES(5, 6, 7); 1048 INSERT INTO t1 VALUES(5, 6, 7);
1047 INSERT INTO t1 VALUES(8, 9, 10); 1049 INSERT INTO t1 VALUES(8, 9, 10);
1048 INSERT INTO t1 VALUES(11, 12, 13); 1050 INSERT INTO t1 VALUES(11, 12, 13);
1049 ANALYZE; 1051 ANALYZE;
1050 SELECT * FROM t1; 1052 SELECT * FROM t1;
1051 } 1053 }
1052 } {1 2 6 8 9 12 1 2 5 11 12 14 1 2 4} 1054 } {1 2 6 8 9 12 1 2 5 11 12 14 1 2 4}
1053 do_test shared-$av-15.2 { 1055 do_test shared-$av-15.2 {
1054 execsql { DROP TABLE t1 } db2 1056 execsql { DROP TABLE t1 } db2
1055 } {} 1057 } {}
1056 db close 1058 db close
1057 db2 close 1059 db2 close
1058 1060
1059 } 1061 # Shared cache on a :memory: database. This only works for URI filenames.
1062 #
1063 do_test shared-$av-16.1 {
1064 sqlite3 db1 file::memory: -uri 1
1065 sqlite3 db2 file::memory: -uri 1
1066 db1 eval {
1067 CREATE TABLE t1(x); INSERT INTO t1 VALUES(1),(2),(3);
1068 }
1069 db2 eval {
1070 SELECT x FROM t1 ORDER BY x;
1071 }
1072 } {1 2 3}
1073 do_test shared-$av-16.2 {
1074 db2 eval {
1075 INSERT INTO t1 VALUES(99);
1076 DELETE FROM t1 WHERE x=2;
1077 }
1078 db1 eval {
1079 SELECT x FROM t1 ORDER BY x;
1080 }
1081 } {1 3 99}
1082
1083 # Verify that there is no cache sharing ordinary (non-URI) filenames are
1084 # used.
1085 #
1086 do_test shared-$av-16.3 {
1087 db1 close
1088 db2 close
1089 sqlite3 db1 :memory:
1090 sqlite3 db2 :memory:
1091 db1 eval {
1092 CREATE TABLE t1(x); INSERT INTO t1 VALUES(4),(5),(6);
1093 }
1094 catchsql {
1095 SELECT * FROM t1;
1096 } db2
1097 } {1 {no such table: t1}}
1098
1099 # Shared cache on named memory databases.
1100 #
1101 do_test shared-$av-16.4 {
1102 db1 close
1103 db2 close
1104 forcedelete test.db test.db-wal test.db-journal
1105 sqlite3 db1 file:test.db?mode=memory -uri 1
1106 sqlite3 db2 file:test.db?mode=memory -uri 1
1107 db1 eval {
1108 CREATE TABLE t1(x); INSERT INTO t1 VALUES(1),(2),(3);
1109 }
1110 db2 eval {
1111 SELECT x FROM t1 ORDER BY x;
1112 }
1113 } {1 2 3}
1114 do_test shared-$av-16.5 {
1115 db2 eval {
1116 INSERT INTO t1 VALUES(99);
1117 DELETE FROM t1 WHERE x=2;
1118 }
1119 db1 eval {
1120 SELECT x FROM t1 ORDER BY x;
1121 }
1122 } {1 3 99}
1123 do_test shared-$av-16.6 {
1124 file exists test.db
1125 } {0} ;# Verify that the database is in-memory
1126
1127 # Shared cache on named memory databases with different names.
1128 #
1129 do_test shared-$av-16.7 {
1130 db1 close
1131 db2 close
1132 forcedelete test1.db test2.db
1133 sqlite3 db1 file:test1.db?mode=memory -uri 1
1134 sqlite3 db2 file:test2.db?mode=memory -uri 1
1135 db1 eval {
1136 CREATE TABLE t1(x); INSERT INTO t1 VALUES(1),(2),(3);
1137 }
1138 catchsql {
1139 SELECT x FROM t1 ORDER BY x;
1140 } db2
1141 } {1 {no such table: t1}}
1142 do_test shared-$av-16.8 {
1143 file exists test1.db
1144 } {0} ;# Verify that the database is in-memory
1145
1146 # Shared cache on named memory databases attached to readonly connections.
1147 #
1148 do_test shared-$av-16.8.1 {
1149 db1 close
1150 db2 close
1151
1152 sqlite3 db test1.db
1153 db eval {
1154 CREATE TABLE yy(a, b);
1155 INSERT INTO yy VALUES(77, 88);
1156 }
1157 db close
1158
1159 sqlite3 db1 test1.db -uri 1 -readonly 1
1160 sqlite3 db2 test2.db -uri 1
1161
1162 db1 eval {
1163 ATTACH 'file:mem?mode=memory&cache=shared' AS shared;
1164 CREATE TABLE shared.xx(a, b);
1165 INSERT INTO xx VALUES(55, 66);
1166 }
1167 db2 eval {
1168 ATTACH 'file:mem?mode=memory&cache=shared' AS shared;
1169 SELECT * FROM xx;
1170 }
1171 } {55 66}
1172
1173 do_test shared-$av-16.8.2 { db1 eval { SELECT * FROM yy } } {77 88}
1174 do_test shared-$av-16.8.3 {
1175 list [catch {db1 eval { INSERT INTO yy VALUES(1, 2) }} msg] $msg
1176 } {1 {attempt to write a readonly database}}
1177
1178 db1 close
1179 db2 close
1180
1181 } ;# end of autovacuum on/off loop
1060 1182
1061 sqlite3_enable_shared_cache $::enable_shared_cache 1183 sqlite3_enable_shared_cache $::enable_shared_cache
1062 finish_test 1184 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/server1.test ('k') | third_party/sqlite/src/test/shared2.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698