1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-04 04:22:36 +03:00

Open the journal file for read-only when doing a playback. Ticket #351. (CVS 1019)

FossilOrigin-Name: 66ac7aea3df8533a49c8c05ba57c5a7015626828
This commit is contained in:
drh
2003-06-14 11:42:57 +00:00
parent 892f671cf3
commit e2227f0092
3 changed files with 17 additions and 16 deletions

View File

@ -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 );