From 8c23864c1720e5aea4903e299a2f9c948f47c84e Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 2 May 2008 14:08:56 +0000 Subject: [PATCH] Add a test case for ticket #3093. (CVS 5077) FossilOrigin-Name: 288a7655c9a876abf53d92dc6599a9305399d562 --- manifest | 11 +++--- manifest.uuid | 2 +- test/tkt3093.test | 86 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 6 deletions(-) create mode 100644 test/tkt3093.test diff --git a/manifest b/manifest index 27d29fdcb6..de2d726ea4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sanother\stest\scase\sto\sverify\sthat\sticket\s#3092\shas\sbeen\sfixed.\s(CVS\s5076) -D 2008-05-02T02:00:54 +C Add\sa\s\stest\scase\sfor\sticket\s#3093.\s(CVS\s5077) +D 2008-05-02T14:08:56 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.in 25b3282a4ac39388632c2fb0e044ff494d490952 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -503,6 +503,7 @@ F test/tkt2920.test a8737380e4ae6424e00c0273dc12775704efbebf F test/tkt2927.test a473c09eafa83d95579fc2b976f2afc11571ce7e F test/tkt2942.test c5c87d179799ca6d1fbe83c815510b87cd5ec7ce F test/tkt3080.test 31a02e87a4c80ed443831c2c5b0e8216ff95ac14 +F test/tkt3093.test 433851feaef6bacb95700355c4811344ef6b851e F test/trace.test 951cd0f5f571e7f36bf7bfe04be70f90fb16fb00 F test/trans.test 2fd24cd7aa0b879d49a224cbd647d698f1e7ac5c F test/trigger1.test 7c13f39ca36f529bf856e05c7d004fc0531d48b4 @@ -633,7 +634,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P 70e708660fec0b6f6c41efc2e29f1d7ae6785b7e -R 714aac9f8d3137c40cb007c56fa21ea2 +P 1906d2dadcd70053f55e2133af9f838e2d828fa7 +R 753b7a8a009f233c8697dfefcc46a9a8 U drh -Z b9b04ac723ad1b47b83155a71bbe6504 +Z 13a2787d3df0d75d1a6ce4dedc8ab3e0 diff --git a/manifest.uuid b/manifest.uuid index a6cccfb22a..cc33a105d4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1906d2dadcd70053f55e2133af9f838e2d828fa7 \ No newline at end of file +288a7655c9a876abf53d92dc6599a9305399d562 \ No newline at end of file diff --git a/test/tkt3093.test b/test/tkt3093.test new file mode 100644 index 0000000000..5f99937c46 --- /dev/null +++ b/test/tkt3093.test @@ -0,0 +1,86 @@ +# 2008 May 2 +# +# 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. +# +#*********************************************************************** +# +# Ticket #3093 +# +# Verify that a busy callback waiting on a reserved lock resolves +# once the lock clears. +# +# $Id: tkt3093.test,v 1.1 2008/05/02 14:08:56 drh Exp $ +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# Set up a test database +# +do_test tkt3093.1 { + db eval { + CREATE TABLE t1(x); + INSERT INTO t1 VALUES(1); + SELECT * FROM t1 + } +} {1} + +# Establish a separate, independent connection to that database. +# +do_test tkt3093.2 { + catch {sqlite3_enable_shared_cache 0} + sqlite3 db2 test.db + db2 eval { + SELECT * FROM t1 + } +} {1} + +# Make sure that clearing a lock allows a pending request for +# a reserved lock to continue. +# +do_test tkt3093.3 { + # This will be the busy callback for connection db2. On the first + # busy callback, commit the transaction in db. This should clear + # the lock so that there should not be a second callback. If the + # busy handler is called a second time, then fail so that we get + # timeout. + proc busy_callback {cnt} { + if {$cnt==0} { + db eval COMMIT + return 0 + } else { + return 1 + } + } + db2 busy ::busy_callback + + # Start a write transaction on db. + db eval { + BEGIN; + INSERT INTO t1 VALUES(2); + } + + # Attempt to modify the database on db2 + catchsql { + UPDATE t1 SET x=x+1; + } db2 +} {0 {}} + +# Verify that everything worked as expected. The db transaction should +# have gone first and added entry 2. Then the db2 transaction would have +# run and added one to each entry. +# +do_test tkt3093.4 { + db eval {SELECT * FROM t1} +} {2 3} +do_test tkt3093.5 { + db2 eval {SELECT * FROM t1} +} {2 3} +db2 close + +finish_test