-C Clarify\sthe\spurpose\sof\sa\stest\sfor\sa\srace-condition\sin\swalIndexReadHdr().
-D 2010-06-05T18:34:26
+C Add\sfurther\stest\scases\sfor\sthe\slogic\sin\ssqlite3WalBeginReadTransaction().
+D 2010-06-05T19:18:59
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F src/vdbemem.c 2a82f455f6ca6f78b59fb312f96054c04ae0ead1
F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2
F src/vtab.c a0f8a40274e4261696ef57aa806de2776ab72cda
-F src/wal.c a97ac7ee623fd92140bb0b37bc210b9cccb283f5
+F src/wal.c d1a6aa3f29c7f4e7ab474264978b7c1030363cb9
F src/wal.h 4ace25262452d17e7d3ec970c89ee17794004008
F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
F src/where.c 75fee9e255b62f773fcadd1d1f25b6f63ac7a356
F test/vtab_shared.test 0eff9ce4f19facbe0a3e693f6c14b80711a4222d
F test/wal.test bfec61450b47cdf09f7d2269f9e9967683b8b0fc
F test/wal2.test 743d9b86041e57ba986dd7e3891c67725f9e2b2b
-F test/wal3.test 1c5e9535e0e307f837e059ec45842e7101796a96
+F test/wal3.test b82ac8268bac644d1d928d25316e5e7696ec47bf
F test/wal_common.tcl 3e953ae60919281688ea73e4d0aa0e1bc94becd9
F test/walbak.test e7650a26eb4b8abeca9b145b1af1e63026dde432
F test/walcksum.test 4efa8fb88c32bed8288ea4385a9cc113a5c8f0bf
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 394204735a842b04b677cca20485b1578e475d4c
-R 27fd1a32d66f249d5fa488d9e53b7946
+P c041c6a9786bc9ebb82527f7a2c96d255aec927f
+R b34f0ea46ed4ddc81ab394ae4b47f8c2
U dan
-Z ac39f481b39b4a8a76aecf6dead9965f
+Z b9b05ea832538d97e39aa0947439a601
-c041c6a9786bc9ebb82527f7a2c96d255aec927f
\ No newline at end of file
+a49713db39d0d6940b368206d4e669aa69aa1fe5
\ No newline at end of file
rc = walLockShared(pWal, WAL_READ_LOCK(0));
sqlite3OsShmBarrier(pWal->pDbFd);
if( rc==SQLITE_OK ){
- if( memcmp(pHdr, &pWal->hdr, sizeof(WalIndexHdr)) ){
+ if( memcmp((void *)pHdr, &pWal->hdr, sizeof(WalIndexHdr)) ){
/* It is not safe to allow the reader to continue here if frames
** may have been appended to the log before READ_LOCK(0) was obtained.
** When holding READ_LOCK(0), the reader ignores the entire log file,
** pWal->hdr.mxFrame risks reading a corrupted snapshot. So, retry
** instead.
**
- ** This does not guarantee that the copy wal-index header is up to
- ** date before proceeding. This would not be possible without somehow
- ** blocking writers. It only guarantees that a damaging checkpoint or
+ ** This does not guarantee that the copy of the wal-index header is up to
+ ** date before proceeding. That would not be possible without somehow
+ ** blocking writers. It only guarantees that a dangerous checkpoint or
** log-wrap (either of which would require an exclusive lock on
** WAL_READ_LOCK(mxI)) has not occurred since the snapshot was valid.
*/
sqlite3OsShmBarrier(pWal->pDbFd);
if( pInfo->aReadMark[mxI]!=mxReadMark
- || memcmp(pHdr, &pWal->hdr, sizeof(WalIndexHdr))
+ || memcmp((void *)pHdr, &pWal->hdr, sizeof(WalIndexHdr))
){
walUnlockShared(pWal, WAL_READ_LOCK(mxI));
return WAL_RETRY;
#-------------------------------------------------------------------------
# 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
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