| OLD | NEW |
| 1 # 2007 September 7 | 1 # 2007 September 7 |
| 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 #*********************************************************************** |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 ] { | 35 ] { |
| 36 # Empty the database. | 36 # Empty the database. |
| 37 # | 37 # |
| 38 catchsql { DROP TABLE ab; } | 38 catchsql { DROP TABLE ab; } |
| 39 | 39 |
| 40 do_test thread001.$tn.0 { | 40 do_test thread001.$tn.0 { |
| 41 db close | 41 db close |
| 42 sqlite3_enable_shared_cache $shared_cache | 42 sqlite3_enable_shared_cache $shared_cache |
| 43 sqlite3_enable_shared_cache $shared_cache | 43 sqlite3_enable_shared_cache $shared_cache |
| 44 } $shared_cache | 44 } $shared_cache |
| 45 sqlite3 db test.db -fullmutex 1 | 45 sqlite3 db test.db -fullmutex 1 -key xyzzy |
| 46 | 46 |
| 47 set dbconfig "" | 47 set dbconfig "" |
| 48 if {$same_db} { | 48 if {$same_db} { |
| 49 set dbconfig [list set ::DB [sqlite3_connection_pointer db]] | 49 set dbconfig [list set ::DB [sqlite3_connection_pointer db]] |
| 50 } | 50 } |
| 51 | 51 |
| 52 # Set up a database and a schema. The database contains a single | 52 # Set up a database and a schema. The database contains a single |
| 53 # table with two columns. The first column ("a") is an INTEGER PRIMARY | 53 # table with two columns. The first column ("a") is an INTEGER PRIMARY |
| 54 # KEY. The second contains the md5sum of all rows in the table with | 54 # KEY. The second contains the md5sum of all rows in the table with |
| 55 # a smaller value stored in column "a". | 55 # a smaller value stored in column "a". |
| (...skipping 14 matching lines...) Expand all Loading... |
| 70 } | 70 } |
| 71 } {1} | 71 } {1} |
| 72 do_test thread001.$tn.3 { | 72 do_test thread001.$tn.3 { |
| 73 execsql { PRAGMA integrity_check } | 73 execsql { PRAGMA integrity_check } |
| 74 } {ok} | 74 } {ok} |
| 75 | 75 |
| 76 set thread_program { | 76 set thread_program { |
| 77 #sqlthread parent {puts STARTING..} | 77 #sqlthread parent {puts STARTING..} |
| 78 set needToClose 0 | 78 set needToClose 0 |
| 79 if {![info exists ::DB]} { | 79 if {![info exists ::DB]} { |
| 80 set ::DB [sqlthread open test.db] | 80 set ::DB [sqlthread open test.db xyzzy] |
| 81 #sqlthread parent "puts \"OPEN $::DB\"" | 81 #sqlthread parent "puts \"OPEN $::DB\"" |
| 82 set needToClose 1 | 82 set needToClose 1 |
| 83 } | 83 } |
| 84 | 84 |
| 85 for {set i 0} {$i < 100} {incr i} { | 85 for {set i 0} {$i < 100} {incr i} { |
| 86 # Test that the invariant is true. | 86 # Test that the invariant is true. |
| 87 do_test t1 { | 87 do_test t1 { |
| 88 execsql { | 88 execsql { |
| 89 SELECT | 89 SELECT |
| 90 (SELECT md5sum(a, b) FROM ab WHERE a < (SELECT max(a) FROM ab)) == | 90 (SELECT md5sum(a, b) FROM ab WHERE +a < (SELECT max(a) FROM ab)) == |
| 91 (SELECT b FROM ab WHERE a = (SELECT max(a) FROM ab)) | 91 (SELECT b FROM ab WHERE a = (SELECT max(a) FROM ab)) |
| 92 } | 92 } |
| 93 } {1} | 93 } {1} |
| 94 | 94 |
| 95 # Add another row to the database. | 95 # Add another row to the database. |
| 96 execsql { INSERT INTO ab SELECT NULL, md5sum(a, b) FROM ab } | 96 execsql { INSERT INTO ab SELECT NULL, md5sum(a, b) FROM ab } |
| 97 } | 97 } |
| 98 | 98 |
| 99 if {$needToClose} { | 99 if {$needToClose} { |
| 100 #sqlthread parent "puts \"CLOSE $::DB\"" | 100 #sqlthread parent "puts \"CLOSE $::DB\"" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 124 } | 124 } |
| 125 | 125 |
| 126 # Check the database still looks Ok. | 126 # Check the database still looks Ok. |
| 127 # | 127 # |
| 128 do_test thread001.$tn.5 { | 128 do_test thread001.$tn.5 { |
| 129 execsql { SELECT count(*) FROM ab; } | 129 execsql { SELECT count(*) FROM ab; } |
| 130 } [expr {1 + $::NTHREAD*100}] | 130 } [expr {1 + $::NTHREAD*100}] |
| 131 do_test thread001.$tn.6 { | 131 do_test thread001.$tn.6 { |
| 132 execsql { | 132 execsql { |
| 133 SELECT | 133 SELECT |
| 134 (SELECT md5sum(a, b) FROM ab WHERE a < (SELECT max(a) FROM ab)) == | 134 (SELECT md5sum(a, b) FROM ab WHERE +a < (SELECT max(a) FROM ab)) == |
| 135 (SELECT b FROM ab WHERE a = (SELECT max(a) FROM ab)) | 135 (SELECT b FROM ab WHERE a = (SELECT max(a) FROM ab)) |
| 136 } | 136 } |
| 137 } {1} | 137 } {1} |
| 138 do_test thread001.$tn.7 { | 138 do_test thread001.$tn.7 { |
| 139 execsql { PRAGMA integrity_check } | 139 execsql { PRAGMA integrity_check } |
| 140 } {ok} | 140 } {ok} |
| 141 } | 141 } |
| 142 | 142 |
| 143 sqlite3_enable_shared_cache $::enable_shared_cache | 143 sqlite3_enable_shared_cache $::enable_shared_cache |
| 144 set sqlite_open_file_count 0 | 144 set sqlite_open_file_count 0 |
| 145 finish_test | 145 finish_test |
| OLD | NEW |