-C Merge\swith\s709e16145e.
-D 2009-08-19T14:42:25
+C Add\ssome\stests\sthat\suse\sthe\ssqlite_stat2\stable\sin\sshared-cache\smode.
+D 2009-08-19T15:34:59
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 0f7761c5d1c62ae7a841e3393ffaff1fa0f5c00a
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F test/alter4.test 9386ffd1e9c7245f43eca412b2058d747509cc1f
F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc
F test/analyze.test ad5329098fe4de4a96852231d53e3e9e6283ad4b
-F test/analyze2.test eb66cbd9486460a9a74876d2c6e0a49a08a44a87
+F test/analyze2.test f3c0944b854fb33987dbadd1e95913365c33deb7
F test/async.test 8c75d31b8330f8b70cf2571b014d4476a063efdb
F test/async2.test bf5e2ca2c96763b4cba3d016249ad7259a5603b6
F test/async3.test 93edaa9122f498e56ea98c36c72abc407f4fb11e
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
-P aa728e06ce456fa42e68687bff6c7424460c31ef 709e16145e37940cb243eede75071fb15095d960
-R f834f9dc41038ed48095999e07ccab3c
+P 6c8a0e2b37d9f4399ef90a44cbc492526201d0d5
+R c19d3a3705481fd11857a3ead91ecc48
U dan
-Z 2159618824032fadaab0aea7ee6653b7
+Z 1e078a1016374413dd52c84153eab75d
#
#***********************************************************************
#
-# $Id: analyze.test,v 1.9 2008/08/11 18:44:58 drh Exp $
+# This file implements regression tests for SQLite library. This file
+# implements tests for the extra functionality provided by the ANALYZE
+# command when the library is compiled with SQLITE_ENABLE_STAT2 defined.
+#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
#
# analyze2-6.*: Check that the library behaves correctly when one of the
# sqlite_stat2 or sqlite_stat1 tables are missing.
+#
+# analyze2-7.*: Check that in a shared-schema situation, nothing goes
+# wrong if sqlite_stat2 data is read by one connection,
+# and freed by another.
#
-proc eqp {sql} {
- uplevel execsql [list "EXPLAIN QUERY PLAN $sql"]
+proc eqp {sql {db db}} {
+ uplevel execsql [list "EXPLAIN QUERY PLAN $sql"] $db
}
do_test analyze2-1.1 {
}
} {0 1 {TABLE t6 WITH INDEX t6i} 1 0 {TABLE t5 USING PRIMARY KEY}}
+#--------------------------------------------------------------------
+# These tests, analyze2-7.*, test that the sqlite_stat2 functionality
+# works in shared-cache mode. Note that these tests reuse the database
+# created for the analyze2-6.* tests.
+#
+ifcapable shared_cache {
+ db close
+ set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+ proc incr_schema_cookie {zDb} {
+ foreach iOffset {24 40} {
+ set cookie [hexio_get_int [hexio_read $zDb $iOffset 4]]
+ incr cookie
+ hexio_write $zDb $iOffset [hexio_render_int32 $cookie]
+ }
+ }
+
+ do_test analyze2-7.1 {
+ sqlite3 db1 test.db
+ sqlite3 db2 test.db
+ db1 cache size 0
+ db2 cache size 0
+ execsql { SELECT count(*) FROM t5 } db1
+ } {20}
+ do_test analyze2-7.2 {
+ incr_schema_cookie test.db
+ execsql { SELECT count(*) FROM t5 } db2
+ } {20}
+ do_test analyze2-7.3 {
+ incr_schema_cookie test.db
+ execsql { SELECT count(*) FROM t5 } db1
+ } {20}
+ do_test analyze2-7.4 {
+ incr_schema_cookie test.db
+ execsql { SELECT count(*) FROM t5 } db2
+ } {20}
+
+ do_test analyze2-7.5 {
+ eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND
+ t5.a>1 AND t5.a<15 AND
+ t6.a>1
+ } db1
+ } {0 1 {TABLE t6 WITH INDEX t6i} 1 0 {TABLE t5 USING PRIMARY KEY}}
+ do_test analyze2-7.6 {
+ incr_schema_cookie test.db
+ execsql { SELECT * FROM sqlite_master } db2
+ eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND
+ t5.a>1 AND t5.a<15 AND
+ t6.a>1
+ } db2
+ } {0 1 {TABLE t6 WITH INDEX t6i} 1 0 {TABLE t5 USING PRIMARY KEY}}
+ do_test analyze2-7.7 {
+ incr_schema_cookie test.db
+ execsql { SELECT * FROM sqlite_master } db1
+ eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND
+ t5.a>1 AND t5.a<15 AND
+ t6.a>1
+ } db1
+ } {0 1 {TABLE t6 WITH INDEX t6i} 1 0 {TABLE t5 USING PRIMARY KEY}}
+
+ do_test analyze2-7.8 {
+ execsql { DELETE FROM sqlite_stat2 } db2
+ execsql { SELECT * FROM sqlite_master } db1
+ eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND
+ t5.a>1 AND t5.a<15 AND
+ t6.a>1
+ } db1
+ } {0 1 {TABLE t6 WITH INDEX t6i} 1 0 {TABLE t5 USING PRIMARY KEY}}
+ do_test analyze2-7.9 {
+ execsql { SELECT * FROM sqlite_master } db2
+ eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND
+ t5.a>1 AND t5.a<15 AND
+ t6.a>1
+ } db2
+ } {0 1 {TABLE t6 WITH INDEX t6i} 1 0 {TABLE t5 USING PRIMARY KEY}}
+
+ do_test analyze2-7.10 {
+ incr_schema_cookie test.db
+ execsql { SELECT * FROM sqlite_master } db1
+ eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND
+ t5.a>1 AND t5.a<15 AND
+ t6.a>1
+ } db1
+ } {0 0 {TABLE t5 WITH INDEX t5i} 1 1 {TABLE t6 USING PRIMARY KEY}}
+
+ db1 close
+ db2 close
+ sqlite3_enable_shared_cache $::enable_shared_cache
+}
+
finish_test