mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-27 20:41:58 +03:00
Fix a bug to do with deleting the journal file when exiting exclusive-locking mode.
FossilOrigin-Name: 6217b607f0cd60383c6cb4ab0fe9da008f611244
This commit is contained in:
13
manifest
13
manifest
@ -1,5 +1,5 @@
|
|||||||
C Add\scomments\sdescribing\sUNKNOWN_LOCK\sto\spager.c.\sImprove\ssome\sother\scomments\si\sthe\ssame\sfile.
|
C Fix\sa\sbug\sto\sdo\swith\sdeleting\sthe\sjournal\sfile\swhen\sexiting\sexclusive-locking\smode.
|
||||||
D 2010-08-05T18:53:27
|
D 2010-08-06T06:54:48
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e
|
F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@ -156,7 +156,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f
|
|||||||
F src/os_os2.c 72d0b2e562952a2464308c4ce5f7913ac10bef3e
|
F src/os_os2.c 72d0b2e562952a2464308c4ce5f7913ac10bef3e
|
||||||
F src/os_unix.c ae5ca8a6031380708f3fec7be325233d49944914
|
F src/os_unix.c ae5ca8a6031380708f3fec7be325233d49944914
|
||||||
F src/os_win.c 51cb62f76262d961ea4249489383d714501315a7
|
F src/os_win.c 51cb62f76262d961ea4249489383d714501315a7
|
||||||
F src/pager.c 07bda904e5b3e6fe6c9425a205fcaf1dca5a444c
|
F src/pager.c f8fdab85e2dd0a3a55fc2bf212035f50ffcada13
|
||||||
F src/pager.h 80726162dc3942f59ab27b738fb667b9ba0a89d5
|
F src/pager.h 80726162dc3942f59ab27b738fb667b9ba0a89d5
|
||||||
F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58
|
F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58
|
||||||
F src/pcache.c 1e9aa2dbc0845b52e1b51cc39753b6d1e041cb07
|
F src/pcache.c 1e9aa2dbc0845b52e1b51cc39753b6d1e041cb07
|
||||||
@ -541,6 +541,7 @@ F test/null.test a8b09b8ed87852742343b33441a9240022108993
|
|||||||
F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec
|
F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec
|
||||||
F test/pager1.test d8e4b2bc8164c920e6ea0572c9e13576d6e4f3fa
|
F test/pager1.test d8e4b2bc8164c920e6ea0572c9e13576d6e4f3fa
|
||||||
F test/pager2.test f5c757c271ce642d36a393ecbfb3aef1c240dcef
|
F test/pager2.test f5c757c271ce642d36a393ecbfb3aef1c240dcef
|
||||||
|
F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f
|
||||||
F test/pagerfault.test c1d176326ce244db157ce9c3ba128be2a9b172d6
|
F test/pagerfault.test c1d176326ce244db157ce9c3ba128be2a9b172d6
|
||||||
F test/pagerfault2.test 1f79ea40d1133b2683a2f811b00f2399f7ec2401
|
F test/pagerfault2.test 1f79ea40d1133b2683a2f811b00f2399f7ec2401
|
||||||
F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806
|
F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806
|
||||||
@ -842,7 +843,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
|||||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||||
P acd26b8b746980c344db017a0e96dbd92c89acdf
|
P 54eff6de9d8d87f33192c192ca91907c4c090988
|
||||||
R c079a70d95550574b0e39982e236e749
|
R d766f7dfb5a440ae684ea90a650f2fcb
|
||||||
U dan
|
U dan
|
||||||
Z 83b26f553c42e8e1edd2dad0b7de50dd
|
Z d043fca41f68ab4a258746c2916bd634
|
||||||
|
@ -1 +1 @@
|
|||||||
54eff6de9d8d87f33192c192ca91907c4c090988
|
6217b607f0cd60383c6cb4ab0fe9da008f611244
|
48
src/pager.c
48
src/pager.c
@ -147,6 +147,22 @@ int sqlite3PagerTrace=1; /* True to enable tracing */
|
|||||||
** | V |
|
** | V |
|
||||||
** +<------WRITER_FINISHED-------->+
|
** +<------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:
|
** NONE:
|
||||||
**
|
**
|
||||||
** The pager starts up in this state. Nothing is guaranteed in this
|
** The pager starts up in this state. Nothing is guaranteed in this
|
||||||
@ -172,6 +188,10 @@ int sqlite3PagerTrace=1; /* True to enable tracing */
|
|||||||
** a locking_mode=exclusive connection can transition from READER to NONE
|
** a locking_mode=exclusive connection can transition from READER to NONE
|
||||||
** is via the ERROR state (see below).
|
** 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 read transaction may be active (but a write-transaction cannot).
|
||||||
** * A SHARED or greater lock is held on the database file.
|
** * A SHARED or greater lock is held on the database file.
|
||||||
** * The dbSize variable may be trusted (even if a user-level read
|
** * The dbSize variable may be trusted (even if a user-level read
|
||||||
@ -183,8 +203,15 @@ int sqlite3PagerTrace=1; /* True to enable tracing */
|
|||||||
**
|
**
|
||||||
** WRITER_INITIAL:
|
** 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 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 dbSize, dbOrigSize and dbFileSize variables are all valid.
|
||||||
** * The contents of the pager cache have not been modified.
|
** * The contents of the pager cache have not been modified.
|
||||||
** * The journal file may or may not be open.
|
** * The journal file may or may not be open.
|
||||||
@ -266,20 +293,6 @@ int sqlite3PagerTrace=1; /* True to enable tracing */
|
|||||||
** state.
|
** 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:
|
** Notes:
|
||||||
**
|
**
|
||||||
** * A pager is never in WRITER_DBMOD or WRITER_FINISHED state if the
|
** * A pager is never in WRITER_DBMOD or WRITER_FINISHED state if the
|
||||||
@ -802,12 +815,14 @@ static char *print_pager_state(Pager *p){
|
|||||||
static char zRet[1024];
|
static char zRet[1024];
|
||||||
|
|
||||||
sqlite3_snprintf(1024, zRet,
|
sqlite3_snprintf(1024, zRet,
|
||||||
|
"Filename: %s\n"
|
||||||
"State: %s errCode=%d\n"
|
"State: %s errCode=%d\n"
|
||||||
"Lock: %s\n"
|
"Lock: %s\n"
|
||||||
"Locking mode: locking_mode=%s\n"
|
"Locking mode: locking_mode=%s\n"
|
||||||
"Journal mode: journal_mode=%s\n"
|
"Journal mode: journal_mode=%s\n"
|
||||||
"Backing store: tempFile=%d memDb=%d useJournal=%d\n"
|
"Backing store: tempFile=%d memDb=%d useJournal=%d\n"
|
||||||
"Journal: journalOff=%lld journalHdr=%lld\n"
|
"Journal: journalOff=%lld journalHdr=%lld\n"
|
||||||
|
, p->zFilename
|
||||||
, p->eState==PAGER_NONE ? "NONE" :
|
, p->eState==PAGER_NONE ? "NONE" :
|
||||||
p->eState==PAGER_READER ? "READER" :
|
p->eState==PAGER_READER ? "READER" :
|
||||||
p->eState==PAGER_WRITER_INITIAL ? "WRITER_INITIAL" :
|
p->eState==PAGER_WRITER_INITIAL ? "WRITER_INITIAL" :
|
||||||
@ -1819,13 +1834,14 @@ static int pager_end_transaction(Pager *pPager, int hasMaster){
|
|||||||
** call to pager_unlock(), as described above.
|
** call to pager_unlock(), as described above.
|
||||||
*/
|
*/
|
||||||
static void pagerUnlockAndRollback(Pager *pPager){
|
static void pagerUnlockAndRollback(Pager *pPager){
|
||||||
if( pPager->eState!=PAGER_ERROR ){
|
if( pPager->eState!=PAGER_ERROR && pPager->eState!=PAGER_NONE ){
|
||||||
assert( assert_pager_state(pPager) );
|
assert( assert_pager_state(pPager) );
|
||||||
if( pPager->eState>=PAGER_WRITER_INITIAL ){
|
if( pPager->eState>=PAGER_WRITER_INITIAL ){
|
||||||
sqlite3BeginBenignMalloc();
|
sqlite3BeginBenignMalloc();
|
||||||
sqlite3PagerRollback(pPager);
|
sqlite3PagerRollback(pPager);
|
||||||
sqlite3EndBenignMalloc();
|
sqlite3EndBenignMalloc();
|
||||||
}else if( pPager->eLock>=RESERVED_LOCK && !pPager->exclusiveMode ){
|
}else if( pPager->eLock>=RESERVED_LOCK && !pPager->exclusiveMode ){
|
||||||
|
assert( pPager->eState==PAGER_READER );
|
||||||
pager_end_transaction(pPager, 0);
|
pager_end_transaction(pPager, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
33
test/pager3.test
Normal file
33
test/pager3.test
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# 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
|
Reference in New Issue
Block a user