1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Fix a problem causing the BtShared.isPending flag to be cleared to early. Also coverage improvements for btree.c. (CVS 6440)

FossilOrigin-Name: 8f1423445b29a5f52ed907de6db82128a96ebfe2
This commit is contained in:
danielk1977
2009-04-02 18:28:08 +00:00
parent e1fb65a0b8
commit fa542f1fc8
5 changed files with 152 additions and 18 deletions

View File

@ -9,7 +9,7 @@
#
#***********************************************************************
#
# $Id: shared6.test,v 1.2 2009/04/01 18:25:54 danielk1977 Exp $
# $Id: shared6.test,v 1.3 2009/04/02 18:28:08 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -21,6 +21,7 @@ do_test shared6-1.1.1 {
CREATE TABLE t2(c, d);
CREATE TABLE t3(e, f);
}
db close
} {}
do_test shared6-1.1.2 {
set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
@ -133,9 +134,11 @@ do_test shared6-1.X {
db2 close
} {}
#-------------------------------------------------------------------------
# The following tests - shared6-2.* - test that two database connections
# that connect to the same file using different VFS implementations do
# not share a cache.
#
if {$::tcl_platform(platform) eq "unix"} {
do_test shared6-2.1 {
sqlite3 db1 test.db -vfs unix
@ -174,6 +177,80 @@ if {$::tcl_platform(platform) eq "unix"} {
} {}
}
#-------------------------------------------------------------------------
# Test that it is possible to open an exclusive transaction while
# already holding a read-lock on the database file. And that it is
# not possible if some other connection holds such a lock.
#
do_test shared6-3.1 {
sqlite3 db1 test.db
sqlite3 db2 test.db
sqlite3 db3 test.db
} {}
db1 eval {SELECT * FROM t1} {
# Within this block [db1] is holding a read-lock on t1. Test that
# this means t1 cannot be written by [db2].
#
do_test shared6-3.2 {
catchsql { INSERT INTO t1 VALUES(1, 2) } db2
} {1 {database table is locked: t1}}
do_test shared6-3.3 {
execsql { BEGIN EXCLUSIVE } db1
} {}
break
}
do_test shared6-3.4 {
catchsql { SELECT * FROM t1 } db2
} {1 {database schema is locked: main}}
do_test shared6-3.5 {
execsql COMMIT db1
} {}
db2 eval {SELECT * FROM t1} {
do_test shared6-3.6 {
catchsql { BEGIN EXCLUSIVE } db1
} {1 {database table is locked}}
break
}
do_test shared6-3.7 {
execsql { BEGIN } db1
execsql { BEGIN } db2
} {}
db2 eval {SELECT * FROM t1} {
do_test shared6-3.8 {
catchsql { INSERT INTO t1 VALUES(1, 2) } db1
} {1 {database table is locked: t1}}
break
}
do_test shared6-3.9 {
execsql { BEGIN ; ROLLBACK } db3
} {}
do_test shared6-3.10 {
catchsql { SELECT * FROM t1 } db3
} {1 {database table is locked}}
do_test shared6-3.X {
db1 close
db2 close
db3 close
} {}
do_test shared6-4.1 {
#file delete -force test.db test.db-journal
sqlite3 db1 test.db
sqlite3 db2 test.db
set ::STMT [sqlite3_prepare_v2 db1 "SELECT * FROM t1" -1 DUMMY]
execsql { CREATE TABLE t5(a, b) } db2
} {}
do_test shared6-4.2 {
sqlite3_finalize $::STMT
} {SQLITE_OK}
do_test shared6-4.X {
db1 close
db2 close
} {}
sqlite3_enable_shared_cache $::enable_shared_cache
finish_test