From: dan Date: Fri, 5 Oct 2012 17:18:16 +0000 (+0000) Subject: Add a test for the collation-sequence/CHECK constraint problem fixed by the previous... X-Git-Tag: version-3.7.15~89^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a2ebe4b418c20099d5582dcc8c31a180bb853b11;p=thirdparty%2Fsqlite.git Add a test for the collation-sequence/CHECK constraint problem fixed by the previous commit. FossilOrigin-Name: 82b6aa77c8d8de4c6fad1960f5958457a929a821 --- diff --git a/manifest b/manifest index f6c4043cc1..00aaa5060f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\sshared-cache\smode\sand\sCHECK\sconstraints\scausing\sone\sdb\shandle\sto\sinvoke\sa\scollation\ssequence\sfunction\sregistered\swith\sanother. -D 2012-10-05T16:30:10.692 +C Add\sa\stest\sfor\sthe\scollation-sequence/CHECK\sconstraint\sproblem\sfixed\sby\sthe\sprevious\scommit. +D 2012-10-05T17:18:16.288 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -702,7 +702,7 @@ F test/shared4.test 72d90821e8d2fc918a08f16d32880868d8ee8e9d F test/shared6.test 866bb4982c45ce216c61ded5e8fde4e7e2f3ffa9 F test/shared7.test 960760bc8d03e1419e70dea69cf41db62853616e F test/shared8.test b27befbefbe7f4517f1d6b7ff8f64a41ec74165d -F test/shared9.test 61cf645c716451642ae9be2342fada8b200649c3 +F test/shared9.test 3a5b09583e3ba3139a4bd66958061306b4331c7e F test/shared_err.test 91e26ec4f3fbe07951967955585137e2f18993de F test/sharedlock.test ffa0a3c4ac192145b310f1254f8afca4d553eabf F test/shell1.test 272384163432c0efd2c6817396beb0d119565d53 @@ -1019,7 +1019,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P 2b370dea704b59262c604af0efcef5660b194454 -R b8d4e5a86ac362df32fe82058e93d169 +P c2c776ab73828374836af008aa320cc670c081b5 +R 944a2743bc72c249d323dde91a15aa61 U dan -Z c2b386d7cf024f01e0a45b9a845b3c47 +Z fb89a86dbc14aadae3bf562a37bf56e5 diff --git a/manifest.uuid b/manifest.uuid index a72d51b876..65775bb214 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c2c776ab73828374836af008aa320cc670c081b5 \ No newline at end of file +82b6aa77c8d8de4c6fad1960f5958457a929a821 \ No newline at end of file diff --git a/test/shared9.test b/test/shared9.test index 99c2b29f8f..bb0dfee186 100644 --- a/test/shared9.test +++ b/test/shared9.test @@ -17,15 +17,15 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl set testprefix shared9 + +ifcapable !view||!trigger { + finish_test + return +} + db close set enable_shared_cache [sqlite3_enable_shared_cache 1] -# Test organization: -# -# 1.* - Views. -# 2.* - Virtual tables. -# - sqlite3 db1 test.db sqlite3 db2 test.db forcedelete test.db2 @@ -48,31 +48,93 @@ do_test 1.1 { } {1 2} do_test 1.2 { db2 eval "ATTACH 'test.db2' AS 'jones'" } {} -do_test 1.2 { db2 eval "SELECT * FROM v1" } {} -do_test 1.3 { db2 eval "INSERT INTO t2 VALUES(3, 4)" } {} +do_test 1.3 { db2 eval "SELECT * FROM v1" } {} +do_test 1.4 { db2 eval "INSERT INTO t2 VALUES(3, 4)" } {} + +ifcapable fts3 { + do_test 1.5 { + db1 eval { + CREATE VIRTUAL TABLE fred.t4 USING fts4; + INSERT INTO t4 VALUES('hello world'); + } + } {} + + do_test 1.6 { + db2 eval { + INSERT INTO t4 VALUES('shared cache'); + SELECT * FROM t4 WHERE t4 MATCH 'hello'; + } + } {{hello world}} + + do_test 1.7 { + db1 eval { + SELECT * FROM t4 WHERE t4 MATCH 'c*'; + } + } {{shared cache}} +} +db1 close +db2 close + +#------------------------------------------------------------------------- +# The following tests attempt to find a similar problem with collation +# sequence names - pointers to database handle specific allocations leaking +# into schema objects and being used after the original handle has been +# closed. +# +forcedelete test.db test.db2 +sqlite3 db1 test.db +sqlite3 db2 test.db +foreach x {collate1 collate2 collate3} { + proc $x {a b} { string compare $a $b } + db1 collate $x $x + db2 collate $x $x +} do_test 2.1 { db1 eval { - CREATE VIRTUAL TABLE fred.t4 USING fts4; - INSERT INTO t4 VALUES('hello world'); + CREATE TABLE t1(a, b, c COLLATE collate1); + CREATE INDEX i1 ON t1(a COLLATE collate2, c, b); } } {} - do_test 2.2 { - db2 eval { - INSERT INTO t4 VALUES('shared cache'); - SELECT * FROM t4 WHERE t4 MATCH 'hello'; - } -} {{hello world}} + db1 close + db2 eval "INSERT INTO t1 VALUES('abc', 'def', 'ghi')" +} {} +db2 close + +#------------------------------------------------------------------------- +# At one point, the following would cause a collation sequence belonging +# to connection [db1] to be invoked by a call to [db2 eval]. Which is a +# problem if [db1] has already been closed. +# +forcedelete test.db test.db2 +sqlite3 db1 test.db +sqlite3 db2 test.db + +proc mycollate_db1 {a b} {set ::invoked_mycollate_db1 1 ; string compare $a $b} +proc mycollate_db2 {a b} {string compare $a $b} + +db1 collate mycollate mycollate_db1 +db2 collate mycollate mycollate_db2 do_test 2.3 { + set ::invoked_mycollate_db1 0 db1 eval { - SELECT * FROM t4 WHERE t4 MATCH 'c*'; + CREATE TABLE t1(a COLLATE mycollate, CHECK (a IN ('one', 'two', 'three'))); + INSERT INTO t1 VALUES('one'); } -} {{shared cache}} + db1 close + set ::invoked_mycollate_db1 +} {1} +do_test 2.4 { + set ::invoked_mycollate_db1 0 + db2 eval { + INSERT INTO t1 VALUES('two'); + } + db2 close + set ::invoked_mycollate_db1 +} {0} -db1 close -db2 close sqlite3_enable_shared_cache $::enable_shared_cache finish_test