| OLD | NEW |
| 1 # 2008 June 28 | 1 # 2008 June 28 |
| 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 #*********************************************************************** |
| 11 # This file implements regression tests for SQLite library. The | 11 # This file implements regression tests for SQLite library. The |
| 12 # focus of this script is database locks. | 12 # focus of this script is database locks. |
| 13 # | 13 # |
| 14 # $Id: lock5.test,v 1.6 2008/12/04 12:34:16 drh Exp $ | 14 # $Id: lock5.test,v 1.6 2008/12/04 12:34:16 drh Exp $ |
| 15 | 15 |
| 16 set testdir [file dirname $argv0] | 16 set testdir [file dirname $argv0] |
| 17 source $testdir/tester.tcl | 17 source $testdir/tester.tcl |
| 18 | 18 |
| 19 # This file is only run if using the unix backend compiled with the | 19 # This file is only run if using the unix backend compiled with the |
| 20 # SQLITE_ENABLE_LOCKING_STYLE macro. | 20 # SQLITE_ENABLE_LOCKING_STYLE macro. |
| 21 db close | 21 db close |
| 22 if {[catch {sqlite3 db test.db -vfs unix-none} msg]} { | 22 if {[catch {sqlite3 db test.db -vfs unix-none} msg]} { |
| 23 finish_test | 23 finish_test |
| 24 return | 24 return |
| 25 } | 25 } |
| 26 db close | 26 db close |
| 27 file delete -force test.db.lock | 27 forcedelete test.db.lock |
| 28 | 28 |
| 29 ifcapable lock_proxy_pragmas { | 29 ifcapable lock_proxy_pragmas { |
| 30 set ::using_proxy 0 | 30 set ::using_proxy 0 |
| 31 foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] { | 31 foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] { |
| 32 set ::using_proxy $value | 32 set ::using_proxy $value |
| 33 } | 33 } |
| 34 # Disable the proxy locking for these tests | 34 # Disable the proxy locking for these tests |
| 35 set env(SQLITE_FORCE_PROXY_LOCKING) "0" | 35 set env(SQLITE_FORCE_PROXY_LOCKING) "0" |
| 36 } | 36 } |
| 37 | 37 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 do_test lock5-dotfile.X { | 94 do_test lock5-dotfile.X { |
| 95 db2 close | 95 db2 close |
| 96 execsql {BEGIN EXCLUSIVE} | 96 execsql {BEGIN EXCLUSIVE} |
| 97 db close | 97 db close |
| 98 file exists test.db.lock | 98 file exists test.db.lock |
| 99 } {0} | 99 } {0} |
| 100 | 100 |
| 101 ##################################################################### | 101 ##################################################################### |
| 102 | 102 |
| 103 file delete -force test.db | 103 forcedelete test.db |
| 104 if {[catch {sqlite3 db test.db -vfs unix-flock} msg]} { | 104 if {[catch {sqlite3 db test.db -vfs unix-flock} msg]} { |
| 105 finish_test | 105 finish_test |
| 106 return | 106 return |
| 107 } | 107 } |
| 108 | 108 |
| 109 do_test lock5-flock.1 { | 109 do_test lock5-flock.1 { |
| 110 sqlite3 db test.db -vfs unix-flock | 110 sqlite3 db test.db -vfs unix-flock |
| 111 execsql { | 111 execsql { |
| 112 CREATE TABLE t1(a, b); | 112 CREATE TABLE t1(a, b); |
| 113 BEGIN; | 113 BEGIN; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 do_test lock5-flock.8 { | 148 do_test lock5-flock.8 { |
| 149 db2 close | 149 db2 close |
| 150 } {} | 150 } {} |
| 151 | 151 |
| 152 ##################################################################### | 152 ##################################################################### |
| 153 | 153 |
| 154 do_test lock5-none.1 { | 154 do_test lock5-none.1 { |
| 155 sqlite3 db test.db -vfs unix-none | 155 sqlite3 db test.db -vfs unix-none |
| 156 sqlite3 db2 test.db -vfs unix-none | 156 sqlite3 db2 test.db -vfs unix-none |
| 157 execsql { PRAGMA mmap_size = 0 } db2 |
| 157 execsql { | 158 execsql { |
| 158 BEGIN; | 159 BEGIN; |
| 159 INSERT INTO t1 VALUES(3, 4); | 160 INSERT INTO t1 VALUES(3, 4); |
| 160 } | 161 } |
| 161 } {} | 162 } {} |
| 162 do_test lock5-none.2 { | 163 do_test lock5-none.2 { |
| 163 execsql { SELECT * FROM t1 } | 164 execsql { SELECT * FROM t1 } |
| 164 } {1 2 3 4} | 165 } {1 2 3 4} |
| 165 do_test lock5-flock.3 { | 166 do_test lock5-none.3 { |
| 166 execsql { SELECT * FROM t1 } db2 | 167 execsql { SELECT * FROM t1; } db2 |
| 167 } {1 2} | 168 } {1 2} |
| 168 do_test lock5-none.4 { | 169 do_test lock5-none.4 { |
| 169 execsql { | 170 execsql { |
| 170 BEGIN; | 171 BEGIN; |
| 171 SELECT * FROM t1; | 172 SELECT * FROM t1; |
| 172 } db2 | 173 } db2 |
| 173 } {1 2} | 174 } {1 2} |
| 174 do_test lock5-none.5 { | 175 do_test lock5-none.5 { |
| 175 execsql COMMIT | 176 execsql COMMIT |
| 176 execsql {SELECT * FROM t1} db2 | 177 execsql {SELECT * FROM t1} db2 |
| 177 } {1 2} | 178 } {1 2} |
| 178 | 179 |
| 179 ifcapable memorymanage { | 180 ifcapable memorymanage { |
| 180 do_test lock5-none.6 { | 181 do_test lock5-none.6 { |
| 181 sqlite3_release_memory 1000000 | 182 sqlite3_release_memory 1000000 |
| 182 execsql {SELECT * FROM t1} db2 | 183 execsql {SELECT * FROM t1} db2 |
| 183 } {1 2 3 4} | 184 } {1 2 3 4} |
| 184 } | 185 } |
| 185 | 186 |
| 186 do_test lock5-flock.X { | 187 do_test lock5-none.X { |
| 187 db close | 188 db close |
| 188 db2 close | 189 db2 close |
| 189 } {} | 190 } {} |
| 190 | 191 |
| 191 ifcapable lock_proxy_pragmas { | 192 ifcapable lock_proxy_pragmas { |
| 192 set env(SQLITE_FORCE_PROXY_LOCKING) $::using_proxy | 193 set env(SQLITE_FORCE_PROXY_LOCKING) $::using_proxy |
| 193 } | 194 } |
| 194 | 195 |
| 195 finish_test | 196 finish_test |
| OLD | NEW |