Annotation of embedaddon/sqlite3/test/tkt3093.test, revision 1.1
1.1 ! misho 1: # 2008 May 2
! 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: #
! 12: # Ticket #3093
! 13: #
! 14: # Verify that a busy callback waiting on a reserved lock resolves
! 15: # once the lock clears.
! 16: #
! 17: # $Id: tkt3093.test,v 1.2 2008/05/02 14:23:55 drh Exp $
! 18: #
! 19:
! 20: set testdir [file dirname $argv0]
! 21: source $testdir/tester.tcl
! 22:
! 23: # Set up a test database
! 24: #
! 25: do_test tkt3093.1 {
! 26: db eval {
! 27: CREATE TABLE t1(x);
! 28: INSERT INTO t1 VALUES(1);
! 29: SELECT * FROM t1
! 30: }
! 31: } {1}
! 32:
! 33: # Establish a separate, independent connection to that database.
! 34: #
! 35: do_test tkt3093.2 {
! 36: catch {sqlite3_enable_shared_cache 0}
! 37: sqlite3 db2 test.db
! 38: db2 eval {
! 39: SELECT * FROM t1
! 40: }
! 41: } {1}
! 42:
! 43: # Make sure that clearing a lock allows a pending request for
! 44: # a reserved lock to continue.
! 45: #
! 46: do_test tkt3093.3 {
! 47: # This will be the busy callback for connection db2. On the first
! 48: # busy callback, commit the transaction in db. This should clear
! 49: # the lock so that there should not be a second callback. If the
! 50: # busy handler is called a second time, then fail so that we get
! 51: # timeout.
! 52: proc busy_callback {cnt} {
! 53: if {$cnt==0} {
! 54: db eval COMMIT
! 55: return 0
! 56: } else {
! 57: return 1
! 58: }
! 59: }
! 60: db2 busy ::busy_callback
! 61:
! 62: # Start a write transaction on db.
! 63: db eval {
! 64: BEGIN;
! 65: INSERT INTO t1 VALUES(2);
! 66: }
! 67:
! 68: # Attempt to modify the database on db2
! 69: catchsql {
! 70: UPDATE t1 SET x=x+1;
! 71: } db2
! 72: } {0 {}}
! 73:
! 74: # Verify that everything worked as expected. The db transaction should
! 75: # have gone first and added entry 2. Then the db2 transaction would have
! 76: # run and added one to each entry.
! 77: #
! 78: do_test tkt3093.4 {
! 79: db eval {SELECT * FROM t1}
! 80: } {2 3}
! 81: do_test tkt3093.5 {
! 82: db2 eval {SELECT * FROM t1}
! 83: } {2 3}
! 84: db2 close
! 85:
! 86: finish_test
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>