Add further test cases for the logic in sqlite3WalBeginReadTransaction().
FossilOrigin-Name: a49713db39d0d6940b368206d4e669aa69aa1fe5
This commit is contained in:
+73
-2
@@ -420,8 +420,8 @@ T delete
|
||||
#-------------------------------------------------------------------------
|
||||
# When opening a read-transaction on a database, if the entire log has
|
||||
# already been copied to the database file, the reader grabs a special
|
||||
# kind of read lock (on aReadMark[0]). This test case tests the outcome
|
||||
# of the following:
|
||||
# kind of read lock (on aReadMark[0]). This set of test cases tests the
|
||||
# outcome of the following:
|
||||
#
|
||||
# + The reader discovering that between the time when it determined
|
||||
# that the log had been completely backfilled and the lock is obtained
|
||||
@@ -563,6 +563,77 @@ db2 close
|
||||
db close
|
||||
T delete
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# When opening a read-transaction on a database, if the entire log has
|
||||
# not yet been copied to the database file, the reader grabs a read
|
||||
# lock on aReadMark[x], where x>0. The following test cases experiment
|
||||
# with the outcome of the following:
|
||||
#
|
||||
# + The reader discovering that between the time when it read the
|
||||
# wal-index header and the lock was obtained that a writer has
|
||||
# written to the log. In this case the reader should re-read the
|
||||
# wal-index header and lock a snapshot corresponding to the new
|
||||
# header.
|
||||
#
|
||||
# + The value in the aReadMark[x] slot has been modified since it was
|
||||
# read.
|
||||
#
|
||||
catch {db close}
|
||||
testvfs T -default 1
|
||||
do_test wal3-7.1.1 {
|
||||
file delete -force test.db test.db-journal test.db wal
|
||||
sqlite3 db test.db
|
||||
execsql {
|
||||
PRAGMA journal_mode = WAL;
|
||||
CREATE TABLE blue(red PRIMARY KEY, green);
|
||||
}
|
||||
} {wal}
|
||||
|
||||
T script method_callback
|
||||
T filter xOpen
|
||||
proc method_callback {method args} {
|
||||
if {$method == "xOpen"} { return "reader" }
|
||||
}
|
||||
do_test wal3-7.1.2 {
|
||||
sqlite3 db2 test.db
|
||||
execsql { SELECT * FROM blue } db2
|
||||
} {}
|
||||
|
||||
T filter xShmLock
|
||||
set ::locks [list]
|
||||
proc method_callback {method file handle spec} {
|
||||
if {$handle != "reader" } { return }
|
||||
if {$method == "xShmLock"} {
|
||||
catch { execsql { INSERT INTO blue VALUES(1, 2) } }
|
||||
catch { execsql { INSERT INTO blue VALUES(3, 4) } }
|
||||
}
|
||||
lappend ::locks $spec
|
||||
}
|
||||
do_test wal3-7.1.3 {
|
||||
execsql { SELECT * FROM blue } db2
|
||||
} {1 2 3 4}
|
||||
do_test wal3-7.1.4 {
|
||||
set ::locks
|
||||
} {{4 1 lock shared} {4 1 unlock shared} {5 1 lock shared} {5 1 unlock shared}}
|
||||
|
||||
set ::locks [list]
|
||||
proc method_callback {method file handle spec} {
|
||||
if {$handle != "reader" } { return }
|
||||
if {$method == "xShmLock"} {
|
||||
catch { execsql { INSERT INTO blue VALUES(5, 6) } }
|
||||
}
|
||||
lappend ::locks $spec
|
||||
}
|
||||
do_test wal3-7.2.1 {
|
||||
execsql { SELECT * FROM blue } db2
|
||||
} {1 2 3 4 5 6}
|
||||
do_test wal3-7.2.2 {
|
||||
set ::locks
|
||||
} {{5 1 lock shared} {5 1 unlock shared} {4 1 lock shared} {4 1 unlock shared}}
|
||||
|
||||
db close
|
||||
db2 close
|
||||
T delete
|
||||
|
||||
finish_test
|
||||
|
||||
|
||||
Reference in New Issue
Block a user