diff options
author | drh <drh@noemail.net> | 2003-06-14 11:42:57 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2003-06-14 11:42:57 +0000 |
commit | e2227f0092c6096cb4734a1b42a2ac6b9b190e8c (patch) | |
tree | fbcd8c750d4978defe9f11da0aa22587f2609dc2 /src/pager.c | |
parent | 892f671cf3689cd0ac250be6e2f76a6bb7f1d370 (diff) | |
download | sqlite-e2227f0092c6096cb4734a1b42a2ac6b9b190e8c.tar.gz sqlite-e2227f0092c6096cb4734a1b42a2ac6b9b190e8c.zip |
Open the journal file for read-only when doing a playback. Ticket #351. (CVS 1019)
FossilOrigin-Name: 66ac7aea3df8533a49c8c05ba57c5a7015626828
Diffstat (limited to 'src/pager.c')
-rw-r--r-- | src/pager.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/pager.c b/src/pager.c index 51c759011..85d6b8896 100644 --- a/src/pager.c +++ b/src/pager.c @@ -18,7 +18,7 @@ ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.84 2003/06/04 16:24:40 drh Exp $ +** @(#) $Id: pager.c,v 1.85 2003/06/14 11:42:58 drh Exp $ */ #include "os.h" /* Must be first to enable large file support */ #include "sqliteInt.h" @@ -1221,7 +1221,7 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){ /* If a journal file exists, try to play it back. */ if( pPager->useJournal && sqliteOsFileExists(pPager->zJournal) ){ - int rc, dummy; + int rc; /* Get a write lock on the database */ @@ -1235,14 +1235,15 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){ } pPager->state = SQLITE_WRITELOCK; - /* Open the journal for exclusive access. Return SQLITE_BUSY if - ** we cannot get exclusive access to the journal file. + /* Open the journal for reading only. Return SQLITE_BUSY if + ** we are unable to open the journal file. ** - ** Even though we will only be reading from the journal, not writing, - ** we have to open the journal for writing in order to obtain an - ** exclusive access lock. + ** The journal file does not need to be locked itself. The + ** journal file is never open unless the main database file holds + ** a write lock, so there is never any chance of two or more + ** processes opening the journal at the same time. */ - rc = sqliteOsOpenReadWrite(pPager->zJournal, &pPager->jfd, &dummy); + rc = sqliteOsOpenReadOnly(pPager->zJournal, &pPager->jfd); if( rc!=SQLITE_OK ){ rc = sqliteOsUnlock(&pPager->fd); assert( rc==SQLITE_OK ); |