-C Add\scomments\sdescribing\sUNKNOWN_LOCK\sto\spager.c.\sImprove\ssome\sother\scomments\si\sthe\ssame\sfile.
-D 2010-08-05T18:53:27
+C Fix\sa\sbug\sto\sdo\swith\sdeleting\sthe\sjournal\sfile\swhen\sexiting\sexclusive-locking\smode.
+D 2010-08-06T06:54:48
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/os_os2.c 72d0b2e562952a2464308c4ce5f7913ac10bef3e
F src/os_unix.c ae5ca8a6031380708f3fec7be325233d49944914
F src/os_win.c 51cb62f76262d961ea4249489383d714501315a7
-F src/pager.c 07bda904e5b3e6fe6c9425a205fcaf1dca5a444c
+F src/pager.c f8fdab85e2dd0a3a55fc2bf212035f50ffcada13
F src/pager.h 80726162dc3942f59ab27b738fb667b9ba0a89d5
F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58
F src/pcache.c 1e9aa2dbc0845b52e1b51cc39753b6d1e041cb07
F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec
F test/pager1.test d8e4b2bc8164c920e6ea0572c9e13576d6e4f3fa
F test/pager2.test f5c757c271ce642d36a393ecbfb3aef1c240dcef
+F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f
F test/pagerfault.test c1d176326ce244db157ce9c3ba128be2a9b172d6
F test/pagerfault2.test 1f79ea40d1133b2683a2f811b00f2399f7ec2401
F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P acd26b8b746980c344db017a0e96dbd92c89acdf
-R c079a70d95550574b0e39982e236e749
+P 54eff6de9d8d87f33192c192ca91907c4c090988
+R d766f7dfb5a440ae684ea90a650f2fcb
U dan
-Z 83b26f553c42e8e1edd2dad0b7de50dd
+Z d043fca41f68ab4a258746c2916bd634
** | V |
** +<------WRITER_FINISHED-------->+
**
+**
+** List of state transitions and the C [function] that performs each:
+**
+** NONE -> READER [sqlite3PagerSharedLock]
+** READER -> NONE [pager_unlock]
+**
+** READER -> WRITER_INITIAL [sqlite3PagerBegin]
+** WRITER_INITIAL -> WRITER_CACHEMOD [pager_open_journal]
+** WRITER_CACHEMOD -> WRITER_DBMOD [syncJournal]
+** WRITER_DBMOD -> WRITER_FINISHED [sqlite3PagerCommitPhaseOne]
+** WRITER_*** -> READER [pager_end_transaction]
+**
+** WRITER_*** -> ERROR [pager_error]
+** ERROR -> NONE [pager_unlock]
+**
+**
** NONE:
**
** The pager starts up in this state. Nothing is guaranteed in this
** this state even after the read-transaction is closed. The only way
** a locking_mode=exclusive connection can transition from READER to NONE
** is via the ERROR state (see below).
+**
+** TODO: Maybe WAL connections should behave like locking_mode=exclusive
+** connections and remain in READER state even when there is no
+** active read transaction.
**
** * A read transaction may be active (but a write-transaction cannot).
** * A SHARED or greater lock is held on the database file.
**
** WRITER_INITIAL:
**
+** The pager moves to this state from READER when a write-transaction
+** is first opened on the database.
+**
** * A write transaction is active.
-** * A RESERVED or greater lock is held on the database file.
+** * If the connection is open in rollback-mode, a RESERVED or greater
+** lock is held on the database file.
+** * If the connection is open in WAL-mode, a WAL write transaction
+** is open (i.e. sqlite3WalBeginWriteTransaction() has been successfully
+** called).
** * The dbSize, dbOrigSize and dbFileSize variables are all valid.
** * The contents of the pager cache have not been modified.
** * The journal file may or may not be open.
** state.
**
**
-** State transitions and the [function] that performs each:
-**
-** NONE -> READER [PagerSharedLock]
-** READER -> WRITER_INITIAL [PagerBegin]
-** WRITER_INITIAL -> WRITER_CACHEMOD [pager_open_journal]
-** WRITER_CACHEMOD -> WRITER_DBMOD [syncJournal]
-** WRITER_DBMOD -> WRITER_FINISHED [PagerCommitPhaseOne]
-**
-** WRITER_*** -> READER [pager_end_transaction]
-** WRITER_*** -> ERROR [pager_error]
-**
-** READER -> NONE [pager_unlock]
-** ERROR -> NONE [pager_unlock]
-**
** Notes:
**
** * A pager is never in WRITER_DBMOD or WRITER_FINISHED state if the
static char zRet[1024];
sqlite3_snprintf(1024, zRet,
+ "Filename: %s\n"
"State: %s errCode=%d\n"
"Lock: %s\n"
"Locking mode: locking_mode=%s\n"
"Journal mode: journal_mode=%s\n"
"Backing store: tempFile=%d memDb=%d useJournal=%d\n"
"Journal: journalOff=%lld journalHdr=%lld\n"
+ , p->zFilename
, p->eState==PAGER_NONE ? "NONE" :
p->eState==PAGER_READER ? "READER" :
p->eState==PAGER_WRITER_INITIAL ? "WRITER_INITIAL" :
** call to pager_unlock(), as described above.
*/
static void pagerUnlockAndRollback(Pager *pPager){
- if( pPager->eState!=PAGER_ERROR ){
+ if( pPager->eState!=PAGER_ERROR && pPager->eState!=PAGER_NONE ){
assert( assert_pager_state(pPager) );
if( pPager->eState>=PAGER_WRITER_INITIAL ){
sqlite3BeginBenignMalloc();
sqlite3PagerRollback(pPager);
sqlite3EndBenignMalloc();
}else if( pPager->eLock>=RESERVED_LOCK && !pPager->exclusiveMode ){
+ assert( pPager->eState==PAGER_READER );
pager_end_transaction(pPager, 0);
}
}
--- /dev/null
+# 2010 June 15
+#
+# 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.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+source $testdir/wal_common.tcl
+
+
+foreach {tn sql res j} {
+ 1 "PRAGMA journal_mode = DELETE" delete 0
+ 2 "CREATE TABLE t1(a, b)" {} 0
+ 3 "PRAGMA locking_mode=EXCLUSIVE" {exclusive} 0
+ 4 "INSERT INTO t1 VALUES(1, 2)" {} 1
+ 5 "PRAGMA locking_mode=NORMAL" {normal} 1
+ 6 "SELECT * FROM t1" {1 2} 0
+} {
+ do_execsql_test pager3-1.$tn.1 $sql $res
+ do_test pager3-1.$tn.2 { file exists test.db-journal } $j
+}
+
+
+finish_test