SQLite
Check-in [82b6aa77c8]
Not logged in
Overview
SHA1 Hash:82b6aa77c8d8de4c6fad1960f5958457a929a821
Date: 2012-10-05 17:18:16
User: dan
Comment:Add a test for the collation-sequence/CHECK constraint problem fixed by the previous commit.
Tags And Properties
Changes
hide diffs unified diffs patch

Changes to test/shared9.test

13 # to the same shared cache using different database names, views and 13 # to the same shared cache using different database names, views and 14 # virtual tables may still be accessed. 14 # virtual tables may still be accessed. 15 # 15 # 16 16 17 set testdir [file dirname $argv0] 17 set testdir [file dirname $argv0] 18 source $testdir/tester.tcl 18 source $testdir/tester.tcl 19 set testprefix shared9 19 set testprefix shared9 > 20 > 21 ifcapable !view||!trigger { > 22 finish_test > 23 return > 24 } > 25 20 db close 26 db close 21 set enable_shared_cache [sqlite3_enable_shared_cache 1] 27 set enable_shared_cache [sqlite3_enable_shared_cache 1] 22 28 23 # Test organization: < 24 # < 25 # 1.* - Views. < 26 # 2.* - Virtual tables. < 27 # < 28 < 29 sqlite3 db1 test.db 29 sqlite3 db1 test.db 30 sqlite3 db2 test.db 30 sqlite3 db2 test.db 31 forcedelete test.db2 31 forcedelete test.db2 32 32 33 do_test 1.1 { 33 do_test 1.1 { 34 db1 eval { 34 db1 eval { 35 ATTACH 'test.db2' AS 'fred'; 35 ATTACH 'test.db2' AS 'fred'; ................................................................................................................................................................................ 44 END; 44 END; 45 INSERT INTO t2 VALUES(1, 2); 45 INSERT INTO t2 VALUES(1, 2); 46 SELECT * FROM t3; 46 SELECT * FROM t3; 47 } 47 } 48 } {1 2} 48 } {1 2} 49 49 50 do_test 1.2 { db2 eval "ATTACH 'test.db2' AS 'jones'" } {} 50 do_test 1.2 { db2 eval "ATTACH 'test.db2' AS 'jones'" } {} 51 do_test 1.2 { db2 eval "SELECT * FROM v1" } {} | 51 do_test 1.3 { db2 eval "SELECT * FROM v1" } {} 52 do_test 1.3 { db2 eval "INSERT INTO t2 VALUES(3, 4)" } {} | 52 do_test 1.4 { db2 eval "INSERT INTO t2 VALUES(3, 4)" } {} 53 53 > 54 ifcapable fts3 { 54 do_test 2.1 { | 55 do_test 1.5 { 55 db1 eval { | 56 db1 eval { 56 CREATE VIRTUAL TABLE fred.t4 USING fts4; | 57 CREATE VIRTUAL TABLE fred.t4 USING fts4; 57 INSERT INTO t4 VALUES('hello world'); | 58 INSERT INTO t4 VALUES('hello world'); 58 } | 59 } 59 } {} | 60 } {} 60 61 61 do_test 2.2 { | 62 do_test 1.6 { 62 db2 eval { | 63 db2 eval { 63 INSERT INTO t4 VALUES('shared cache'); | 64 INSERT INTO t4 VALUES('shared cache'); 64 SELECT * FROM t4 WHERE t4 MATCH 'hello'; | 65 SELECT * FROM t4 WHERE t4 MATCH 'hello'; 65 } | 66 } 66 } {{hello world}} | 67 } {{hello world}} 67 68 68 do_test 2.3 { | 69 do_test 1.7 { 69 db1 eval { | 70 db1 eval { 70 SELECT * FROM t4 WHERE t4 MATCH 'c*'; | 71 SELECT * FROM t4 WHERE t4 MATCH 'c*'; 71 } | 72 } 72 } {{shared cache}} | 73 } {{shared cache}} 73 | 74 } > 75 74 db1 close 76 db1 close 75 db2 close 77 db2 close > 78 > 79 #------------------------------------------------------------------------- > 80 # The following tests attempt to find a similar problem with collation > 81 # sequence names - pointers to database handle specific allocations leaking > 82 # into schema objects and being used after the original handle has been > 83 # closed. > 84 # > 85 forcedelete test.db test.db2 > 86 sqlite3 db1 test.db > 87 sqlite3 db2 test.db > 88 foreach x {collate1 collate2 collate3} { > 89 proc $x {a b} { string compare $a $b } > 90 db1 collate $x $x > 91 db2 collate $x $x > 92 } > 93 do_test 2.1 { > 94 db1 eval { > 95 CREATE TABLE t1(a, b, c COLLATE collate1); > 96 CREATE INDEX i1 ON t1(a COLLATE collate2, c, b); > 97 } > 98 } {} > 99 do_test 2.2 { > 100 db1 close > 101 db2 eval "INSERT INTO t1 VALUES('abc', 'def', 'ghi')" > 102 } {} > 103 db2 close > 104 > 105 #------------------------------------------------------------------------- > 106 # At one point, the following would cause a collation sequence belonging > 107 # to connection [db1] to be invoked by a call to [db2 eval]. Which is a > 108 # problem if [db1] has already been closed. > 109 # > 110 forcedelete test.db test.db2 > 111 sqlite3 db1 test.db > 112 sqlite3 db2 test.db > 113 > 114 proc mycollate_db1 {a b} {set ::invoked_mycollate_db1 1 ; string compare $a $b} > 115 proc mycollate_db2 {a b} {string compare $a $b} > 116 > 117 db1 collate mycollate mycollate_db1 > 118 db2 collate mycollate mycollate_db2 > 119 > 120 do_test 2.3 { > 121 set ::invoked_mycollate_db1 0 > 122 db1 eval { > 123 CREATE TABLE t1(a COLLATE mycollate, CHECK (a IN ('one', 'two', 'three'))); > 124 INSERT INTO t1 VALUES('one'); > 125 } > 126 db1 close > 127 set ::invoked_mycollate_db1 > 128 } {1} > 129 do_test 2.4 { > 130 set ::invoked_mycollate_db1 0 > 131 db2 eval { > 132 INSERT INTO t1 VALUES('two'); > 133 } > 134 db2 close > 135 set ::invoked_mycollate_db1 > 136 } {0} > 137 76 sqlite3_enable_shared_cache $::enable_shared_cache 138 sqlite3_enable_shared_cache $::enable_shared_cache 77 finish_test 139 finish_test 78 140