Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add some tests that use the sqlite_stat2 table in shared-cache mode. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
29cafcfdccf4c0a27746b9a82fa41916 |
User & Date: | dan 2009-08-19 15:34:59.000 |
Context
2009-08-19
| ||
16:21 | Merge 29cafcfdcc and a6f39181a7. (check-in: 740a93e89c user: dan tags: trunk) | |
15:34 | Add some tests that use the sqlite_stat2 table in shared-cache mode. (check-in: 29cafcfdcc user: dan tags: trunk) | |
14:42 | Merge with 709e16145e. (check-in: 6c8a0e2b37 user: dan tags: trunk) | |
Changes
Changes to test/analyze2.test.
1 2 3 4 5 6 7 8 9 10 11 | # 2009 August 06 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # | | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # 2009 August 06 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # # 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 ifcapable !stat2 { finish_test return |
︙ | ︙ | |||
40 41 42 43 44 45 46 | # # analyze2-5.*: Check that collation sequences are used as described above # even when the only available version of the collation # function require UTF-16 encoded arguments. # # analyze2-6.*: Check that the library behaves correctly when one of the # sqlite_stat2 or sqlite_stat1 tables are missing. | | > > > | > | | | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | # # analyze2-5.*: Check that collation sequences are used as described above # even when the only available version of the collation # function require UTF-16 encoded arguments. # # 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 {db db}} { uplevel execsql [list "EXPLAIN QUERY PLAN $sql"] $db } do_test analyze2-1.1 { execsql { CREATE TABLE t1(x PRIMARY KEY) } for {set i 0} {$i < 1000} {incr i} { execsql { INSERT INTO t1 VALUES($i) } } |
︙ | ︙ | |||
398 399 400 401 402 403 404 405 406 | sqlite3 db test.db execsql ANALYZE eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND t5.a>1 AND t5.a<15 AND t6.a>1 } } {0 1 {TABLE t6 WITH INDEX t6i} 1 0 {TABLE t5 USING PRIMARY KEY}} finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 | sqlite3 db test.db execsql ANALYZE eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND t5.a>1 AND t5.a<15 AND t6.a>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 |