-C Fix\ssome\sproblems\swith\smulti-file\stransaction\srollback.\s(CVS\s1751)
-D 2004-06-28T04:52:30
+C Add\sa\ssimple\stest\scase\sfor\sinter-process\slocking.\s(CVS\s1752)
+D 2004-06-28T08:25:48
F Makefile.in cb7a9889c38723f72b2506c4236ff30a05ff172b
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
F src/os_mac.h 51d2445f47e182ed32d3bd6937f81070c6fd9bd4
F src/os_test.c ef353f73a2ad85a239d7a77c4a5df2e1377f3848
F src/os_test.h 6a26a4978492e4bbdbf385554958418ff02db162
-F src/os_unix.c bd62e20d3abfb96c41fe737715b328d1dbb52bf7
+F src/os_unix.c 295d0d4fe8a3f531ae39623e2c8766b1823c0acd
F src/os_unix.h 00c1f82b526ab2fb7ee5ddd555ea4ed68363c93a
F src/os_win.c 84549f6cc815237533c5d0eb3697352b03478d96
F src/os_win.h babd4e912967c6b09088cfe38a45e8005a07ba44
F test/laststmtchanges.test 417aa27eb2b5cdfafb46e390e2c9ddd0a20eba43
F test/limit.test 60d7f856ee7846f7130dee67f10f0e726cd70b5d
F test/lock.test 1dbf1d06b0a7eb36237b4f107cfb3da9726b449e
+F test/lock2.test 321066db9e0dfa22968ece2ea9b03e7ffbdd4d94
F test/main.test e8c4d9ca6d1e5f5e55e6550d31aec488883b2ed9
F test/malloc.test a78617ce8258388e4835f4834a3a2c0d4282a7ec
F test/memdb.test b8a13fa79f006bd087bbcf135ce8eb62056a6027
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/version3.tcl 563ba3ac02f64da27ab17f3edbe8e56bfd0293fb
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P 81e4994045697470bcfd692a794731c8291a8a30
-R 720c8ecc08d420175dd5d527a0298db7
+P 06e8e30b249c10512a225d6c7a5fcb5c666595e6
+R d120c4842e7f311a12d71241eb9f9f18
U danielk1977
-Z 4b192e4a8c202247fb9d2a51a2cec3ca
+Z a2a960a2ceb55201658e7b059b0a9a2b
--- /dev/null
+# 2001 September 15
+#
+# 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. The
+# focus of this script is database locks between competing processes.
+#
+# $Id: lock2.test,v 1.1 2004/06/28 08:25:48 danielk1977 Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Launch another testfixture process to be controlled by this one. A
+# channel name is returned that may be passed as the first argument to proc
+# 'testfixture' to execute a command. The child testfixture process is shut
+# down by closing the channel.
+proc launch_testfixture {} {
+ set chan [open "|[file join . testfixture] tf_main.tcl" r+]
+ fconfigure $chan -buffering line
+ return $chan
+}
+
+# Execute a command in a child testfixture process, connected by two-way
+# channel $chan. Return the result of the command, or an error message.
+proc testfixture {chan cmd} {
+ puts $chan $cmd
+ puts $chan OVER
+ set r ""
+ while { 1 } {
+ set line [gets $chan]
+ if { $line == "OVER" } {
+ return $r
+ }
+ append r $line
+ }
+}
+
+# Write the main loop for the child testfixture processes into file
+# tf_main.tcl. The parent (this script) interacts with the child processes
+# via a two way pipe. The parent writes a script to the stdin of the child
+# process, followed by the word "OVER" on a line of it's own. The child
+# process evaluates the script and writes the results to stdout, followed
+# by an "OVER" of its own.
+set f [open tf_main.tcl w]
+puts $f {
+ set l [open log w]
+ set script ""
+ while {![eof stdin]} {
+ flush stdout
+ set line [gets stdin]
+ puts $l "READ $line"
+ if { $line == "OVER" } {
+ catch {eval $script} result
+ puts $result
+ puts $l "WRITE $result"
+ puts OVER
+ puts $l "WRITE OVER"
+ flush stdout
+ set script ""
+ } else {
+ append script $line
+ append script " ; "
+ }
+ }
+ close $l
+}
+close $f
+
+# Simple locking test case:
+#
+# lock2-1.1: Connect a second process to the database.
+# lock2-1.2: Establish a RESERVED lock with this process.
+# lock2-1.3: Get a SHARED lock with the second process.
+# lock2-1.4: Try for a RESERVED lock with process 2. This fails.
+# lock2-1.5: Try to upgrade the first process to EXCLUSIVE, this fails so
+# it gets PENDING.
+# lock2-1.6: Release the SHARED lock held by the second process.
+# lock2-1.7: Attempt to reaquire a SHARED lock with the second process.
+# this fails due to the PENDING lock.
+# lock2-1.8: Ensure the first process can now upgrade to EXCLUSIVE.
+#
+do_test lock2-1.1 {
+ set ::tf1 [launch_testfixture]
+ testfixture $::tf1 {
+ sqlite3 db test.db
+ db eval {select * from sqlite_master}
+ }
+} {}
+do_test lock2-1.2 {
+ execsql {
+ BEGIN;
+ CREATE TABLE abc(a, b, c);
+ }
+} {}
+do_test lock2-1.3 {
+ testfixture $::tf1 {
+ db eval {
+ BEGIN;
+ SELECT * FROM sqlite_master;
+ }
+ }
+} {}
+do_test lock2-1.4 {
+ testfixture $::tf1 {
+ db eval {
+ CREATE TABLE def(d, e, f)
+ }
+ }
+} {database is locked}
+do_test lock2-1.5 {
+ catchsql {
+ COMMIT;
+ }
+} {1 {database is locked}}
+do_test lock2-1.6 {
+ testfixture $::tf1 {
+ db eval {
+ SELECT * FROM sqlite_master;
+ COMMIT;
+ }
+ }
+} {}
+do_test lock2-1.7 {
+ testfixture $::tf1 {
+ db eval {
+ BEGIN;
+ SELECT * FROM sqlite_master;
+ }
+ }
+} {database is locked}
+do_test lock2-1.8 {
+ catchsql {
+ COMMIT;
+ }
+} {0 {}}
+do_test lock2-1.9 {
+ execsql {
+ SELECT * FROM sqlite_master;
+ }
+} {table abc abc 2 {CREATE TABLE abc(a, b, c)}}
+do_test lock2-1.10 {
+ testfixture $::tf1 {
+ db eval {
+ SELECT * FROM sqlite_master;
+ }
+ }
+} {table abc abc 2 {CREATE TABLE abc(a, b, c)}}
+
+finish_test
+