diff options
author | dan miller | 2007-10-20 02:49:29 +0000 |
---|---|---|
committer | dan miller | 2007-10-20 02:49:29 +0000 |
commit | e36d23a85ebff914d74bb541558c2b6082b78edb (patch) | |
tree | 54b58fdf162e78af64055282a6035c8d2443389d /libraries/sqlite/unix/sqlite-3.5.1/test/lock4.test | |
parent | * Fixed an issue whereby avatar chat distances were being calculated against ... (diff) | |
download | opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.zip opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.gz opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.bz2 opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.xz |
sqlite source (unix build) added to libraries
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/test/lock4.test')
-rw-r--r-- | libraries/sqlite/unix/sqlite-3.5.1/test/lock4.test | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/test/lock4.test b/libraries/sqlite/unix/sqlite-3.5.1/test/lock4.test new file mode 100644 index 0000000..3820476 --- /dev/null +++ b/libraries/sqlite/unix/sqlite-3.5.1/test/lock4.test | |||
@@ -0,0 +1,99 @@ | |||
1 | # 2007 April 6 | ||
2 | # | ||
3 | # The author disclaims copyright to this source code. In place of | ||
4 | # a legal notice, here is a blessing: | ||
5 | # | ||
6 | # May you do good and not evil. | ||
7 | # May you find forgiveness for yourself and forgive others. | ||
8 | # May you share freely, never taking more than you give. | ||
9 | # | ||
10 | #*********************************************************************** | ||
11 | # This file implements regression tests for SQLite library. The | ||
12 | # focus of this script is database locks. | ||
13 | # | ||
14 | # $Id: lock4.test,v 1.6 2007/09/06 23:28:25 drh Exp $ | ||
15 | |||
16 | |||
17 | set testdir [file dirname $argv0] | ||
18 | source $testdir/tester.tcl | ||
19 | |||
20 | # Initialize the test.db database so that it is non-empty | ||
21 | # | ||
22 | do_test lock4-1.1 { | ||
23 | db eval { | ||
24 | PRAGMA auto_vacuum=OFF; | ||
25 | CREATE TABLE t1(x); | ||
26 | } | ||
27 | file delete -force test2.db test2.db-journal | ||
28 | sqlite3 db2 test2.db | ||
29 | db2 eval { | ||
30 | PRAGMA auto_vacuum=OFF; | ||
31 | CREATE TABLE t2(x) | ||
32 | } | ||
33 | db2 close | ||
34 | list [file size test.db] [file size test2.db] | ||
35 | } {2048 2048} | ||
36 | |||
37 | # Create a script to drive a separate process that will | ||
38 | # | ||
39 | # 1. Create a second database test2.db | ||
40 | # 2. Get an exclusive lock on test2.db | ||
41 | # 3. Add an entry to test.db in table t1, waiting as necessary. | ||
42 | # 4. Commit the change to test2.db. | ||
43 | # | ||
44 | # Meanwhile, this process will: | ||
45 | # | ||
46 | # A. Get an exclusive lock on test.db | ||
47 | # B. Attempt to read from test2.db but get an SQLITE_BUSY error. | ||
48 | # C. Commit the changes to test.db thus alloing the other process | ||
49 | # to continue. | ||
50 | # | ||
51 | do_test lock4-1.2 { | ||
52 | set out [open test2-script.tcl w] | ||
53 | puts $out "set sqlite_pending_byte [set sqlite_pending_byte]" | ||
54 | puts $out { | ||
55 | sqlite3 db2 test2.db | ||
56 | db2 eval { | ||
57 | BEGIN; | ||
58 | INSERT INTO t2 VALUES(2); | ||
59 | } | ||
60 | sqlite3 db test.db | ||
61 | db timeout 1000000 | ||
62 | db eval { | ||
63 | INSERT INTO t1 VALUES(2); | ||
64 | } | ||
65 | db2 eval COMMIT | ||
66 | exit | ||
67 | } | ||
68 | close $out | ||
69 | db eval { | ||
70 | BEGIN; | ||
71 | INSERT INTO t1 VALUES(1); | ||
72 | } | ||
73 | exec [info nameofexec] ./test2-script.tcl & | ||
74 | while {![file exists test2.db-journal]} { | ||
75 | after 10 | ||
76 | } | ||
77 | sqlite3 db2 test2.db | ||
78 | catchsql { | ||
79 | INSERT INTO t2 VALUES(1) | ||
80 | } db2 | ||
81 | } {1 {database is locked}} | ||
82 | do_test lock4-1.3 { | ||
83 | db eval { | ||
84 | COMMIT; | ||
85 | } | ||
86 | while {[file exists test2.db-journal]} { | ||
87 | after 10 | ||
88 | } | ||
89 | db2 eval { | ||
90 | SELECT * FROM t2 | ||
91 | } | ||
92 | } {2} | ||
93 | |||
94 | |||
95 | do_test lock4-999.1 { | ||
96 | rename db2 {} | ||
97 | } {} | ||
98 | |||
99 | finish_test | ||