mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
If xAccess() fails while attempting to detect a hot-journal file, do not assume that the error was an out-of-memory condition. (CVS 5515)
FossilOrigin-Name: 70f20425e8197bce74b412f65050d954acb5bde4
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
||||
C Define\s_GNU_SOURCE\sonly\sif\sit\sis\snot\salready\sdefined.\s\sTicket\s#3263.\s(CVS\s5514)
|
||||
D 2008-07-31T17:35:45
|
||||
C If\sxAccess()\sfails\swhile\sattempting\sto\sdetect\sa\shot-journal\sfile,\sdo\snot\sassume\sthat\sthe\serror\swas\san\sout-of-memory\scondition.\s(CVS\s5515)
|
||||
D 2008-08-01T10:50:23
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in bbb62eecc851379aef5a48a1bf8787eb13e6ec06
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@@ -135,7 +135,7 @@ F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
|
||||
F src/os_os2.c 676ed273b17bd260f905df81375c9f9950d85517
|
||||
F src/os_unix.c fe0dbc35bcd3de49e46b132abfc0f45d6dd6a864
|
||||
F src/os_win.c aefe9ee26430678a19a058a874e4e2bd91398142
|
||||
F src/pager.c a6ecad26297469a8a3d1fd7a7c3dc2d603955044
|
||||
F src/pager.c 6ad4d2b9b62a40f9ee898111d4519fec2e7c4796
|
||||
F src/pager.h 588c1ac195228b2da45c4e5f7ab6c2fd253d1751
|
||||
F src/parse.y d962e544d9953289db23c1d4cc2dab514c7136fa
|
||||
F src/pragma.c 6e207b4f69901089758c02c02e0bf86ed12a4d8f
|
||||
@@ -614,7 +614,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
P d43ff7bb8fc59c54b85658aaeb3dd088a324276f
|
||||
R e9616e8e48e4c16696138dc02f276c0f
|
||||
U drh
|
||||
Z 0d489aea3de9f958e0d9db5f75558e86
|
||||
P bc5abd31a7b5bc656edbb54c1c4523549d888056
|
||||
R fcbe4ad8b3e67d6472323658421c446a
|
||||
U danielk1977
|
||||
Z aceab1fca2abe9cb8b7e81fe04cfe121
|
||||
|
@@ -1 +1 @@
|
||||
bc5abd31a7b5bc656edbb54c1c4523549d888056
|
||||
70f20425e8197bce74b412f65050d954acb5bde4
|
39
src/pager.c
39
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.467 2008/07/22 05:18:01 shane Exp $
|
||||
** @(#) $Id: pager.c,v 1.468 2008/08/01 10:50:23 danielk1977 Exp $
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_DISKIO
|
||||
#include "sqliteInt.h"
|
||||
@@ -3144,11 +3144,11 @@ static PgHdr *pager_get_all_dirty_pages(Pager *pPager){
|
||||
** is hot. The pager_playback() routine will discover that the
|
||||
** journal file is not really hot and will no-op.
|
||||
*/
|
||||
static int hasHotJournal(Pager *pPager){
|
||||
static int hasHotJournal(Pager *pPager, int *pExists){
|
||||
sqlite3_vfs *pVfs = pPager->pVfs;
|
||||
int res = 0;
|
||||
int rc = SQLITE_OK;
|
||||
*pExists = 0;
|
||||
if( pPager->useJournal && pPager->fd->pMethods ){
|
||||
int rc;
|
||||
int exists;
|
||||
int locked;
|
||||
|
||||
@@ -3160,16 +3160,17 @@ static int hasHotJournal(Pager *pPager){
|
||||
if( rc==SQLITE_OK && exists && !locked ){
|
||||
int nPage;
|
||||
rc = sqlite3PagerPagecount(pPager, &nPage);
|
||||
if( rc==SQLITE_OK && nPage==0 ){
|
||||
if( rc==SQLITE_OK ){
|
||||
if( nPage==0 ){
|
||||
sqlite3OsDelete(pVfs, pPager->zJournal, 0);
|
||||
exists = 0;
|
||||
}else{
|
||||
*pExists = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res = (rc!=SQLITE_OK ? -1 : (exists && !locked));
|
||||
}
|
||||
|
||||
return res;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3435,7 +3436,7 @@ static int readDbPage(Pager *pPager, PgHdr *pPg, Pgno pgno){
|
||||
*/
|
||||
static int pagerSharedLock(Pager *pPager){
|
||||
int rc = SQLITE_OK;
|
||||
int isHot = 0;
|
||||
int isErrorReset = 0;
|
||||
|
||||
/* If this database is opened for exclusive access, has no outstanding
|
||||
** page references and is in an error-state, now is the chance to clear
|
||||
@@ -3444,7 +3445,7 @@ static int pagerSharedLock(Pager *pPager){
|
||||
*/
|
||||
if( !MEMDB && pPager->exclusiveMode && pPager->nRef==0 && pPager->errCode ){
|
||||
if( pPager->journalOpen ){
|
||||
isHot = 1;
|
||||
isErrorReset = 1;
|
||||
}
|
||||
pPager->errCode = SQLITE_OK;
|
||||
pager_reset(pPager);
|
||||
@@ -3458,9 +3459,10 @@ static int pagerSharedLock(Pager *pPager){
|
||||
return pPager->errCode;
|
||||
}
|
||||
|
||||
if( pPager->state==PAGER_UNLOCK || isHot ){
|
||||
if( pPager->state==PAGER_UNLOCK || isErrorReset ){
|
||||
sqlite3_vfs *pVfs = pPager->pVfs;
|
||||
if( !MEMDB ){
|
||||
int isHotJournal;
|
||||
assert( pPager->nRef==0 );
|
||||
if( !pPager->noReadlock ){
|
||||
rc = pager_wait_on_lock(pPager, SHARED_LOCK);
|
||||
@@ -3474,12 +3476,13 @@ static int pagerSharedLock(Pager *pPager){
|
||||
/* If a journal file exists, and there is no RESERVED lock on the
|
||||
** database file, then it either needs to be played back or deleted.
|
||||
*/
|
||||
rc = hasHotJournal(pPager);
|
||||
if( rc<0 ){
|
||||
rc = SQLITE_IOERR_NOMEM;
|
||||
if( !isErrorReset ){
|
||||
rc = hasHotJournal(pPager, &isHotJournal);
|
||||
if( rc!=SQLITE_OK ){
|
||||
goto failed;
|
||||
}
|
||||
if( rc==1 || isHot ){
|
||||
}
|
||||
if( isErrorReset || isHotJournal ){
|
||||
/* Get an EXCLUSIVE lock on the database file. At this point it is
|
||||
** important that a RESERVED lock is not obtained on the way to the
|
||||
** EXCLUSIVE lock. If it were, another process might open the
|
||||
@@ -3506,7 +3509,7 @@ static int pagerSharedLock(Pager *pPager){
|
||||
** OsTruncate() call used in exclusive-access mode also requires
|
||||
** a read/write file handle.
|
||||
*/
|
||||
if( !isHot && pPager->journalOpen==0 ){
|
||||
if( !isErrorReset && pPager->journalOpen==0 ){
|
||||
int res;
|
||||
rc = sqlite3OsAccess(pVfs,pPager->zJournal,SQLITE_ACCESS_EXISTS,&res);
|
||||
if( rc==SQLITE_OK ){
|
||||
|
Reference in New Issue
Block a user